22.09.2013, 16:25
I need help to show a message to the player about how long time they have left in jail..
jailPlayer(playerid, jailtime) {
if (jailtime <=0) //Can't jail them for <= 0 seconds
return 0;
if (GetPVarInt(playerid, "plJailTime") > 0) //Already in jail
return 0;
KillTimer(GetPVarInt(playerid, "plJailTimer")); //Kill the timer, just in case its still going
// Code to move them to jail here!
SetPVarInt(playerid, "plJailTime", jailtime);
SetPVarInt(playerid, "plJailTimer", SetTimerEx("jailPlayerTimer", 1000, false, "i", playerid));
}
unjailPlayer(playerid) {
SetPVarInt(playerid, "plJailTime", 0);
KillTimer(GetPVarInt(playerid, "plJailTimer"));
// Code to move them out of jail here!
}
forward jailPlayerTimer(playerid);
public jailPlayerTimer(playerid) {
new jailTime = GetPVarInt(playerid, "plJailTime");
if (jailTime > 0) {
new msg[64];
format(msg, 64, "You are in jail for %i seconds", jailTime);
GameTextForPlayer(playerid, msg, 1200, 4);
SetPVarInt(playerid, "plJailTime", jailTime-1);
KillTimer(GetPVarInt(playerid, "plJailTimer"));
SetPVarInt(playerid, "plJailTimer", SetTimerEx("jailPlayerTimer", 1000, false, "i", playerid));
} else {
unjailPlayer(playerid);
}
}
public OnPlayerDisconnect(playerid, reason) {
KillTimer(GetPVarInt(playerid, "plJailTimer")); //Kill the timer, just incase its still going
return 1;
}