OnPlayerDeath help!
#1

PHP код:
new Injured[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
Injured[playerid] = 0;
return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    if(
Injured[playerid] == 1)
    {
        
ClearAnimations(playerid);
        
ApplyAnimation(playerid"KNIFE""KILL_Knife_Ped_Die"4.0011101);
        
TogglePlayerControllable(playerid0);
    }
    if(
Injured[playerid] == 2)
    {
        
TogglePlayerControllable(playeridtrue);
        
SetPlayerCameraPos(playerid,2000.942,-1453.973,39.952);
        
SetPlayerCameraLookAt(playerid,2032.520,-1416.205,16.992);
        
SetTimerEx("NamVien"80000"i",playerid);
    }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
Injured[playerid] == 1)
    {
        
Injured[playerid] = 2;
        
SetSpawnInfo(playerid0PInfo[playerid][Skin], 2032.5200,-1416.2058,120,0,0,0,0,0,0);
        
SpawnPlayer(playerid);
        return 
1;
    }
    
GetPlayerPos(playeridBTPos[playerid][0], BTPos[playerid][1], BTPos[playerid][2]);
    
GetPlayerFacingAngle(playeridBTPos[playerid][3]);
    
SetSpawnInfo(playerid0PInfo[playerid][Skin], BTPos[playerid][0],BTPos[playerid][1],BTPos[playerid][2]-0.1BTPos[playerid][3],0,0,0,0,0,0);
    
SpawnPlayer(playerid);
    
Injured[playerid] = 1;
    return 
1;

I want to make injured system, but the condition in OnPlayerDeath likely not performed . Someone help me
Reply
#2

Код:
    if(Injured[playerid] == 1) 
    { 
        Injured[playerid] = 2; 
        SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], 2032.5200,-1416.2058,12, 0,0,0,0,0,0,0); 
        SpawnPlayer(playerid); 
        return 1; 
    }
    else
    { 
    GetPlayerPos(playerid, BTPos[playerid][0], BTPos[playerid][1], BTPos[playerid][2]); 
    GetPlayerFacingAngle(playerid, BTPos[playerid][3]); 
    SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], BTPos[playerid][0],BTPos[playerid][1],BTPos[playerid][2]-0.1, BTPos[playerid][3],0,0,0,0,0,0); 
    SpawnPlayer(playerid); 
    Injured[playerid] = 1;
    }
I think this will do what you wanted. The problem in the code you posted is if your if statement return true, the code inside WILL be executed, but after that it will be overwritten by the code under it, I assume you wanted them for two different cases. Try the code above and tell me if it works the way you want it to.
Reply
#3

still not work
Reply
#4

*pump*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)