Removing the parameters.
#1

Alright, basically i am using ZCMD.
And now i've been using OnPlayerCommandPerformed to display if it is unknown command, Basically that means the command doesn't exist, Now, The thing i want to do is how do i remove the parameters, For example, if player types a command with spaces and parameters like /noncmd Hi, It will only display this "SERVER: The command '/noncmd' doesn't exist, Please refer to /commands or /help" instead of "SERVER: The command '/noncmd Hi' doesn't exist, Please refer to /commands or /help"

When player types /noncmd (without the spaces and Hi) it will display the normal one like "SERVER: The command '/noncmd' doesn't exist, Please refer to /commands or /help"

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        new string[256];
        format(string, sizeof(string), ""lightblue"SERVER: "white"The command '"lightred"%s"white"' doesn't exist, Please refer to "grey"/commands "white"or "grey"/help", cmdtext);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        new
            string[103], arrays;
        while(cmdtext[++arrays] > ' ')
        if(arrays > MAX_FUNCTION_NAME)
        {
            format(string, sizeof(string), ""lightblue"SERVER: "white"The command '"lightred"%s"white"' doesn't exist, Please refer to "grey"/commands "white"or "grey"/help", arrays);
            SendClientMessage(playerid, -1, string);
            return 0;
        }
    }
    return 1;
}
Reply
#3

Basically nothing appears right after i typed an unknown command, Although i am concerned about the variable arrays, Why are you using an integer over the "%s" in the format?
Reply
#4

Have you tried using sscanf ?
It's an idea and i didn't test it before !
Test it and tell the result

new string[50];
sscanf(cmdtext, "s[50]", string) ;

I don't now it'll be work or no
Just a little test
Reply
#5

Quote:
Originally Posted by M4D
Посмотреть сообщение
Have you tried using sscanf ?
It's an idea and i didn't test it before !
Test it and tell the result

new string[50];
sscanf(cmdtext, "s[50]", string) ;

I don't now it'll be work or no
Just a little test
That wouldn't work, But you'd give me an idea though, Nice try.
Reply
#6

I've tested it now and worked.
I'll give you an example
pawn Код:
new string[50], output1[30], output2[30];
format(string, 50,"/blabla parameter1 parameter2 parameter3");
sscanf(string, "s[30]p< >",output1,output2);
print(output1);
Note: there is a space between < and > after "p" in sscanf.
Because between command and parameters is a space
Hope i helped
Good luck
Reply
#7

Works like a charm, thanks bro, there are few warnings during the test but managed to fixed it by myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)