OnPlayerTakeDamage gets called wrong - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP (
https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (
https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: OnPlayerTakeDamage gets called wrong (
/showthread.php?tid=421837)
OnPlayerTakeDamage gets called wrong -
[SF]OutLawZ - 11.03.2013
Hi, I've recently made a skin hit system which uses OnPlayerTakeDamage.
But after i restart my server (without the player leaving), when a player spawns the public will automatically get called.
Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
SendClientMessage(playerid, -1, "This will get called after restart on spawn");
//Other Code
return 1;
}
This is a SA:MP bug am i right?
Re: OnPlayerTakeDamage gets called wrong -
MP2 - 11.03.2013
Confirmed.
Re: OnPlayerTakeDamage gets called wrong -
Kar - 11.03.2013
how much is the amount of damage lost? if it's 0.0 can't you detect it with that?
Re: OnPlayerTakeDamage gets called wrong -
iRage - 11.03.2013
Alternate Fix
I'm aware that you can remove few lines from what is being stated in this post but SA-MP acts weird sometimes so I'm just making sure that nothing would go off the plan.
Make a public variable on top of your script.
pawn Code:
new Spawned[MAX_PLAYERS];
Add this to the following callbacks:
OnPlayerConnect &
OnPlayerDisconnect
Add this to the following callbacks:
OnGameModeInit,
OnGameModeExit
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
Spawned[i] = 0;
}
Add this to the following callback:
OnPlayerSpawn
Now change your code to:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(!Spawned[playerid])
{
Spawned[playerid] = 1;
}
else
{
SendClientMessage(playerid, -1, "This will get called after restart on spawn");
//Other Code
}
return 1;
}