Explain me this code from top to bottom
#1

Deleted.
Reply
#2

Really?

Look up the functions on the SA:MP Wiki and how to use variables.
Reply
#3

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Really?

Look up the functions on the SA:MP Wiki and how to use variables.
I KNOW WHAT IT IS! I JUST WANT TO EDIT SOME THING IN THE CODE AND I NEED TO KNOW WHERE IS THE PART WHERE THE KILLED PLAYER GETS MONEY!
Reply
#4

Quote:
Originally Posted by RiChArD_A
Посмотреть сообщение
I KNOW WHAT IT IS! I JUST WANT TO EDIT SOME THING IN THE CODE AND I NEED TO KNOW WHERE IS THE PART WHERE THE KILLED PLAYER GETS MONEY!
Look up the functions on the SA:MP Wiki and how to use variables.

If you had done that by now you would already have your answer. Have a nice day.
Reply
#5

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
}
Reply
#6

Thanks Dwane, for helping support his theory that he needs to do nothing in life to get everything he wants. Promoting laziness is idiotic.
Reply
#7

pawn Код:
public OnPlayerDeath(playerid, killerid, reason) //callback when a player dies
{
    new playercash; //new variable
    if(killerid == INVALID_PLAYER_ID) { //if the killerid is invalid run the code block:
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason); //Sending a death message
        ResetPlayerMoney(playerid); //Reset the victim's money
    } else { //if the killerid is valid:
            SendDeathMessage(killerid,playerid,reason); //Sending a death message
            SetPlayerScore(killerid,GetPlayerScore(killerid)+2); //Giving the killer 2 extra score
            playercash = GetPlayerMoney(playerid); //Storing the victim's cash into playercash
            if (playercash > 100)  { //if the victim's cash is above 100:
                GivePlayerMoney(killerid, playercash); //Give the killer all of the victim's cash
                ResetPlayerMoney(playerid); //Reset the victim's cash
            }
        else // if the cash is lower than 100 or equal to 100
        {
            // do something;
        }
        }
    return 1;
}
By the way, your indents make the code hard to read.
Reply
#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
#9

read the fucking manual
Reply
#10

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Thanks Dwane, for helping support his theory that he needs to do nothing in life to get everything he wants. Promoting laziness is idiotic.
I explained him, I didn't give him a finished code to use as most here ask for. It's not that bad!

@RiChArD_A
- If the killer is valid/connected player and playerid's money are more than $100, then it will get -100 from the playerid. This is what your code above does.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)