OnPlayerSpawn not getting called. -
jihadmeneer - 05.04.2014
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(playerid, 6);
SetPlayerVirtualWorld(playerid, 1);
SetPlayerColor(playerid, 0xED9111FF);
SetPlayerPos(playerid, 264.2733, 77.4141, 1001.0391);
SetPlayerFacingAngle(playerid, 269.7870);
TogglePlayerControllable(playerid, 1);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
return 1;
}
else
{
switch(PlayerJustDied[playerid])
{
case 1:
{
PlayerJustDied[playerid] = 0;
AccountData[playerid][pHospitalized] = 1;
printf("1: Player %d is dieng | Just died? %d", playerid, 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]);
}
}
}
OnPlayerSpawn:
PHP код:
if (PlayerJustDied[playerid])
{
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);
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;
}
Debug puts out:
PHP код:
[11:07:42] 0: Player 0 is dieng | Just died? 1
[11:07:42] [death] Yason_Wrath died 255
[11:07:59] AdmCmd: Yason Wrath has revived Yason Wrath.
[11:08:07] 0: Player 0 is dieng | Just died? 1
Re: OnPlayerSpawn not getting called. -
Dokins - 05.04.2014
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!
Re: OnPlayerSpawn not getting called. -
jihadmeneer - 05.04.2014
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.
Re: OnPlayerSpawn not getting called. -
Dokins - 05.04.2014
Ahh I see....
Can you show me the entire OnPlayerDeath Please?
Re: OnPlayerSpawn not getting called. -
jihadmeneer - 05.04.2014
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
new playerState = GetPlayerState(killerid), vehicleid = GetPlayerVehicleID(playerid);
if (playerState == PLAYER_STATE_DRIVER)
{
new string[127];
if(IsAHelicopter(vehicleid))
{
RemovePlayerFromVehicle(killerid);
format(string, sizeof(string), "AdmCmd: %s was prisoned by %s, reason: Heli-Blading", PlayerRPName(killerid), PlayerRPName(playerid));
SendClientMessageToAll(TOMATO, string);
AccountData[killerid][pPrisoned] = 2;
AccountData[killerid][pPrisonTime] = 30 * 60;
SetPlayerPos(killerid, 264.6288, 77.5742, 1001.0391);
SetPlayerInterior(killerid, 6);
SetPlayerVirtualWorld(killerid, killerid+1337);
SetPlayerColor(killerid, 0xF4A41900);
ClearWeapons(killerid);
if (PlayerCuffed[killerid])
{
SetPlayerSpecialAction(killerid, SPECIAL_ACTION_NONE);
RemovePlayerAttachedObject(killerid, 1);
}
}
}
if(AccountData[playerid][pPrisoned] >= 1)
{
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 1);
SetPlayerColor(playerid, 0xED9111FF);
SetPlayerPos(playerid, 264.2733, 77.4141, 1001.0391);
SetPlayerFacingAngle(playerid, 269.7870);
TogglePlayerControllable(playerid, 1);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
return 1;
}
else
{
switch(PlayerJustDied[playerid])
{
case 1:
{
PlayerJustDied[playerid] = 0;
AccountData[playerid][pHospitalized] = 1;
printf("1: Player %d is dieng | Just died? %d", playerid, 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]);
}
}
}
if (IsBeingSpeced[playerid])
{
foreach(Player,i)
{
if(SpectatingID[i] == playerid)
{
TogglePlayerSpectating(i,false);
}
}
}
return 1;
}
Re: OnPlayerSpawn not getting called. -
Dokins - 05.04.2014
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.
Re: OnPlayerSpawn not getting called. -
jihadmeneer - 05.04.2014
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.
Re: OnPlayerSpawn not getting called. -
Dokins - 05.04.2014
I'm sorry, I'm stumped.
Re: OnPlayerSpawn not getting called. -
jihadmeneer - 05.04.2014
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.
Re: OnPlayerSpawn not getting called. -
Dokins - 05.04.2014
I know, that's what gets me. I can't figure it out.