Jail command doesn't show reason.
#1

pawn Код:
dcmd_jail(playerid,params[])
{
    new string[128];
    new ID;
    new cmdtime;
    new cmdreason[100];
    if(sscanf(params,"ui",ID,cmdtime,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /jail [Player ID] [Seconds] [Reason]");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID [%d] is not connected to the server. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s[%d] is not spawned. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    format(string,sizeof(string),"{FF0000}[ADMIN] {FFFFFF}%s[%d] has jailed %s[%d] for %d seconds. Reason: %s.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdtime,cmdreason);
    SendClientMessageToAll(COLOR_WHITE,string);
Can you help me?
Reply
#2

Try

pawn Код:
cmd_jail(playerid,params[])
{
    new string[128];
    new ID;
    new cmdtime;
    new cmdreason[100];
    if(sscanf(params,"ui",ID,cmdtime,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /jail [Player ID] [Seconds] [Reason]");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID [%d] is not connected to the server. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s[%d] is not spawned. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    format(string,sizeof(string),"{FF0000}[ADMIN] {FFFFFF}%s[%d] has jailed %s[%d] for %d seconds. Reason: %s.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdtime,cmdreason);
    SendClientMessageToAll(COLOR_WHITE,string);
    return 1;
}
Reply
#3

if (sscanf(params,"uis[100]", ID, cmdtime, cmdreason))
Reply
#4

This should work.

pawn Код:
dcmd_jail(playerid,params[])
{
    new string[256],ID,cmdtime,cmdreason[100];// Using 256 as you are displaying lot of things in a ClientMessage. Lower it according to your needs.
    if(sscanf(params,"uis[99]",ID,cmdtime,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /jail [playerid/partofname] [Seconds] [Reason]");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"ID [%d] is not connected to the server. Please recheck the ID.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s[%d] is not spawned yet. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    format(string,sizeof(string),"{FF0000}[ADMIN] {FFFFFF}%s[%d] has jailed %s[%d] for %d seconds. Reason: %s.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdtime,cmdreason);
    SendClientMessageToAll(COLOR_WHITE,string);
    return 1;
}
Reply
#5

They both worked fine, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)