OnPlayerDeath help - 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 help (
/showthread.php?tid=529396)
OnPlayerDeath help -
tommzy09 - 02.08.2014
hey guys, on my script I have made it so that when someone gets killed by another player, it comes up in the chat saying, for example: "John(5) Died. Killed by Smith(6) - Sawn Off's.".
when a player dies from suicide, I want it just to say: "John(5) Died."
but the thing is, it instead says: "John(5) Died. Killed by (5) - ."
how do i go about doing this? here is my script.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new name[MAX_PLAYER_NAME];
new killer[MAX_PLAYER_NAME];
new weapname[50];
new string[50];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(killerid, killer, sizeof(killer));
GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));
format(string,128,"%s(%d) Died. Killed by %s(%d) - %s.",name,playerid,killer,playerid,weapname);
SendClientMessageToAll(0xAA3333AA, string);
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 6);
SetPlayerColor(killerid, 0xAA3333AA);
PlayerPlaySound(playerid, 44070, 0, 0, 0);
SendDeathMessage(killerid, playerid, reason);
StopAudioStreamForPlayer(playerid);
return 1;
}
Re: OnPlayerDeath help -
Stinged - 02.08.2014
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new name[MAX_PLAYER_NAME];
new killer[MAX_PLAYER_NAME];
new weapname[50];
new string[50];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(killerid, killer, sizeof(killer));
GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));
if (killerid == INVALID_PLAYER_ID)
{
format(string, sizeof (string), "%s (%d) Died.", name, playerid);
SendClientMessageToAll(0xAA3333AA, string);
}
else
{
format(string,128,"%s(%d) Died. Killed by %s(%d) - %s.",name,playerid,killer,playerid,weapname);
SendClientMessageToAll(0xAA3333AA, string);
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 6);
SetPlayerColor(killerid, 0xAA3333AA);
PlayerPlaySound(playerid, 44070, 0, 0, 0);
StopAudioStreamForPlayer(playerid);
}
SendDeathMessage(killerid, playerid, reason);
return 1;
}
You need to check if killer id is invalid.
Re: OnPlayerDeath help -
tommzy09 - 02.08.2014
i knew i had to do else/if statements, just didn't know where :/
thanks for the help