26.03.2013, 18:19
I scripted this little self-functioning jail filterscript and as title says, when i jail someone and in a few seconds unjail him with the command /unjail [ID], the timer still runs and trigers "public unjail()" lines. What do I do wrong?
pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
new bool: j12[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
j12[playerid]=false;
return 0;
}
CMD:jail(playerid,params[])
{
if (IsPlayerAdmin(playerid))
{
new id, time, admin[MAX_PLAYER_NAME], JailTimer[MAX_PLAYERS], Jailed[MAX_PLAYERS], str[128];
if (!sscanf(params,"dd",id,time))
{
if (IsPlayerConnected(id))
{
if (j12[id]==false)
{
GetPlayerName(playerid, admin, sizeof(admin));
GetPlayerName(id, Jailed, sizeof(Jailed));
format(str, sizeof(str), "Admin %s has put %s [%d] in jail for %d minutes.", admin, Jailed, id, time);
SendClientMessageToAll(0xFFA500FF, str);
SetPlayerInterior(id, 3);
SetPlayerFacingAngle(id, 360.0);
SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
SetPlayerHealth(id, 9999999999.0);
ResetPlayerWeapons(id);
JailTimer[id] = SetTimerEx("unjail", time*60000, 0, "d", id);
j12[id] = true;
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is already in jail.");
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
}
else SendClientMessage(playerid, 0xFF0000AA, "USAGE: /jail [playerid] [minutes] ");
}
else SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command.");
return 1;
}
forward unjail(id);
public unjail(id)
{
new free[MAX_PLAYERS], str[128];
SetPlayerInterior(id, 0);
SpawnPlayer(id);
GivePlayerWeapon(id, 4, 1);
SetPlayerHealth(id,100.0);
GameTextForPlayer(id, "~g~You are free",2500,3);
GetPlayerName(id, free, sizeof(free));
format(str, sizeof(str), "%s {FFFFFF}has been automatically released from jail.", free);
SendClientMessageToAll(0x009DFFFF, str);
PlayerPlaySound(id, 1137, 0.0, 0.0, 0.0);
j12[id] = false;
return 1;
}
CMD:unjail(playerid,params[])
{
if (IsPlayerAdmin(playerid))
{
new id, admin[MAX_PLAYER_NAME], JailTimer[MAX_PLAYERS], free[MAX_PLAYERS], str[128];
if(!sscanf(params,"d",id))
{
if (IsPlayerConnected(id))
{
if (j12[id]==true)
{
GetPlayerName(playerid, admin, sizeof(admin));
GetPlayerName(id, free, sizeof(free));
j12[id] = false;
SetPlayerInterior(id, 0);
SpawnPlayer(id);
SetPlayerHealth(id, 100);
KillTimer(JailTimer[id]);
PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Admin %s has unjailed you.", admin);
SendClientMessage(id,0x00FF00AA, str);
format(str, sizeof(str), "You unjailed %s.", free);
SendClientMessage(id,0x00FF00AA, str);
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not in jail.");
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
}
else SendClientMessage(playerid, 0xFF0000AA, "USAGE: /unjail [playerid]");
}
else SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command.");
return 1;
}