[Tutorial] Simple Team Setup + Player Data Template
#2

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    //The != operator means NOT equal to.
    //This is one of the simplest forms of control structures.
    //INVALID_PLAYER_ID is a define inside of a_players (or a_samp) to detect, well if they're not a real player...Or not connected
    if(killerid != INVALID_PLAYER_ID)
    {
        //So if they ARE a valid player, let's continue our code.
        //Here we INCREMENT our player's Kills variable...or array slot.
        //What incrementing does is adds 1 to whatever the previous value is.
        //It's like doing...Info[playerid][Kills]+=1;
        Info[playerid][Kills]++;
    }
    //Even if the killer is an invalid player...We'll still give our player a death.
    Info[playerid][Deaths]++; //we increment again, this time using playerid instead of killerid (playerid = the one who died | killerid = the one who killed the player)

    //So basically, it will check our if statement... REGARDLESS of whether the player is a valid player we'll give the dead guy a death
    return 1;
}
You're giving the player who died a kill.. instead of "playerid" use "killerid"
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)