[HELP] Jail works only for ID 0...
#1

pawn Код:
dcmd_jail(playerid, params[])
{
    new ReturnPlayer, ppName[24], ReturnUserName[24], str[128];
    if(PlayerInfo[playerid][AdminLevel] < 1) return false;
    if(sscanf(params, "dd", ReturnPlayer, JailMins[ReturnPlayer])) return SendClientMessage(playerid, mwhite, "Usage: /jail [playerid] [mins]");
    if(!IsPlayerConnected(ReturnPlayer)) return SendClientMessage(playerid, mbrightred, "Invalid playerid.");
    if(PlayerIsJailed[ReturnPlayer] == 1) return SendClientMessage(playerid, mbrightred, "That player is jailed already.");

    GetPlayerName(playerid, ppName, sizeof(ppName));
    GetPlayerName(ReturnPlayer, ReturnUserName, sizeof(ReturnUserName));

    format(str, sizeof(str), "You have been jailed for %d minutes!", JailMins[ReturnPlayer]);
    SendClientMessage(ReturnPlayer, COLOR_RED, str);
    SendClientMessage(ReturnPlayer, COLOR_RED, "Commands are disabled untill you get unjailed.");

    format(str, sizeof(str), "Mod Message: %s (ID: %d) has jailed %s (ID: %d) for %d minutes.", ppName, playerid, ReturnUserName, ReturnPlayer, JailMins[ReturnPlayer]);
    SendModMsg(mwhite, str);

    JailTimerEx[ReturnPlayer] = SetTimerEx("JailTimer", 60000, 1, "d", ReturnPlayer);

    SetPlayerInterior(ReturnPlayer,3);
    SetPlayerVirtualWorld(ReturnPlayer,990);
    PlayerIsJailed[ReturnPlayer] = 1;

    return 1;
}
Well, it doesn't set JailMins[playerid] for other IDs (except 0). Only works for ID 0. When i jail ID 0 for 2 mins, it says "You have been jailed for 2 minutes!", but when i jail ID 1, it can't set JailMins[playerid], so it says that "You have been jailed for 0 minutes!"...

How to fix?
Reply
#2

Try using a seperate variable and setting it later. I don't think sscanf would've set ReturnPlayer by the time it got to JailMins[ReturnPlayer], so it will always be 0.

Try this:
pawn Код:
dcmd_jail(playerid, params[])
{
    new ReturnPlayer, jailtime, ppName[24], ReturnUserName[24], str[128];
    if(PlayerInfo[playerid][AdminLevel] < 1) return false;
    if(sscanf(params, "dd", ReturnPlayer, jailtime)) return SendClientMessage(playerid, mwhite, "Usage: /jail [playerid] [mins]");
    if(!IsPlayerConnected(ReturnPlayer)) return SendClientMessage(playerid, mbrightred, "Invalid playerid.");
    if(PlayerIsJailed[ReturnPlayer] == 1) return SendClientMessage(playerid, mbrightred, "That player is jailed already.");

    JailMins[ReturnPlayer] = jailtime;

    GetPlayerName(playerid, ppName, sizeof(ppName));
    GetPlayerName(ReturnPlayer, ReturnUserName, sizeof(ReturnUserName));

    format(str, sizeof(str), "You have been jailed for %d minutes!", JailMins[ReturnPlayer]);
    SendClientMessage(ReturnPlayer, COLOR_RED, str);
    SendClientMessage(ReturnPlayer, COLOR_RED, "Commands are disabled untill you get unjailed.");

    format(str, sizeof(str), "Mod Message: %s (ID: %d) has jailed %s (ID: %d) for %d minutes.", ppName, playerid, ReturnUserName, ReturnPlayer, JailMins[ReturnPlayer]);
    SendModMsg(mwhite, str);

    JailTimerEx[ReturnPlayer] = SetTimerEx("JailTimer", 60000, 1, "d", ReturnPlayer);

    SetPlayerInterior(ReturnPlayer,3);
    SetPlayerVirtualWorld(ReturnPlayer,990);
    PlayerIsJailed[ReturnPlayer] = 1;

    return 1;
}
Reply
#3

Hmm, im gonna try it, brb
Reply
#4

It works now, thanks.
Reply
#5

Quote:
Originally Posted by LasTRace
Посмотреть сообщение
Its still the same... Now it doesn't work for ID:0, too
Can you show me where you initialize the JailMins variable?

Edit: Nevermind
Reply
#6

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Can you show me where you initialize the JailMins variable?

Edit: Nevermind
My bad, sorry, forgot to change Jailmins with jailtime, then edited it :P

Anyways, ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)