How to make players now lose money on death
#1

Hey i want to know how can i not make a player lose money on death if they used /kill or /changeteam(a cmd we made to put players back in class selection) If a player kills there self i dont want them to lose money how can i make that happen?
Reply
#2

You could use a variable to check wether they used one of those commands (IE: playerKilledSelf[MAX_PLAYERS]) and at OnPlayerDeath check if its 1 or 0, if it was 1 don't take money.

PHP код:
new playerKilledSelf[MAX_PLAYERS];
if(!
strcmp(cmdtext"/kill"true))
{
     
playerKilledSelf[playerid] = 1;
     return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
playerKilledSelf[playerid] == 1)
    {
        
playerKilledSelf[playerid] = 0;
    }
    else
    {
      
GivePlayerMoney(playerid, -500);
     }

Just a simple example of one way to do this
Reply
#3

I confused a bit. Do you mean everytime someone dies normally to loose his money, but if he type a command for example /kill not to loose the money. If I understand correct then you can make a global variable and everytime players type the command you want to use set the variable to 1 and check OnPlayerDeath Callback if the player who died had the variable not equal to 1 then GivePlayerMoney the amount you want.

Edit: Person above me was faster!
Reply
#4

Quote:
Originally Posted by Dwane
Посмотреть сообщение
I confused a bit. Do you mean everytime someone dies normally to loose his money, but if he type a command for example /kill not to loose the money. If I understand correct then you can make a global variable and everytime players type the command you want to use set the variable to 1 and check OnPlayerDeath Callback if the player who died had the variable not equal to 1 then GivePlayerMoney the amount you want.

Edit: Person above me was faster!
Yes if the player uses the command to commit suicide i wint them to not lose money
Reply
#5

Quote:
Originally Posted by malcomjones
Посмотреть сообщение
Yes if the player uses the command to commit suicide i wint them to not lose money
Use the code 'Think' submitted. If you still need help, reply and i'll give you some help.
Reply
#6

But thanks anyways it helped
Reply
#7

Well they are right but as far as you don't look to know much, just make it give player they money he is going to lose using GivePlayerMoney(playerid, money);

Not the best thing, but maybe the best one for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)