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);
Deathactor = CreateActor("%s", "%s", "%s", "%s"), pSkin(playerid), Float:x, Float:y, Float:z);
ApplyActorAnimation(Deathactor, "WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1);
}
}
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;
}
(5907) : error 035: argument type mismatch (argument 1)
(5907) : warning 215: expression has no effect
(5907) : error 001: expected token: ";", but found ")"
(5907) : error 029: invalid expression, assumed zero
(5907) : fatal error 107: too many error messages on one line
death_actor[playerid] = CreateActor("%s", "%s", "%s", "%s"), pSkin(playerid), Float:x, Float:y, Float:z);
CreateActor(pSkin(playerid), x, y, z, 0.0 /* rotation */);
This code will not work because the first three parameters are incorrectly passed.
CreateActor function pawn Код:
|
: error 012: invalid function call, not a valid address
: warning 215: expression has no effect
: error 001: expected token: ";", but found ")"
: error 029: invalid expression, assumed zero
: fatal error 107: too many error messages on one line
error 017: undefined symbol "x"
arning 202: number of arguments does not match definition
ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1); // Applying the animation, this was your code.
i modified it with
death_actor[playerid] = CreateActor(pInfo[playerid][pSkin], x, y, z, 0.0); and it works, but PHP код:
PHP код:
PHP код:
|
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,0,1); // Applying the animation, this was your code.
Just tested it in game.
Knowns bugs 1) When player is killed, his character rotates in 380 grades. (If he is facing forward, his actor faces backsward) 2) when I kill the same player after 5-10 seconds, there will not spawn another actor. (there's 1 character per death) 3) It won't recognise the skin. It spawned the character with skin id 299 |
forward RemovePlayerDeathActor(playerid); public RemovePlayerDeathActor(playerid) { if(IsValidActor(death_actor[playerid])) DestroyActor(death_actor[playerid]); // Removes the "death actor". KillTimer(RemoveActorTimer[playerid]); return 1; }
new pskin = GetPlayerSkin(playerid);
Just tested it in game.
Knowns bugs 1) When player is killed, his character rotates in 380 grades. (If he is facing forward, his actor faces backsward) 2) when I kill the same player after 5-10 seconds, there will not spawn another actor. (there's 1 character per death) 3) It won't recognise the skin. It spawned the character with skin id 299 |
new Float:angle;
GetPlayerFacingAngle(playerid, angle);
CreateActor(/* ...arguments... */, angle);