SA-MP Forums Archive
Command parameters problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command parameters problem (/showthread.php?tid=128909)



Command parameters problem - SpiderPork - 20.02.2010

Hey there!
I'm having some problems with detecting multiple parameters in a command. It should send a message saying how to use the command, but if I use strlen, it never detects that the string is empty and always sends me the message, even if I type something more. If I use if(!params[0]), it also never detects it's empty, but still proceeds as if the string wasn't empty.

Just an example in my /mute command, though it happens in every command.
pawn Код:
command(unmute, playerid, params[])
{
    if(AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
    {
        new
            giveplayerid;

        if(!IsNumeric(params)) giveplayerid = ReturnPlayerID(params);
            else giveplayerid = strval(params);

        if(!params[0]) return SendClientMessage(playerid, RED, "Usage: /unmute [ID]");

        if(IsPlayerConnected(giveplayerid))
        {
            format(stringy, sizeof(stringy), "You have been unmuted by administrator %s.", PlayerName(playerid));
            SendClientMessage(giveplayerid, RED, stringy);
            AccountInfo[giveplayerid][Muted] = 0;
            SaveLog("MuteLog", stringy);
        }
        else return SendClientMessage(playerid, RED, "Error: That player is not connected.");
    }
    else return SendClientMessage(playerid, RED, "Error: Your administrator level is not high enough for this command.");
    return 1;
}



Re: Command parameters problem - SpiderPork - 21.02.2010

Bump


Re: Command parameters problem - kLx - 21.02.2010

Try using sscanf