SA-MP Forums Archive
Can u detect killed by rpg and who killed him? also with grenade and satchel? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Can u detect killed by rpg and who killed him? also with grenade and satchel? (/showthread.php?tid=312766)



Can u detect killed by rpg and who killed him? also with grenade and satchel? - chrism11 - 22.01.2012

like the title says pls post how or just the code what ever you prefer, thx


Re: Can u detect killed by rpg and who killed him? also with grenade and satchel? - Whitetiger - 25.01.2012

pawn Код:
new LastShot[MAX_PLAYERS] = -1, Shooter[MAX_PLAYERS] = -1;
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) {
    LastShot[playerid] = weaponid;
    Shooter[playerid] = issuerid;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if(LastShot[playerid] != -1 && Shooter[playerid] == killerid) reason = LastShot[playerid];
}

public OnPlayerSpawn(playerid) {
    LastShot[playerid] = -1;
    Shooter[playerid] = -1
}
or

pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
    reason = GetPlayerWeapon(killerid);
}
I would use the first example cause it fixes a bug if the player changes weapon after firing rpg,nade etc

*UNTESTED CODE*


Re: Can u detect killed by rpg and who killed him? also with grenade and satchel? - chrism11 - 29.01.2012

thx but it didnt work for some reason, it didnt get the killerid, or the reason