Ajail quit on the server
#1

I've a problem. When a user quits on the server with ajail, and comes back, his timer is no longer avaible, but he is still in ajail and the timer is not visible.


Код:
public OnPlayerDisconnect(playerid, reason)
{
	if(!IsPlayerNPC(playerid))
	{
	    if(pInfo[playerid][pLogged] == 1) { SaveStats(playerid); }
        DestroyDynamic3DTextLabel(PlayerLabel[playerid]);
 		PlayersAlive--;

  		ResetVars(playerid);
	    DisconnectVars(playerid);
        DeletePlayerTD(playerid);

  		new log[128];
	    format(log,sizeof(log),"~w~%s~b~ has disconnected",PlayerName(playerid));
	    UpdateAnnouncement(log);

		new str[256];
	  	switch(reason)
	    {
	        case 0: format(str,sizeof(str),"*"COL_GREEN" Player %s(%i) has left the server Reason: Timed Out",PlayerName(playerid),playerid);
	        case 1: format(str,sizeof(str),"*"COL_GREEN" Player %s(%i) has left the server Reason: Leaving",PlayerName(playerid),playerid);
	        case 2: format(str,sizeof(str),"*"COL_GREEN" Player %s(%i) has left the server Reason: Kicked/Banned",PlayerName(playerid),playerid);
	    }
		SendMessageToAllAdmins(str,-1);

     	if(IsBeingSpeced[playerid] == 1)
	    {
	        foreach(Player,i)
	        {
	            if(spectatorid[i] == playerid)
	            {
	                TogglePlayerSpectating(i,false);
	                giveWeaponAllow[i] = 1;
	            }
	        }
	    }
    }

	return 1;
}








public AjailCount(playerid)
{
	if(--pInfo[playerid][pJailed] < 1)
	{
		KillTimer(playertimer[playerid]);
		SendClientMessage(playerid, COLOR_RED, "Your time in Ajail is over..");
		SetPlayerInterior(playerid, 0);//You can change interior
		SetPlayerVirtualWorld(playerid, 0); //You can change virtual world
		SetPlayerPos(playerid, 1529.6,-1691.2,13.3);
	}
	else
	{
		new str[32];
        format(str,sizeof(str),"%02d:%02d",((pInfo[playerid][pJailed]/60)%60),pInfo[playerid][pJailed]%60);
		if(!GameTextForPlayer(playerid, str, 1200, 5))
			KillTimer(playertimer[playerid]);
	}
	return 1;
}

JailPlayer(playerid, targetid, time, reason[])
{
	new string[128], adminname[MAX_PLAYER_NAME + 1], targetname[MAX_PLAYER_NAME + 1];
	GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
	GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
	SetPlayerPos(targetid, 346.870025, 309.259033, 999.155700);
	SetPlayerVirtualWorld(targetid, 2);
	SetPlayerInterior(targetid,6);
	ResetPlayerWeapons(targetid);
	ResetPlayerInventory(targetid);
	AddSlotToInventoryWorld(targetid,"Bandage",1);
	pInfo[targetid][BackpackSlotsUsed] = 1;
	SendClientMessage(targetid,-1,"*"COL_RED" Your inventory has been reset!");
	pInfo[playerid][pJailed] = time * 60;
	format(string, sizeof(string), "Administrator %s ajailed %s for %d minutes. Reason: %s", adminname, targetname, time, reason);
	SendClientMessageToAll(COLOR_RED, string);
	KillTimer(playertimer[targetid]);
	playertimer[targetid] = SetTimerEx("AjailCount", 1000, true, "i", targetid);
}

CMD:ajail(playerid, params[])
{
	if(pInfo[playerid][pAdminLevel] < 1) SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Admin");
	else
	{
		new targetid, time, reason[64];
		if(sscanf(params, "uds[64]", targetid, time, reason)) SendClientMessage(playerid, -1, "USAGE: /ajail <playerid> <time> <reason>");
		else if(targetid > MAX_PLAYERS) SendClientMessage(playerid, COLOR_RED, "ERROR: Not connected !");
		else if(time < 1) SendClientMessage(playerid, COLOR_RED, "ERROR: Minimum 1 minute !");
		else if(pInfo[targetid][pJailed] > 0) SendClientMessage(playerid, COLOR_RED, "ERROR: Already in Jail !");
		else JailPlayer(playerid, targetid, time, reason);
	}
	return 1;
}

CMD:unjail(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel] < 1)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not admin!");

    new targetid;

    if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, -1, "USAGE: /unajail <playerid>");

    if(pInfo[targetid][pJailed] == 0)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: Player not in ajail right now!");

    new string[128], adminname[24], targetname[24];

    GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
    GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);

    format(string, sizeof(string), "Administrator %s took %s out of Admin Jail.", adminname, targetname);
    SendMessageToAllAdmins(string, -1);

    
    pInfo[playerid][pJailed] = 0;
    return 1;
}


I need to do something like saving timer at /q and giving it back at onplayerconnect

but how?
Reply


Messages In This Thread
Ajail quit on the server - by Zeus666 - 10.07.2016, 10:25
Re: Ajail quit on the server - by MCZOFT - 10.07.2016, 10:38
Re: Ajail quit on the server - by Zeus666 - 10.07.2016, 11:23
Re: Ajail quit on the server - by Zeus666 - 11.07.2016, 14:17

Forum Jump:


Users browsing this thread: 1 Guest(s)