07.05.2014, 20:52
I'm camping with this problem for a couple of days now.
I have no clue how to save a timer to the database, which is in the case y_ini.
If a player is jailed by an admin and he logs off, I want the time he has left to stay in Jail saved but I don't know how.
Like when the player logs on again the time just continues counting down.
This is what I have:
Enum pInfo
/jail and /unjail command
Additional publics:
Help is much appreciated!
Sincerely,
Bible
I have no clue how to save a timer to the database, which is in the case y_ini.
If a player is jailed by an admin and he logs off, I want the time he has left to stay in Jail saved but I don't know how.
Like when the player logs on again the time just continues counting down.
This is what I have:
Enum pInfo
pawn Код:
enum pInfo
{
pJailed,
pJailTime,
}
[/PAWNO]
OnPlayerSpawn
[PAWNO]
public OnPlayerSpawn(playerid)
{
if(PlayerInfo[playerid][pJailed] == 1)
{
SetPlayerPos(playerid, 197.6661, 173.8179, 1003.0234);
SetPlayerInterior(playerid, 3);
SetCameraBehindPlayer(playerid);
SendClientMessage(playerid, COLOR_GREY, "[JAIL] You have not served your time yet!");
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
ResetPlayerWeapons(playerid);
GameTextForPlayer(playerid, "~r~Back To Jail", 2500, 0);
return 1;
}
else
{
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SetPlayerPos(playerid, 1685.8979/*X*/, -2330.5691/*Y*/, -2.6797/*Z*/);
SetPlayerFacingAngle(playerid, 360.0);
return 1;
}
}
pawn Код:
CMD:jail(playerid, params[])
{
new tID, time, reason[128], jstring[128];
if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
if(PlayerInfo[playerid][pAdmin] < 2) return SCM(playerid, COLOR_GREY, NOTADMIN);
if(sscanf(params, "udS(No Reason)[128]", tID, time, reason)) return SCM(playerid, -1, "[USAGE] /jail [playerid/PartOfName] [Minutes] [Reason]");
else if(tID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, INVALIDID);
else if(PlayerInfo[tID][pAdmin] > PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "[AdmCMD] You can't jail admins who are a higher level than you!");
else if(PlayerInfo[tID][pJailed] == 1) return SCM(playerid, COLOR_GREY, "[NOTE] The player you have specified is already in jail!");
else
{
format(jstring, sizeof(jstring), "[AdmCMD] %s has been jailed by Administrator %s for %d minute(s), [Reason: %s]", GetName(tID), GetName(playerid), time, reason);
SCMTA(COLOR_LIGHTRED, jstring);
SetTimerEx("JailP1", 1000, false, "i", tID);
SetTimerEx("Jailer", 5000, false, "i", tID);
}
return 1;
}
CMD:unjail(playerid, params[])
{
new tID, jstring[128];
if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
if(PlayerInfo[playerid][pAdmin] < 2) return SCM(playerid, COLOR_GREY, NOTADMIN);
if(sscanf(params, "u", tID)) return SCM(playerid, -1, "[USAGE] /unjail [playerid/PartOfName]");
else if(tID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, INVALIDID);
else if(PlayerInfo[tID][pAdmin] > PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "[AdmCMD] You can't unjail admins who are a higher level than you!");
else if(PlayerInfo[tID][pJailed] == 0) return SCM(playerid, COLOR_GREY, "[NOTE] The player you have specified is not in jail!");
else
{
format(jstring, sizeof(jstring), "[AdmCMD] %s has been unjailed by Administrator %s", GetName(tID), GetName(playerid));
SCMTA(COLOR_LIGHTRED, jstring);
SetTimerEx("Unjail", 1000, false, "i", tID);
}
return 1;
}
pawn Код:
public Jailer(playerid)
{
TogglePlayerControllable(playerid, 1);
SetPlayerPos(playerid, 197.6661, 173.8179, 1003.0234);
SetPlayerInterior(playerid, 3);
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pJailTime] = SetTimerEx("Unjail", PlayerInfo[playerid][pJailTime], 0, "d", playerid);
PlayerInfo[playerid][pJailed] = 1;
SaveAccountInfo(playerid);
}
public Unjail(playerid)
{
if(--PlayerInfo[playerid][pJailTime] < 1)
{
PlayerInfo[playerid][pJailTime] = 0;
PlayerInfo[playerid][pJailed] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1685.8979/*X*/, -2330.5691/*Y*/, -2.6797/*Z*/);
SetPlayerFacingAngle(playerid, 360.0);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~g~Released!", 3000, 0);
}
return 1;
}
Help is much appreciated!
Sincerely,
Bible