30.11.2011, 19:44
This is my hospital system, when the player dies, it calls dohospital, however, it sets them at blueberry farm and the timer doesnt work although the value of HospitalTime[p] is saved in MySQL and it doesnt reduce the time:
Dohospital
OnPlayerDeath
Timer.
Dohospital
pawn Код:
stock dohospital(playerid)
{
if(Hospitalized[playerid] == 1)
{
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerColor(playerid, COLOUR_GREY);
TogglePlayerControllable(playerid, false);
SetPlayerPos(playerid, -319.1807, 1044.5845-5 , 27.0152);
SetPlayerCameraPos(playerid, -315.1983, 1064.2436, 19.5937);
SetPlayerCameraLookAt(playerid, -320.1983, 1067.2436, 19.5937);
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;
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
Hospitalized[playerid] = 1;
MySQL_SetInteger(PlayerSQLID[playerid], "HospitalTime", 30, "Accounts");
HospitalTime[playerid] = 30;
dohospital(playerid);
new string[32];
format(string, sizeof(string),"%s(ID: %d), %s(ID: %d), %s", GetNameEx(playerid),playerid, GetNameEx(killerid),playerid, reason);
if(AdminLevel[playerid] >= 1)
{
SendClientMessage(playerid, COLOUR_RED, string);
}
return 1;
}
pawn Код:
public OneSecondTimer()
{
new string[32];
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(LoggedIn[p] == 1 && IsPlayerConnected(p))
{
if(HospitalTime[p] > 0)
{
HospitalTime[p]--;
format(string, sizeof(string), "You have %d seconds(s) left in hospital.", HospitalTime[p]);
SendClientMessage(p, COLOUR_GREY, string);
if(HospitalTime[p] == 0)
{
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);
MySQL_SetInteger(PlayerSQLID[p], "HospitalTime", 0, "Accounts");
}
}
}
}
return 1;
}