09.03.2014, 19:40
Hi, I just spent about an hour searching through these forums to find an noob friendly answer to my question, however was unable to find.
I have created a jail command, however when a player disconnects, the timer doesn't save and it restarts/and or just screws up and keeps him in pJail = 1 forever.
I was wondering if it's possible to save the amount of time remaining in the jail timer in the players YINI file, and on connect, read the amount of minutes in his file and start the timer from there.
I'm sorry if this is really easy to do, but I am a bit of a noob to scripting.
My jail scripts:
I have created a jail command, however when a player disconnects, the timer doesn't save and it restarts/and or just screws up and keeps him in pJail = 1 forever.
I was wondering if it's possible to save the amount of time remaining in the jail timer in the players YINI file, and on connect, read the amount of minutes in his file and start the timer from there.
I'm sorry if this is really easy to do, but I am a bit of a noob to scripting.
My jail scripts:
Код:
new JailTimer[MAX_PLAYERS];
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 4) return 1;
new targetid, minutes, reason[64], str[128];
if(sscanf(params, "riS[64]", targetid, minutes, reason)) return SendClientMessage(playerid, -1, "USAGE: /jail [id] [minutes] [reason]");
else
{
format(str, sizeof(str), "AdmCmd: Administrator %s has jailed %s for %d minutes. Reason: %s", Name(playerid), Name(targetid), minutes, reason);
JailTimer[targetid] = SetTimer("Unjail", minutes*1000*60, false);
SetPlayerInterior(targetid, 6);
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
PlayerInfo[targetid][pJailed] = 1;
SendClientMessageToAll(0xFF0000FF, str);
SetPlayerHealth(targetid, 9999);
GameTextForPlayer(targetid, "Welcome to AJAIL!", 5000, 6);
}
return 1;
}
forward Unjail(playerid);
public Unjail(playerid)
{
SendClientMessage(playerid, -1, "Released nigga.");
SetPlayerPos(playerid,1538.7344,-1675.2236,13.5469);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pJailed] = 0;
KillTimer(JailTimer[playerid]);
return 1;
}

