Explain me this code from top to bottom
#8

Quote:
Originally Posted by Dwane
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playercash; // new variable to store a value
    if(killerid == INVALID_PLAYER_ID) // if killerid is not a valid/connected player (ID 65536)
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason); // then it sends the icon of falling/explosion
        ResetPlayerMoney(playerid); // it sets money to 0
    }
    else // else killerid is a valid/connected player
    {
        SendDeathMessage(killerid,playerid,reason); // it sends the death message (icon killer > player with this weapon)
        SetPlayerScore(killerid,GetPlayerScore(killerid)+2); // it sets +2 score ( old score + 2 )
        playercash = GetPlayerMoney(playerid); // it assignes a value to the first variable with the playerid's money
        if (playercash > 100)  // if the cash is greater than 100
        {
            GivePlayerMoney(killerid, playercash); // then it gives the money to the killer
            ResetPlayerMoney(playerid); // it sets playerid's money to 0
        }
        else // if the cash is lower than 100 or equal to 100
        {
            // do something;
        }
    }
    return 1; // return a value to the callback
}
But what I don't want is to reset the playerid's money. I want to give him -100$

Is like this?
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playercash; // new variable to store a value
    if(killerid == INVALID_PLAYER_ID) // if killerid is not a valid/connected player (ID 65536)
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason); // then it sends the icon of falling/explosion
        ResetPlayerMoney(playerid); // it sets money to 0
    }
    else // else killerid is a valid/connected player
    {
        SendDeathMessage(killerid,playerid,reason); // it sends the death message (icon killer > player with this weapon)
        SetPlayerScore(killerid,GetPlayerScore(killerid)+2); // it sets +2 score ( old score + 2 )
        playercash = GetPlayerMoney(playerid); // it assignes a value to the first variable with the playerid's money
        if (playercash > 100)  // if the cash is greater than 100
        {
            GivePlayerMoney(killerid, playercash); // then it gives the money to the killer
            GivePlayerMoney(playerid, -100); // it sets playerid's money to 0 <<<< I CHANGES THIS.
        }
        else // if the cash is lower than 100 or equal to 100
        {
            // do something;
        }
    }
    return 1; // return a value to the callback
}
Reply


Messages In This Thread
Explain me this code from top to bottom - by RiChArD_A - 05.04.2013, 21:16
Re: Explain me this code from top to bottom - by Bakr - 05.04.2013, 21:17
Re: Explain me this code from top to bottom - by RiChArD_A - 05.04.2013, 21:25
Re: Explain me this code from top to bottom - by Bakr - 05.04.2013, 21:26
Re: Explain me this code from top to bottom - by Konstantinos - 05.04.2013, 21:28
Re: Explain me this code from top to bottom - by Bakr - 05.04.2013, 21:31
Re: Explain me this code from top to bottom - by MattyG - 05.04.2013, 21:34
Re: Explain me this code from top to bottom - by RiChArD_A - 05.04.2013, 21:35
Re: Explain me this code from top to bottom - by mastermax7777 - 05.04.2013, 21:37
Re: Explain me this code from top to bottom - by Konstantinos - 05.04.2013, 21:38

Forum Jump:


Users browsing this thread: 2 Guest(s)