admin jail problem
#1

this system works, however sometimes (not all the time) when the time is up, the player will respawn every second, even though the timer has been killed.

pawn Код:
CMD:ajail(playerid, params[])
{
    new target, reason[100], time, query[400], string[124], timestr[256];
    if(pInfo[playerid][Admin] < 1) return ErrorMessage(pid, "You aren't authorized to use this command.");
    if(sscanf(params, "uds[100]", target, time, reason)) return UsageMessage(pid, "/ajail [target] [time] [reason]");
    SetPlayerVirtualWorld(target, target);
    SetPlayerInterior(target, 2);
    SetPlayerPos(target, 20.1830, 31.9226, 3.1341);
    pInfo[target][Jailed] = time*60;
    format(string, sizeof(string), "%s admin jailed by %s for: %s ( %d minutes )", pInfo[target][Name], pInfo[playerid][Name], reason, time);
    SendClientMessageToAll(COLADMIN, string);

    GetDateTime(timestr);
   
    mysql_format(connection, query, sizeof(query), "INSERT INTO `adminrecord` (`UID`, `Player`, `Banning Admin`, `Ban Type`, `Ban Reason`, `Ban Date`) VALUES (%d, '%e', '%e', %d, '%e', '%e')", pInfo[target][ID], pInfo[target][Name], pInfo[playerid][Name], 2, reason, timestr);
    mysql_query(connection, query);
   
    ajailtimer[pid] = SetTimerEx("ajail", 1000, true, "i", target);
    return 1;
}

public ajail(playerid)
{
    if(pInfo[pid][Jailed] <= 1)
    {
        KillTimer(ajailtimer[pid]);
        SpawnPlayer(playerid);
        return 1;
    }
    else
    {
        pInfo[pid][Jailed] --;
        new string[100];
        format(string, sizeof(string), "~r~%d ~w~Seconds left", pInfo[pid][Jailed]);
        GameTextForPlayer(pid, string, 1000, 6);
    }
    return 1;
}
Reply
#2

[pid] doesn't exists
Reply
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
[pid] doesn't exists
Its defined
Reply
#4

and this is wrong, you're using target not pid and in public playerid instead of pid (pid is always id 0)
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
and this is wrong, you're using target not pid and in public playerid instead of pid (pid is always id 0)
That would explain why I had no issue when I tried to jail myself!

Thanks -_-
Reply


Forum Jump:


Users browsing this thread: