SA-MP Forums Archive
admin jail problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: admin jail problem (/showthread.php?tid=550289)



admin jail problem - TakeiT - 12.12.2014

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;
}



Re: admin jail problem - Jefff - 12.12.2014

[pid] doesn't exists


Re: admin jail problem - TakeiT - 12.12.2014

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


Re: admin jail problem - Jefff - 12.12.2014

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


Re: admin jail problem - TakeiT - 12.12.2014

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 -_-