Score system - HELP
#1

Can you help me about making a score.

For example, when someone type /score, message comes:


TEAM1: (NumberOfKills) // TEAM2: (NumberOfKills)

Not. score on tab list - giving level, but comes one more number when someone kills other player.
Reply
#2

Hmm, do you have a variable on your script for saving team kills?
Reply
#3

Код:
new team1score=0; // declaring team 1 score
new team2score=0; //declaring team 2 score
new team[MAX_PLAYERS]; //will use to find out team of player
Код:
public OnPlayerRequestClass(playerid,classid)
{
   if(classid(playerid)==0)
   {
        team[playerid]=0; //setting team of player
   }
   if(classid(playerid)==1)
   {
        team[playerid]=1; //setting team of player
   }
}
Код:
OnPlayerDeath(playerid,killerid,reason)
{
     if(team[killerid]==0)
     {
          team1score++; //adding kill to team which killed player
    }
    if(team[playerid]==1)
    {
          team2score++; //adding kill to team which killed player
    }
    if(team[playerid]==0)
    {
          team1score++;
    }
}
Код:
CMD:score(playerid,params[]) //displaying kills
{
       new string[100];
       format(string,sizeof(string),"Team1:%i,Team2:%i",team1score,team2score);
       SendClientMessage(playerid,COLOR_BLUE,string);
}
Untested. Hope it works
Reply
#4

I have pScore

So: OnPlayerDeath: when someone from TEAM1 kill someone from TEAM2, to pScoreTEAM1 +1, or when someone from TEAM2 kill someone from TEAM1, to pScoreTEAM2 +1.
Reply
#5

Just to let you know
Код:
pscoreTEAM1++
means that the value will be added by one.
Reply
#6

Can you explain me what : if(classid(playerid)==0) is here for.
Reply
#7

remember on top of your script you do
Код:
AddPlayerClass(...)
to create teams? So [cpde]onplayerrequestclass[/code] it checks what PlayerClass have you select (on the initial menu of skin select) and sets the team of player that we declared on top of the script to the team he chose. Get it?
Reply
#8

Is this right?

Код:
OnPlayerDeath(playerid,killerid,reason)
{
     if(team[killerid]==0)
     {
          team1score++; //adding kill to team which killed player
    }
    if(team[playerid]==1)
    {
          team2score++; //adding kill to team which killed player
    }
    if(team[playerid]==0)
    {
          team1score++;
    }
}
InGame when I killed someone i get 2points for team1, when someone kill me, I again get points.
Reply
#9

oh sorry. its my bad.. I was sleepy. It should be just
Код:
OnPlayerDeath(playerid,killerid,reason)
{
    if(team[killerid]==0)
    {
          team1score++; //adding kill to team which killed player
    }
    if(team[playerid]==1)
    {
          team2score++; //adding kill to team which killed player
    }
}
The previous code added score to team one twice.
Reply
#10

I dont think this is right. Correct me if I'm wrong.

if(team[killerid]==0)
{
team1score++; //adding kill to team which killed player
}

For Team1 one more score.

if(team[playerid]==1)
{
team2score++; //adding kill to team which killed player
}

For team 2 one more score.

Why is for team1score++ killerid
And why is for team2score++ playerid
Reply
#11

pawn Код:
// Correct
if(team[killerid]==0)
{
    team1score++; //adding kill to team which killed player
}
pawn Код:
// Wrong
if(team[playerid]==1)
{
    team2score++; //adding kill to team which killed player
}
If someone dies from the team 2, you add score. It should be minus 1!
Reply
#12

Yes, my bad again. sorry. Its supposed to be [killerid] for the second case too.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)