/jail-/unjail commands problem
#1

Code:
#include <a_samp>
#include <sscanf2>
#include <zcmd>


CMD:jail(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");
new id, time, admin[MAX_PLAYER_NAME], str[128], JailTimer[MAX_PLAYERS], Jailed[MAX_PLAYERS];
GetPlayerName(playerid, admin, sizeof(admin));
GetPlayerName(id, Jailed, sizeof(Jailed));
if(sscanf(params,"df",id,time)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /jail <playerid> <time> ");
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
if(Jailed[id] == 1) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is already jailed.");
format(str, sizeof(str), "Admin %s has put %s [ID:%d] in jail for %f minutes", admin, Jailed, id, time);
SendClientMessageToAll(COLOR_ORANGE, str);
SetPlayerInterior(id, 3);
SetPlayerVirtualWorld(id, 10);
SetPlayerFacingAngle(id, 360.0);
SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
SetPlayerHealth(id, 9999999999.0);
ResetPlayerWeapons(id);
JailTimer[id] = SetTimerEx("unjail", time*60000, false, "i", id);
return 1;
}

CMD:unjail(playerid,params[])
{
new id, str[128], admin[MAX_PLAYER_NAME], JailTimer[MAX_PLAYERS], Jailed[MAX_PLAYERS] ;
GetPlayerName(playerid, admin, sizeof(admin));
GetPlayerName(id, Jailed, sizeof(Jailed));
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");
if(sscanf(params,"d",id)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /unjail <playerid>");
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
if(Jailed[id] == 0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not jailed.");
Jailed[id] = 0;
SetPlayerInterior(id, 0);
SetPlayerVirtualWorld(id, 0);
SpawnPlayer(id);
SetPlayerHealth(id, 100);
KillTimer(JailTimer[id]);
format(str, sizeof(str), "Admin %s has unjailed you", admin);
SendClientMessage(id,0x00FF00AA, str);
return 1;
}
My problems are: 1. I can't trigger line "if(Jailed[id] == 1) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is already jailed.");"
2. I know lines "if(Jailed==0/1)" are nosense but i dont know what to do about it.
3. Timer doesnt work. I know it needs public format, but i searched in wiki and didnt understand how to use it. I am a begginer.
PLease help me!
Reply
#2

as i can see that you put integer %f instead of integer %d or %i

on your sscanf it should be like this
pawn Code:
if(sscanf(params,"dd",id,time)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /jail <playerid> <time> ");
AND

on your /jail string it should be like this
pawn Code:
format(str, sizeof(str), "Admin %s has put %s [ID:%d] in jail for %d minutes", admin, Jailed, id, time);
SendClientMessageToAll(COLOR_ORANGE, str);
Reply
#3

"f" letter allows me to enter 0.5 minutes or 0.1 minuts. f is fine. You don't help me at all. If you dont know whats going on don't waste time for useless posts.
Reply
#4

pawn Code:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

new JailTimer[MAX_PLAYERS],Jailed[MAX_PLAYERS];
CMD:jail(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");
    new id, time, admin[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, admin, sizeof(admin));
    GetPlayerName(id, Jailed, sizeof(Jailed));
    if(sscanf(params,"df",id,time)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /jail <playerid> <time> ");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
    if(Jailed[id] == 1) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is already jailed.");
    Jailed[id] = 1;
    format(str, sizeof(str), "Admin %s has put %s [ID:%d] in jail for %f minutes", admin, Jailed, id, time);
    SendClientMessageToAll(-1, str);
    SetPlayerInterior(id, 3);
    SetPlayerVirtualWorld(id, 10);
    SetPlayerFacingAngle(id, 360.0);
    SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
    SetPlayerHealth(id, 9999999999.0);
    ResetPlayerWeapons(id);
    JailTimer[id] = SetTimerEx("unjail", time*60000, false, "i", id);
    return 1;
}

CMD:unjail(playerid,params[])
{
    new id, str[128], admin[MAX_PLAYER_NAME];
    GetPlayerName(playerid, admin, sizeof(admin));
    GetPlayerName(id, Jailed, sizeof(Jailed));
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");
    if(sscanf(params,"d",id)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /unjail <playerid>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
    if(Jailed[id] == 0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not jailed.");
    Jailed[id] = 0;
    SetPlayerInterior(id, 0);
    SetPlayerVirtualWorld(id, 0);
    SpawnPlayer(id);
    SetPlayerHealth(id, 100);
    KillTimer(JailTimer[id]);
    format(str, sizeof(str), "Admin %s has unjailed you", admin);
    SendClientMessage(id,0x00FF00AA, str);
    return 1;
}

forward unjail(playerid);

public unjail(playerid)
{
    Jailed[playerid] = 0;
    SetPlayerInterior(playerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    SpawnPlayer(playerid);
    SetPlayerHealth(playerid, 100);
    return 1;
}
Reply
#5

doesn't work dude, thanks for your time. Adding line "Jailed[id]=0;" I get "jailed" at spawnpoint, not even in jail. After i delete this, it works as it did before I started this topic. Timer doesn't work.
Reply
#6

Tried making the jail time minimum as 1minute and using integers?
Try that and reply here after you've done it and what are the results. Or if you even done it.
Reply
#7

integer minutes dont work either
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)