aJail command problem
#1

Alright, I got a problem with my /ajail command. It is scripted with sscanf & zcmd. And i am new to sscanf. I dont understand it so good. But when i write /ajail 1(my ID) 5(5 mins) test(reason) it just shows up: You cant jail NPCS!

This is my code:

pawn Код:
CMD:ajail(playerid, params[])
    {
        new
            user,
            ajailtime,
            szReason[32],
            giveplayerid;
        if(sscanf(params, "us[32]", user, ajailtime, szReason))
            return SendClientMessage(playerid, RED, "[LOST:RP] /ajail [ID] [TIME] [REASON]");
        if(IsPlayerNPC(giveplayerid))
            return SendClientMessage(playerid, RED, "[LOST:RP] You cant ajail npcs");
        if(PlayerInfo[playerid][pAdmin] == 0)
            return SendClientMessage(playerid, RED, "[LOST:RP] You are not a admin");
        if(PlayerInfo[playerid][pAdmin] < 2)
            return SendClientMessage(playerid, RED, "[LOST:RP] You are not a admin or you are a to low one");
            if(PlayerInfo[playerid][pAdmin] > 3)
         {
            new
                sendername[MAX_PLAYER_NAME],
                string[128],
                giveplayer[MAX_PLAYER_NAME];
                GetPlayerName(user, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                PlayerInfo[user][pJailed] = 1;
                PlayerInfo[user][pJailTime] = ajailtime*60;
                SetPlayerInterior(user, 6);
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerPos(user, 264.6288,77.5742,1001.0391);
                SetPlayerFacingAngle(user, -90);
                format(string, sizeof(string), "You got jailed! %d minutes left.", ajailtime);
                SendClientMessage(user, RED, string);
            }
            return 1;
        }
Anyone know how to fix this?

Again, Im new to sscanf.
Reply
#2

You didn't set giveplayerid.
Do like this
pawn Код:
if(IsPlayerNPC(user))
Reply
#3

That worked with the npc thing :P But now when i write /ajail 1 5 test it says: Invaild command
Reply
#4

pawn Код:
if(sscanf(params, "uis[32]", user, ajailtime, szReason))
You can't have 2 formats with 3 definitions. You need an integer value for "ajailtime", hence the "i" between the "u" and the "s[32]".
Reply
#5

Works fine now Thanks and i'll remember that with the UIS
Reply
#6

Look:
u = username, playerid
i,d = integer
s = string
And you format the sscanf with these.
Reply
#7

ahh okey Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)