OnPlayerSpawn not getting called.
#1

Dear SA-MP community,

I have been working on my own GM but I have some troubles with the death system.

The first time you die it sends you to class selection, after you press the spawn button, you will spawn at your death position and you will do the anim.

The second time you are spawning immediatly.

Video:

https://www.youtube.com/watch?v=rh73VMIBqkA
OnPlayerDeath:

PHP код:
if(AccountData[playerid][pPrisoned] >= 1)
    {
        
SetPlayerInterior(playerid6);
        
SetPlayerVirtualWorld(playerid1);
        
SetPlayerColor(playerid0xED9111FF);
        
SetPlayerPos(playerid264.273377.41411001.0391);
        
SetPlayerFacingAngle(playerid269.7870);
        
TogglePlayerControllable(playerid1);
        
SetPlayerHealth(playerid100);
        
SetPlayerArmour(playerid100);
        return 
1;
    }
    else
    {
        switch(
PlayerJustDied[playerid])
        {
            case 
1:
            {
                
PlayerJustDied[playerid] = 0;
                
AccountData[playerid][pHospitalized] = 1;
                
printf("1: Player %d is dieng | Just died? %d"playeridPlayerJustDied[playerid]);
            }
            case 
0:
               {
                   
GetPlayerPos(playeridDeathStuff[playerid][DeathX], DeathStuff[playerid][DeathY], DeathStuff[playerid][DeathZ]);
                
GetPlayerFacingAngle(playeridDeathStuff[playerid][DeathA]);
                
DeathStuff[playerid][DeathInt] = GetPlayerInterior(playerid);
                
DeathStuff[playerid][DeathHP] = 100;
                for(new 
0i<13;i++)
                {
                    
GetPlayerWeaponData(playeridiDeathWeapons[playerid][i][0], DeathWeapons[playerid][i][1]);
                }
                
PlayerJustDied[playerid] = 1;
                
AccountData[playerid][pHospitalized] = 0;
                
printf("0: Player %d is dieng | Just died? %d"playeridPlayerJustDied[playerid]);
            }
        }
    } 
OnPlayerSpawn:


PHP код:
if (PlayerJustDied[playerid])
        {
            
SetPlayerPos(playeridDeathStuff[playerid][DeathX], DeathStuff[playerid][DeathY], DeathStuff[playerid][DeathZ]);
            
SetPlayerInterior(playeridDeathStuff[playerid][DeathInt]);
            
SetPlayerFacingAngle(playeridDeathStuff[playerid][DeathA]);
            
SetPlayerSkin(playeridAccountData[playerid][pSkin]);
            
DeathStuff[playerid][DeathHP] = 100;
            
displayCenterHUDInfo(playerid"~r~Injured~n~~w~/accept death or /service ems"8);
            
SetPlayerArmour(playerid0.0);
            
SetPlayerHealth(playerid100.0);
            
ClearAnimations(playerid);
            
ApplyAnimation(playerid"KNIFE""KILL_Knife_Ped_Die",4.0,0,1,1,1,0,1);
            for(new 
0;i<13;i++)
               {
                  
GivePlayerValidWeapon(playeridDeathWeapons[playerid][i][0], DeathWeapons[playerid][i][1]);
               }
            
SetTimerEx("DeathTimer"1000false"i"playerid);
            return 
1;
        } 
Debug puts out:

PHP код:
[11:07:420Player 0 is dieng Just died1
[11:07:42] [deathYason_Wrath died 255
[11:07:59AdmCmdYason Wrath has revived Yason Wrath.
[
11:08:070Player 0 is dieng Just died
Reply
#2

pawn Код:
if (PlayerJustDied[playerid] == 1)
        {
            SetPlayerPos(playerid, DeathStuff[playerid][DeathX], DeathStuff[playerid][DeathY], DeathStuff[playerid][DeathZ]);
            SetPlayerInterior(playerid, DeathStuff[playerid][DeathInt]);
            SetPlayerFacingAngle(playerid, DeathStuff[playerid][DeathA]);
            SetPlayerSkin(playerid, AccountData[playerid][pSkin]);
            DeathStuff[playerid][DeathHP] = 100;
            displayCenterHUDInfo(playerid, "~r~Injured~n~~w~/accept death or /service ems", 8);
            SetPlayerArmour(playerid, 0.0);
            SetPlayerHealth(playerid, 100.0);
            ClearAnimations(playerid);
            PlayerJustDied[playerid] = 0;
            ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die",4.0,0,1,1,1,0,1);
            for(new i = 0;i<13;i++)
               {
                  GivePlayerValidWeapon(playerid, DeathWeapons[playerid][i][0], DeathWeapons[playerid][i][1]);
               }
            SetTimerEx("DeathTimer", 1000, false, "i", playerid);
            return 1;
        }
Try that, Let me know what happens, or furthermore video it!
Reply
#3

Not working, the server isn't even counting him as injured anymore due to reset of that variable, and why do I get a beer bottle in my hand?

I use that variable for commands such as /revive:

PHP код:
if (PlayerJustDied[toplayerid])
                    { 
ect.
Reply
#4

Ahh I see....

Can you show me the entire OnPlayerDeath Please?
Reply
#5

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
playerState GetPlayerState(killerid), vehicleid GetPlayerVehicleID(playerid);
    if (
playerState == PLAYER_STATE_DRIVER)
    {
        new 
string[127];
        if(
IsAHelicopter(vehicleid))
        {
            
RemovePlayerFromVehicle(killerid);
            
format(stringsizeof(string), "AdmCmd: %s was prisoned by %s, reason: Heli-Blading"PlayerRPName(killerid), PlayerRPName(playerid));
             
SendClientMessageToAll(TOMATOstring);
             
            
AccountData[killerid][pPrisoned] = 2;
            
AccountData[killerid][pPrisonTime] = 30 60;
              
SetPlayerPos(killerid264.628877.57421001.0391);
            
SetPlayerInterior(killerid6);
            
SetPlayerVirtualWorld(killeridkillerid+1337);
            
SetPlayerColor(killerid0xF4A41900);
            
ClearWeapons(killerid);
            if (
PlayerCuffed[killerid])
            {
                
SetPlayerSpecialAction(killeridSPECIAL_ACTION_NONE);
                
RemovePlayerAttachedObject(killerid1);
            }
        }
    }
    if(
AccountData[playerid][pPrisoned] >= 1)
    {
        
SetPlayerInterior(playerid6);
        
SetPlayerVirtualWorld(playerid1);
        
SetPlayerColor(playerid0xED9111FF);
        
SetPlayerPos(playerid264.273377.41411001.0391);
        
SetPlayerFacingAngle(playerid269.7870);
        
TogglePlayerControllable(playerid1);
        
SetPlayerHealth(playerid100);
        
SetPlayerArmour(playerid100);
        return 
1;
    }
    else
    {
        switch(
PlayerJustDied[playerid])
        {
            case 
1:
            {
                
PlayerJustDied[playerid] = 0;
                
AccountData[playerid][pHospitalized] = 1;
                
printf("1: Player %d is dieng | Just died? %d"playeridPlayerJustDied[playerid]);
            }
            case 
0:
               {
                   
GetPlayerPos(playeridDeathStuff[playerid][DeathX], DeathStuff[playerid][DeathY], DeathStuff[playerid][DeathZ]);
                
GetPlayerFacingAngle(playeridDeathStuff[playerid][DeathA]);
                
DeathStuff[playerid][DeathInt] = GetPlayerInterior(playerid);
                
DeathStuff[playerid][DeathHP] = 100;
                for(new 
0i<13;i++)
                {
                    
GetPlayerWeaponData(playeridiDeathWeapons[playerid][i][0], DeathWeapons[playerid][i][1]);
                }
                
PlayerJustDied[playerid] = 1;
                
AccountData[playerid][pHospitalized] = 0;
                
printf("0: Player %d is dieng | Just died? %d"playeridPlayerJustDied[playerid]);
            }
        }
    }
    if (
IsBeingSpeced[playerid])
    {
        foreach(
Player,i)
        {
            if(
SpectatingID[i] == playerid)
            {
                
TogglePlayerSpectating(i,false);
            }
        }
    }
    return 
1;

Reply
#6

Okay, I think I've got it.

You're calling case 1 before 0. It may be messing it up or, I'm not entirely sure.

pawn Код:
switch(PlayerJustDied[playerid])
        {
            case 0:
               {
                    GetPlayerPos(playerid, DeathStuff[playerid][DeathX], DeathStuff[playerid][DeathY], DeathStuff[playerid][DeathZ]);
                    GetPlayerFacingAngle(playerid, DeathStuff[playerid][DeathA]);
                    DeathStuff[playerid][DeathInt] = GetPlayerInterior(playerid);
                    DeathStuff[playerid][DeathHP] = 100;
                    for(new i = 0; i<13;i++)
                    {
                        GetPlayerWeaponData(playerid, i, DeathWeapons[playerid][i][0], DeathWeapons[playerid][i][1]);
                    }
                    PlayerJustDied[playerid] = 1;
                    AccountData[playerid][pHospitalized] = 0;
                    printf("0: Player %d is dieng | Just died? %d", playerid, PlayerJustDied[playerid]);
               }
            case 1:
            {
                PlayerJustDied[playerid] = 0;
                AccountData[playerid][pHospitalized] = 1;
                printf("1: Player %d is dieng | Just died? %d", playerid, PlayerJustDied[playerid]);
            }

        }
    }
  }
Try this.
Reply
#7

Nope, it isn't the problem.

I changed it and still not working, but somehow I always get a beer or a sigaret in my hand when I am send to RequestClass.
Reply
#8

I'm sorry, I'm stumped.
Reply
#9

Same here.

It's so odd it works perfectly the second time you die, but it's fucked up the first time?

I think there is something wrong with a variable.
Reply
#10

I know, that's what gets me. I can't figure it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)