function:OnPlayerDead(playerid, killerid, reason, executed)
{
if(executed == 1)
{
SendAdminAction(playerid, "%s has been executed by %s. (%s)", ReturnName(playerid), ReturnName(killerid), ReturnWeaponName(reason));
}
SetPlayerTeam(playerid, PLAYER_STATE_DEAD);
PlayerData[playerid][pRespawnTime] = gettime();
SendClientMessage(playerid, COLOR_YELLOWEX, "-> You're now dead. You need to wait 60 seconds until you can /respawnme.");
ClearAnimations(playerid);
for(new i =0; i <4; i++)
ApplyAnimation(playerid,"PED","KO_skid_back",4.1,0,1,1,1,0,1);
SetPlayerWeather(playerid, globalWeather);
TogglePlayerControllable(playerid, 0);
ResetWeapons(playerid);
return 1;
}
for(new i =0; i <4; i++)
ApplyAnimation(playerid,"PED","KO_skid_back",4.1,0,1,1,1,0,1);
ApplyAnimation(playerid,"PED","KO_skid_back",4.1,0,1,1,1,0,1);
SetPlayerWeather(playerid, globalWeather);
TogglePlayerControllable(playerid, 0);
ResetWeapons(playerid);
|
OnPlayerDead calls OnPlayerSpawn, thus no animation will perform if you apply it inside OnPlayerDead callback. You will need to pass a variable to OnPlayerSpawn to determine if a player died and apply the animation from there. Other way around is to check for player's health, if it is below 1.0, then apply the animation on that player or whatever you want to do with him. You can achieve this by utilizing OnPlayerUpdate callback. This would obviously not work if a player is killed instantly, e.g. in an explosion, but may be useful to omit events called by OnPlayerDead callback.
|
|
Got an headache, could you make the code for me? I'm a bit confused
![]() |
new Float:Health;
GetPlayerHealth(playerid, Health);
if (Health < 10.0)
{
//animation
}
|
under onplayerupdate
Код:
new Float:Health;
GetPlayerHealth(playerid, Health);
if (Health < 10.0)
{
//animation
}
|
|
Problem is, whenever I do that, the player still vulnerable and people can instantly come and kill him and it makes a bug that heals the player again, anything that can be possible to make the player not damageable whilst in death mode?
edit: I have done something similar to what you gave me, everything is fine but target vulnerable and the animation repeat itself. any way to make the animation do it once then stays like it? |