SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/09/2018, 06:00 PM   #11
Zeus666
Gangsta
 
Join Date: Mar 2015
Posts: 613
Reputation: 46
Default Re: Onplayerdeath actors

Fixed with SKIN bug.

But there's the problem.

It appears only ONCE per player (why?) I want everytime if A PLAYER dies, that much time an actor to be spawned.


Ex. I die 5 times, i want an actor each time.
Zeus666 is online now   Reply With Quote
Old 24/09/2018, 06:07 PM   #12
UFF
Huge Clucker
 
UFF's Avatar
 
Join Date: Feb 2018
Location: Funky World
Posts: 312
Reputation: 28
Default Re: Onplayerdeath actors

Quote:
Originally Posted by Zeus666 View Post
Fixed with SKIN bug.

But there's the problem.

It appears only ONCE per player (why?) I want everytime if A PLAYER dies, that much time an actor to be spawned.


Ex. I die 5 times, i want an actor each time.
Provide the code of the fixed one.
__________________
(¯`ˇ._.ˇUltimate Funky Freeroam._.ˇ´¯)



UFF is offline   Reply With Quote
Old 24/09/2018, 06:19 PM   #13
Zeus666
Gangsta
 
Join Date: Mar 2015
Posts: 613
Reputation: 46
Default Re: Onplayerdeath actors

Quote:
Originally Posted by UFF View Post
Provide the code of the fixed one.

PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        if(!
IsPlayerNPC(playerid))
        {
            new 
name[24], kname[30], string[64];
            new 
gunname[32];
            
GetWeaponName(reasongunnamesizeof(gunname));
            
GetPlayerName(playeridname24);
            
GetPlayerName(killeridkname30);
             
format(stringsizeof(string), "%s has killed %s with%s."knamenamegunname);
            
SendMessageToAllAdmins(string, -1);
            
        }
        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.
            
}
            new 
Float:x,Float:y,Float:z,Float:angle;
            
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
            
death_actor[playerid] = CreateActor(pInfo[playerid][pSkin], xyzangle);
            
ApplyActorAnimation(death_actor[playerid], "WUZI","CS_Dead_Guy",4.1,1,1,1,1,5000); // Applying the animation, this was your code.
            
RemoveActorTimer[playerid] = SetTimerEx("RemovePlayerDeathActor"10000false"i"playerid);
        }
    } 


PHP Code:
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.
forward RemovePlayerDeathActor(playerid);

public 
RemovePlayerDeathActor(playerid)
{
    if(
IsValidActor(death_actor[playerid])) DestroyActor(death_actor[playerid]); // Removes the "death actor".
    
return 1;

Zeus666 is online now   Reply With Quote
Old 24/09/2018, 07:40 PM   #14
Undef1ned
Big Clucker
 
Undef1ned's Avatar
 
Join Date: Aug 2018
Location: Venezuela
Posts: 189
Reputation: 12
Default Re: Onplayerdeath actors

PHP Code:
new death_actor[MAX_PLAYERS];
new 
RemoveActorTimer[MAX_PLAYERS];

public 
OnPlayerConnect(playerid)
{
    
death_actor[playerid] = INVALID_ACTOR_ID;
    return 
1;
}

public 
OnPlayerDeath(playeridkilleridreason

    if(
killerid != INVALID_PLAYER_ID
    {
        if(!
IsPlayerNPC(playerid)) 
        { 
            new 
name[24], kname[30], string[64]; 
            new 
gunname[32]; 
            
GetWeaponName(reasongunnamesizeof(gunname)); 
            
GetPlayerName(playeridname24); 
            
GetPlayerName(killeridkname30); 
            
format(stringsizeof(string), "%s has killed %s with%s."knamenamegunname); 
            
SendMessageToAllAdmins(string, -1); 
        } 
        
        if(
death_actor[playerid] != INVALID_ACTOR_ID)
        {
            
DestroyActor(death_actor[playerid]);
            
death_actor[playerid] = INVALID_ACTOR_ID;
            
KillTimer(RemoveActorTimer[playerid]);
        }
        new 
Float:p[4]; GetPlayerPos(playeridp[0], p[1], p[2]); GetPlayerFacingAngle(playeridp[3]);
        
death_actor[playerid] = CreateActor(GetPlayerSkin(playerid), p[0], p[1], p[2], p[3]); 
        
ApplyActorAnimation(death_actor[playerid], "WUZI""CS_Dead_Guy"4.111115000); // Applying the animation, this was your code. 
        
RemoveActorTimer[playerid] = SetTimerEx("RemovePlayerDeathActor"5000false"i"playerid); 
    }
    return 
1;
}

forward RemovePlayerDeathActor(playerid); 
public 
RemovePlayerDeathActor(playerid

    if(
death_actor[playerid] != INVALID_ACTOR_ID)
    {
        
DestroyActor(death_actor[playerid]);
        
death_actor[playerid] = INVALID_ACTOR_ID;
    }
    return 
1

Undef1ned is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerDeath AnonScripter Scripting Help 11 19/01/2014 08:14 PM
OnPlayerDeath []Allex[] Scripting Help 1 26/01/2013 07:05 PM
OnPlayerDeath HELP brightas Scripting Help 1 03/11/2012 10:13 AM
OnPlayerDeath Blackazur Scripting Help 6 15/09/2012 08:46 AM
OnPlayerDeath Qaiis Scripting Help 1 08/09/2012 10:39 AM


All times are GMT. The time now is 05:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.