public OnPlayerDeath(playerid, killerid, reason)
{
stop InjuredTimer[playerid];
SetPVarInt(playerid, "JustDied", 1);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(GetPVarInt(playerid, "JustDied") == 1)
{
ClearChat(playerid);
OOCEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_LRED, "You have been transported to the hospital and can't remember what happened to you.");
SetPlayerCameraLookAt(playerid, -2327.4072, 1357.9125, 334.0528);
defer HospitalTimer(playerid);
SetPVarInt(playerid, "INHOSP", 1);
DeletePVar(playerid, "JustDied");
return 0;
}
return 0;
}
timer HospitalTimer[15000](playerid)
{
SetSpawnInfo(playerid, -1, pStats[playerid][EP_SKIN], fHospSpawnX, fHospSpawnY, fHospSpawnZ, fHospSpawnR, -1, -1, -1, -1, -1, -1);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have been discharged from the hospital.");
DeletePVar(playerid, "INHOSP");
}
Are you sure OnPlayerRequestClass is the most relevant callback to use? I'd use OnPlayerSpawn, so once they respawn, their camera positions are changed as necessary.
|
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "JustDied") == 1)
{
ClearChat(playerid);
OOCEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_LRED, "You have been transported to the hospital and can't remember what happened to you.");
SetPlayerCameraLookAt(playerid, -2327.4072, 1357.9125, 334.0528);
SetPlayerVirtualWorld(playerid, randomEx(30, 500));
defer HospitalTimer(playerid);
SetPVarInt(playerid, "INHOSP", 1);
DeletePVar(playerid, "JustDied");
}
TextDrawShowForPlayer(playerid, TimeTD);
TextDrawShowForPlayer(playerid, CompleteDate);
TextDrawShowForPlayer(playerid, ServerVersionTD);
PreloadAnimLib(playerid, "BOMBER");
PreloadAnimLib(playerid, "RAPPING");
PreloadAnimLib(playerid, "SHOP");
PreloadAnimLib(playerid, "BEACH");
PreloadAnimLib(playerid, "SMOKING");
PreloadAnimLib(playerid, "ON_LOOKERS");
PreloadAnimLib(playerid, "DEALER");
PreloadAnimLib(playerid, "CRACK");
PreloadAnimLib(playerid, "CARRY");
PreloadAnimLib(playerid, "COP_AMBIENT");
PreloadAnimLib(playerid, "PARK");
PreloadAnimLib(playerid, "INT_HOUSE");
PreloadAnimLib(playerid, "FOOD");
PreloadAnimLib(playerid, "GANGS");
PreloadAnimLib(playerid, "PED");
PreloadAnimLib(playerid, "FAT");
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(GetPVarInt(playerid, "JustDied") == 1)
{
ClearChat(playerid);
OOCEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_LRED, "You have been transported to the hospital and can't remember what happened to you.");
TogglePlayerSpectating(playerid, true);
SetPlayerCameraLookAt(playerid, -2327.4072, 1357.9125, 334.0528);
defer HospitalTimer(playerid);
SetPVarInt(playerid, "INHOSP", 1);
DeletePVar(playerid, "JustDied");
return 0;
}
return 0;
}
timer HospitalTimer[15000](playerid)
{
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, -1, pStats[playerid][EP_SKIN], fHospSpawnX, fHospSpawnY, fHospSpawnZ, fHospSpawnR, -1, -1, -1, -1, -1, -1);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have been discharged from the hospital.");
DeletePVar(playerid, "INHOSP");
}
public OnPlayerSpawn(playerid)
{
print("OPS called");
TextDrawShowForPlayer(playerid, TimeTD);
TextDrawShowForPlayer(playerid, CompleteDate);
TextDrawShowForPlayer(playerid, ServerVersionTD);
PreloadAnimLib(playerid, "BOMBER");
PreloadAnimLib(playerid, "RAPPING");
PreloadAnimLib(playerid, "SHOP");
PreloadAnimLib(playerid, "BEACH");
PreloadAnimLib(playerid, "SMOKING");
PreloadAnimLib(playerid, "ON_LOOKERS");
PreloadAnimLib(playerid, "DEALER");
PreloadAnimLib(playerid, "CRACK");
PreloadAnimLib(playerid, "CARRY");
PreloadAnimLib(playerid, "COP_AMBIENT");
PreloadAnimLib(playerid, "PARK");
PreloadAnimLib(playerid, "INT_HOUSE");
PreloadAnimLib(playerid, "FOOD");
PreloadAnimLib(playerid, "GANGS");
PreloadAnimLib(playerid, "PED");
PreloadAnimLib(playerid, "FAT");
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid, TimeTD);
TextDrawHideForPlayer(playerid, CompleteDate);
TextDrawHideForPlayer(playerid, ServerVersionTD);
stop InjuredTimer[playerid];
SetPVarInt(playerid, "JustDied", 1);
return 1;
}
timer HospitalTimer[15000](playerid)
{
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, -1, pStats[playerid][EP_SKIN], fHospSpawnX, fHospSpawnY, fHospSpawnZ, fHospSpawnR, -1, -1, -1, -1, -1, -1);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have been discharged from the hospital.");
DeletePVar(playerid, "INHOSP");
}
Do you call ForceClassSelection anywhere? There's no reference to it in your code and without it "OnPlayerRequestClass" will never be called after death.
|
I'm not sure if it's a bug or not, it's just strange and I've been wrestling with that strange sequence as well recently. TogglePlayerSpectating does disable the class selection, but I'm not sure of the entire effect.
|