Help. Give killer $1000 -
Hash [NL-RP] - 29.05.2010
Alright, I know this is simple but i don't really know how to do it never had to scripting roleplay servers
but i'v moved on to Death Matching servers. Okay lets get down to it,
When a player kills another how can i give him money.
Thanks in Advance
Re: Help. Give killer $1000 -
(SF)Noobanatior - 29.05.2010
ok here ya go under OnPlayerDeath go
pawn Код:
if(killerid != INVALID_PLAYER_ID) {
if(IsPlayerConnected(killerid)GivePlayerMoney(killerid,amount);
}
where amount is the dolar value
Re: Help. Give killer $1000 -
Retardedwolf - 29.05.2010
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new string[32];
//Award $1000 to the killer
GivePlayerMoney(killerid, 1000);
format(string, sizeof(string), "You now have %d.", GetPlayerMoney(killerid));
SendClientMessage(killerid, 0xFFFFFFAA, string);
}
https://sampwiki.blast.hk/wiki/GivePlayerMoney
Re: Help. Give killer $1000 -
(SF)Noobanatior - 29.05.2010
Quote:
Originally Posted by (SF)Noobanatior
ok here ya go under OnPlayerDeath go
pawn Код:
if(killerid != INVALID_PLAYER_ID) { if(IsPlayerConnected(killerid){ GivePlayerMoney(killerid,amount); format(string, sizeof(string), "You now have %d.", GetPlayerMoney(killerid)); SendClientMessage(killerid, 0xFFFFFFAA, string); } }
where amount is the dolar value
|
this is better i think as it checks it the killer is a vaild player and if therre conected b4 giving the the coin
Re: Help. Give killer $1000 -
Hash [NL-RP] - 29.05.2010
Quote:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { new string[32]; //Award $1000 to the killer GivePlayerMoney(killerid, 1000); format(string, sizeof(string), "You now have %d.", GetPlayerMoney(killerid)); SendClientMessage(killerid, 0xFFFFFFAA, string); }
https://sampwiki.blast.hk/wiki/GivePlayerMoney
|
Thank you very much.. works fine,
If you can, can i ask you a few more things, as i'v just started writting scripts from scratch
and not editing them
-How to get the list on the right hand side, which shows which player killed who,
-How to Limit the cash $0, so you can't go in to minus money.
Would really appreciate if ya'll can help
Re: Help. Give killer $1000 -
Sergei - 29.05.2010
Quote:
Originally Posted by (SF)Noobanatior
ok here ya go under OnPlayerDeath go
pawn Код:
if(killerid != INVALID_PLAYER_ID) { if(IsPlayerConnected(killerid)GivePlayerMoney(killerid,amount); }
where amount is the dolar value
|
What a stupid piece of code.
You check if killerid is invalid ID and in next step you check if killerid is connected.
Every function has IsPlayerConnected check included, so it doesn't matter if you check if killerid is valid or not sicne GivePlayerMoney will do it also.
Re: Help. Give killer $1000 -
(SF)Noobanatior - 29.05.2010
Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by (SF)Noobanatior
ok here ya go under OnPlayerDeath go
pawn Код:
if(killerid != INVALID_PLAYER_ID) { if(IsPlayerConnected(killerid)GivePlayerMoney(killerid,amount); }
where amount is the dolar value
|
What a stupid piece of code.
You check if killerid is invalid ID and in next step you check if killerid is connected.
Every function has IsPlayerConnected check included, so it doesn't matter if you check if killerid is valid or not sicne GivePlayerMoney will do it also.
|
read it i check if there != to an invalid id
Re: Help. Give killer $1000 -
Sergei - 29.05.2010
Код:
if(killerid != INVALID_PLAYER_ID)
Means if killerid is not invalid player id (so if killerid is actually valid player)
Код:
if(IsPlayerConnected(killerid))
Checks if killerid is connected (valid player).
Two checks which do the same + GivePlayerMoney also incldues IsPlayerConnected check, so basically you check three times in a row if killerid is connected? Is it more important than Obama or what?
Re: Help. Give killer $1000 -
RyDeR` - 29.05.2010
Quote:
Originally Posted by Seif_
Quote:
Originally Posted by $ЂЯĢ
Is it more important than Obama or what?
|
Obama isn't important
killerid does return INVALID_PLAYER_ID(meaning killerid does not exist). That means if you check IsPlayerConnected, it's the same thing, because killerid still doesn't exist.
GivePlayerMoney does include a connection check, but this statement would be more useful for SendDeathMessage.
|
True.
To be specific for people who wants to know, it returns 0xFFFF or 65535.