OnPlayerDeath/GivePlayerMoney - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath/GivePlayerMoney (
/showthread.php?tid=301694)
OnPlayerDeath/GivePlayerMoney -
Gooday - 05.12.2011
Hi, how i could make a spawn when someone die and give him a message like:
*me died*
You were critically injured, your medical bill is 2000$
give him -2000$
and spawn him here:
Quote:
AddPlayerClass(0,-320.2867,1052.6426,20.3403,341.9651,0,0,0,0,0,0); // OnPlayerDeath
|
Re: OnPlayerDeath/GivePlayerMoney -
Thresholdold - 05.12.2011
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, -2000);
SendClientMessage(playerid, 0xFF0000AA, "You have died. Your medical bill is: $2000");
GameTextForPlayer(playerid, "~r~Medical Bills: $2000", 5000, 5);
return 1;
}
Re: OnPlayerDeath/GivePlayerMoney -
jueix - 05.12.2011
Quote:
Originally Posted by Threshold
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { GivePlayerMoney(playerid, -2000); SendClientMessage(playerid, 0xFF0000AA, "You have died. Your medical bill is: $2000"); GameTextForPlayer(playerid, "~r~Medical Bills: $2000", 5000, 5); return 1; }
|
or you would do
Quote:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, -2000);
SendClientMessage(playerid, 0xFF0000AA, "You have died. Your medical bill is: $2000");
GameTextForPlayer(playerid, "~r~Medical Bills: $2000", 5000, 5);
SetPlayerPos(playerid, ,-320.2867,1052.6426,20.3403);
return 1;
}
|
Re: OnPlayerDeath/GivePlayerMoney -
Thresholdold - 05.12.2011
Quote:
Originally Posted by jueix
or you would do
|
Ahh I didn't see the last bit... but no... that would set his position, then he would simply respawn somewhere else...
Can you please show me your OnPlayerSpawn function, so then I can edit it so you can respawn at that location.
Re: OnPlayerDeath/GivePlayerMoney -
jueix - 05.12.2011
Quote:
Originally Posted by Threshold
Ahh I didn't see the last bit... but no... that would set his position, then he would simply respawn somewhere else...
Can you please show me your OnPlayerSpawn function, so then I can edit it so you can respawn at that location.
|
I use something like this.
Quote:
new dead[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
if(Dead[playerid] != 0) { //basicly its saying that if the value = 0 it will tele him to the spawn point.
SetPlayerPos(playerid,,-320.2867,1052.6426,20.3403); //this is the hospital when you die
Dead[playerid] = 0;
}
else {
SetPlayerPos(playerid, x, y, z);// this teles you to spawn point when they pick a class first time
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
Dead[playerid] = 1;
return 1;
}
|
Re: OnPlayerDeath/GivePlayerMoney -
Thresholdold - 05.12.2011
That's a very complex way of putting it... it could be alot simpler, but without having seen his OnPlayerSpawn function, I cannot generate the code for it...
Re: OnPlayerDeath/GivePlayerMoney -
Kostas' - 05.12.2011
Do it with jueix's way, because actually you cannot Set the position of players on the OnPlayerDeath Callback, because the player is already dead and after that take place the OnPlayerSpawn part.