Onplayerdeath actors
#1

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    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(reasongunnamesizeof(gunname));
            
GetPlayerName(playeridname24);
            
GetPlayerName(killeridkname30);
             
format(stringsizeof(string), "%s has wasted %s using a %s."killernameplayernamegunname);
            
SendMessageToAllAdmins(string, -1);
            
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
            
Deathactor CreateActor("%s""%s""%s""%s"), pSkin(playerid), Float:xFloat:yFloat:z);
            
ApplyActorAnimation(Deathactor"WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1);
        }

Could this work? When player dies, actor spawns with his initial coords and via anim


if yes, how can i remove the actor after 5 seconds ?(5000 ms)
Reply
#2

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(playeridkilleridreason)
{
    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(reasongunnamesizeof(gunname));
            
GetPlayerName(playeridname24);
            
GetPlayerName(killeridkname30);
            
format(stringsizeof(string), "%s has wasted %s using a %s."killernameplayernamegunname);
            
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:xFloat:yFloat: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"5000false"i"playerid);
        }
    }
}  
forward RemovePlayerDeathActor(playerid);
public 
RemovePlayerDeathActor(playerid)
{
    if(
IsValidActor(death_actor[playerid])) DestroyActor(death_actor[playerid]); // Removes the "death actor".
    
return 1;

Reply
#3

This gives me a lot of errors that pawn won't show them. It shows blank at compiling.
Fixed it, shown errors


PHP код:
(5907) : error 035argument type mismatch (argument 1)
(
5907) : warning 215expression has no effect
(5907) : error 001expected token";"but found ")"
(5907) : error 029invalid expressionassumed zero
(5907) : fatal error 107too many error messages on one line 
PHP код:
            death_actor[playerid] = CreateActor("%s""%s""%s""%s"), pSkin(playerid), Float:xFloat:yFloat:z); 
Reply
#4

This code will not work because the first three parameters are incorrectly passed.
CreateActor function
pawn Код:
CreateActor(pSkin(playerid), x, y, z, 0.0 /* rotation */);
Reply
#5

Quote:
Originally Posted by VVWVV
Посмотреть сообщение
This code will not work because the first three parameters are incorrectly passed.
CreateActor function
pawn Код:
CreateActor(pSkin(playerid), x, y, z, 0.0 /* rotation */);
PHP код:
 error 012invalid function callnot a valid address
 
warning 215expression has no effect
 
error 001expected token";"but found ")"
 
error 029invalid expressionassumed zero
 
fatal error 107too many error messages on one line 
//

i modified it with

death_actor[playerid] = CreateActor(pInfo[playerid][pSkin], x, y, z, 0.0);

and it works,

but

PHP код:
error 017undefined symbol "x" 
PHP код:
arning 202number of arguments does not match definition 
PHP код:
           ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1); // Applying the animation, this was your code. 
I'm trying to fix them
Reply
#6

Is there the 'pSkin' function in the code?

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
i modified it with

death_actor[playerid] = CreateActor(pInfo[playerid][pSkin], x, y, z, 0.0);

and it works,

but

PHP код:
error 017undefined symbol "x" 
PHP код:
arning 202number of arguments does not match definition 
PHP код:
           ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,1,0,1); // Applying the animation, this was your code. 
I'm trying to fix them
Use GetPlayerPos to get player's position.

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PHP код:
           ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,0,1); // Applying the animation, this was your code. 
Reply
#7

Fixed them. Thanks!
Reply
#8

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
Reply
#9

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
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
1) Use GetPlayerFacingAngle

2)
Код:
forward RemovePlayerDeathActor(playerid);
public RemovePlayerDeathActor(playerid)
{
    if(IsValidActor(death_actor[playerid])) DestroyActor(death_actor[playerid]); // Removes the "death actor".
    KillTimer(RemoveActorTimer[playerid]); 
    return 1;
}
3) Use GetPlayerSkin(playerid); instead of pSkin[playerid];
Example:
Код:
new pskin =  GetPlayerSkin(playerid);
Reply
#10

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
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
1) Use GetPlayerFacingAngle to get the player's rotation. This rotation must be passed when CreateActor function is called.
Example:
pawn Код:
new Float:angle;
GetPlayerFacingAngle(playerid, angle);
CreateActor(/* ...arguments... */, angle);
2) Yes. There is just one actor per player. In order to spawn a lot of actors per player, this system must be radically altered.
3) This problem is due to the 'pSkin' function (we don't know its definition)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)