Weapon Death? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weapon Death? (
/showthread.php?tid=108058)
Weapon Death? -
TheNotorius - 12.11.2009
Hi, im going to create something for the death reason and kill except i want it to appear on screen so something Like Player Darkside[id] Has Killed Player Bert[id] With Weapon: M4 This is what i got..
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new pName[MAX_PLAYER_NAME];
new string[48];
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "Player %s has Died", pName);
SendClientMessageToAll(0xFF0000AA, string);
return 1;
}
Can someone please help me

Thank you
Re: Weapon Death? -
Gergo1352 - 12.11.2009
You can find an example here:
https://sampwiki.blast.hk/wiki/GetWeaponName
Re: Weapon Death? -
TheNooB - 12.11.2009
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new Killer;
new Dead;
new string[128];
new WName[128];
new weaponid = GetPlayerWeapon(killerid);
GetPlayerName(killerid, Killer, sizeof Killer);
GetPlayerName(playerid, Dead, sizeof Dead);
GetWeaponName(weaponid, WName, sizeof WName);
format(string, sizeof string, "The player %s (ID: %d) killed player %s (ID: %d) with a %s", Killer, killerid, Dead, playerid, WName);
SendClientMessageToAll(0xBB0000AA, string);
return 1;
}
Or
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new Killer;
new Dead;
new string[128];
GetPlayerName(killerid, Killer, sizeof Killer);
GetPlayerName(playerid, Dead, sizeof Dead);
format(string, sizeof string, "The player %s (ID: %d) killed player %s (%d) with a %s", Killer, killerid, Dead, playerid, reason);
SendClientMessageToAll(0xBB0000AA, string);
return 1;
}
Warning: untested code! (This code is only a draft!):
1є - The first code, there may be a bug if the player who killed quickly change weapon after killing the other
2є - Perhaps the second submit a bug not to say the name of the weapon
Re: Weapon Death? -
TheNooB - 12.11.2009
Quote:
Originally Posted by Seif_
Quote:
Originally Posted by TheNooB
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { new Killer; new Dead; new string[128]; new WName[128]; new weaponid = GetPlayerWeapon(killerid);
GetPlayerName(killerid, Killer, sizeof Killer); GetPlayerName(playerid, Dead, sizeof Dead); GetWeaponName(weaponid, WName, sizeof WName);
format(string, sizeof string, "The player %s (ID: %d) killed player %s (ID: %d) with a %s", Killer, killerid, Dead, playerid, WName); SendClientMessageToAll(0xBB0000AA, string); return 1; }
Or
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { new Killer; new Dead; new string[128];
GetPlayerName(killerid, Killer, sizeof Killer); GetPlayerName(playerid, Dead, sizeof Dead);
format(string, sizeof string, "The player %s (ID: %d) killed player %s (%d) with a %s", Killer, killerid, Dead, playerid, reason); SendClientMessageToAll(0xBB0000AA, string); return 1; }
Warning: untested code!
|
Only the first one will work. But 128 is a waste of arrays, 32 is enough.
|
I just edit to put the possible bugs:
Quote:
Originally Posted by TheNooB
Warning: untested code! (This code is only a draft!):
1є - The first code, there may be a bug if the player who killed quickly change weapon after killing the other
2є - Perhaps the second submit a bug not to say the name of the weapon
|
Re: Weapon Death? -
TheNotorius - 12.11.2009
Okay Guys, thank you so much for your help!
Re: Weapon Death? -
Francis[French] - 12.11.2009
You can use GetWeaponName on reason. As reason is the weapon ID that was used to kill, if memory serves me right.