24.09.2018, 16:53
PHP код:
new death_actor[MAX_PLAYERS]; // Storing actor ids in an array for every player (seeing how there should only be 1 "death actor" per player)
new RemoveActorTimer[MAX_PLAYERS]; // Storing timer IDs in order to kill them.
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
if(!IsPlayerNPC(playerid))
{
new name[24], kname[30], string[64];
new gunname[32], playername[MAX_PLAYER_NAME + 1], killername[MAX_PLAYER_NAME + 1];
GetWeaponName(reason, gunname, sizeof(gunname));
GetPlayerName(playerid, name, 24);
GetPlayerName(killerid, kname, 30);
format(string, sizeof(string), "%s has wasted %s using a %s.", killername, playername, gunname);
SendMessageToAllAdmins(string, -1);
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
if(IsValidActor(death_actor[playerid])) // Debugging; in the case someone dies within 5 seconds of their last death.
{
DestroyActor(death_actor[playerid]); // If for some reason the actor already exists, destroy/delete it before creating another one.
KillTimer(RemoveActorTimer[playerid]); // Kill the already running timer to avoid it deleting the actor that's about to be created fresh prior to the time we want.
}
death_actor[playerid] = CreateActor("%s", "%s", "%s", "%s", pSkin(playerid), Float:x, Float:y, Float:z); // Create the actor and assign the ID, not entirely sure why you're passing an actor's "modelid" as a string here but I'll assume you have a reason . . .
ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1); // Applying the animation, this was your code.
RemoveActorTimer[playerid] = SetTimerEx("RemovePlayerDeathActor", 5000, false, "i", playerid);
}
}
}
forward RemovePlayerDeathActor(playerid);
public RemovePlayerDeathActor(playerid)
{
if(IsValidActor(death_actor[playerid])) DestroyActor(death_actor[playerid]); // Removes the "death actor".
return 1;
}