Hospital System - Not working. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hospital System - Not working. (
/showthread.php?tid=299605)
Hospital System - Not working. -
Dokins - 26.11.2011
Release:
Basically, it just doesnt work when someone dies. Nothing does anything.
pawn Код:
public OneSecondTimer()
{
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(LoggedIn[p] == 1 && IsPlayerConnected(p))
{
if(Hospitalized[p] >= 1)
{
HospitalTime[p]++;
if(HospitalTime[p] >= 11)
{
new randtmp = RandomEx(1, 11);
if(randtmp >= 6)
{
Hospitalized[p] = 0;
HospitalTime[p] = 0;
SetPlayerPos(p, -227.3866, 1039.8873, 19.7422);
SetCameraBehindPlayer(p);
PlayerMoney[p] -= 500;
SetPlayerColor(p, COLOUR_WHITE);
SetPlayerHealth(p, 100);
SetPlayerDrunkLevel(p, 0);
TogglePlayerControllable(p, true);
SendClientMessage(p, COLOUR_BLUE, "You have been released from Hospital.");
SendClientMessage(p, COLOUR_WHITE, "Your medical expenses came to $500");
SetPlayerVirtualWorld(p, 0);
SetPlayerInterior(p, 0);
}
}
}
}
}
return 1;
}
They don't work in case your wondering.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
Hospitalized[playerid] = 1;
pawn Код:
stock dohospital(playerid)
{
if(Hospitalized[playerid] == 1)
{
if(AdminDuty[playerid] == 1)
{
Hospitalized[playerid] = 0;
SetPlayerPos(playerid, -227.3866, 1039.8873, 19.7422);
SendClientMessage(playerid, COLOUR_WHITE, "You are currently administrating, you were removed from hospital.");
}
else
{
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerDrunkLevel(playerid, 50000);
HospitalTime[playerid] = 1;
SetPlayerColor(playerid, COLOUR_GREY);
SetPlayerVirtualWorld(playerid, playerid+59);
TogglePlayerControllable(playerid, false);
SetPlayerPos(playerid, -227.3866, 1039.8873 -5, 19.7422);
SetPlayerCameraPos(playerid, -833.5241, -1358.8575, 86.9054);
SetPlayerCameraLookAt(playerid, -830.8118, -1360.3612, 87.0289);
SendClientMessage(playerid, COLOUR_WHITE, "You are recovering in hospital.");
SendClientMessage(playerid, COLOUR_WHITE, "You will be released shortly. ((Revenge killing is against the server rules)).");
}
}
return 1;
}
When they die.
Re: Hospital System - Not working. -
SlashQ - 26.11.2011
Try this:
pawn Код:
stock dohospital(playerid)
{
if(Hospitalized[playerid] == 1)
{
if(AdminDuty[playerid] == 1)
{
Hospitalized[playerid] = 0;
SetPlayerPos(playerid, -227.3866, 1039.8873, 19.7422);
SendClientMessage(playerid, COLOUR_WHITE, "You are currently administrating, you were removed from hospital.");
}
else
{
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerDrunkLevel(playerid, 50000);
HospitalTime[playerid] = 1;
SetPlayerColor(playerid, COLOUR_GREY);
SetPlayerVirtualWorld(playerid, playerid+59);
TogglePlayerControllable(playerid, false);
SetPlayerPos(playerid, -227.3866, 1039.8873 -5, 19.7422);
SetPlayerCameraPos(playerid, -833.5241, -1358.8575, 86.9054);
SetPlayerCameraLookAt(playerid, -830.8118, -1360.3612, 87.0289);
SendClientMessage(playerid, COLOUR_WHITE, "You are recovering in hospital.");
SendClientMessage(playerid, COLOUR_WHITE, "You will be released shortly. ((Revenge killing is against the server rules)).");
SetTimer("OneSecondTimer", 1000, false); // I've added this. You never called it!
}
}
return 1;
}
And OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
if(Hospitalized[playerid])
{
dohospital(playerid);
}
return 1;
}
Make sure you add
pawn Код:
Hospitalized[playerid] = 1;
Under OnPlayerDeath.