OnplayerDeath Killer ID Undefined (Onplayerweaponshot return 0;) -
PRoleplay - 18.07.2016
I'm using custom Damage Script to avoid Sprunkguard Cheat
on my OnplayerWeaponshot i return 0; to avoid default damage then i set the target hp manually depends on Gun ID
So here's the problem, on my onplayerdeath killer id is undefined, ( ithink it cause my onplayerweaponshot return 0)
so the default Program can't detect killer id
any suggestion to fix this??
Re: OnplayerDeath Killer ID Undefined - WhiteGhost - 18.07.2016
What do u mean?
Also,have a look at
https://sampwiki.blast.hk/wiki/OnPlayerDeath
Re: OnplayerDeath Killer ID Undefined -
PRoleplay - 18.07.2016
When i tried to car ram it detects the killerid
but when i try to kill target using gun
it can't detect the killer id
maybe this cause my problem
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
i sethpmanually code here then return 0; to avoid default damage
return 0;// i think this one is the cause of the issue, but if i removed this, my server side damage will mess up
}
Re: OnplayerDeath Killer ID Undefined -
Threshold - 18.07.2016
Because they're not being killed by the player, they're being killed by the server setting their HP to 0 or below... so there IS no killerid. You need a player variable that stores the player ID of the last person that shot them and use that as a killerid under OnPlayerDeath.
You'll need to exclude the killerid depending on the death reason.
Re: OnplayerDeath Killer ID Undefined -
PrO.GameR - 18.07.2016
Just void any OnPlayerDeath with reason 255 and call it yourself when you kill someone with your custom dmg.
Re: OnplayerDeath Killer ID Undefined -
GangstaSunny - 18.07.2016
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
//stuff
if(hitid != INVALID_PLAYER_ID){SetPVarInt(hitid, "LastHittedFrom", playerid);}
return 0;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPVarInt(playerid,"LastHittedFrom") != INVALID_PLAYER_ID)){killerid = GetPVarInt(playerid,"LastHittedFrom");}
//stuff
}
Should work.