SA-MP Forums Archive
cmdtext's cases can't be read - 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: cmdtext's cases can't be read (/showthread.php?tid=180913)



cmdtext's cases can't be read - ZecKo - 03.10.2010

Hi, I can't access to something like cmdtext[0] in OnPlayerCommandText(), I must use another string to read them.
Код:
	new cmdText[128];
	format(cmdText, 128, "%s", cmdtext);
My question is : Why ?


Re: cmdtext's cases can't be read - Mike_Peterson - 03.10.2010

hmm what?
u mean u cant use strcmp?
have u got #include <a_samp> at top?


Re: cmdtext's cases can't be read - ZecKo - 03.10.2010

No I mean using cmdtext[i] (i = 0..127) will "crash" the function (OnPlayerCommandText()), like if it has a return; in it.


Re: cmdtext's cases can't be read - Mike_Peterson - 03.10.2010

Can you tlel me where ur using cmdtext[i] in?
since i know onPlayerCommandText u should use strcmp(cmdtext, bla bla bla
where your using it in?


Re: cmdtext's cases can't be read - ZecKo - 03.10.2010

Код:
    // separate command and params
    new command[64];
    new params[128];
    new i = 1, ii = 0;
    while(cmdText[i] != 0 && cmdText[i] != ' ')
    {
        command[ii] = cmdText[i];
        i++;
        ii++;
        if(i > 60)
        {
            return UnknownCommand(playerid, command);
        }
    }
It bug at the while() if I use "cmdtext".


Re: cmdtext's cases can't be read - Mike_Peterson - 03.10.2010

I cant figure out whats the problem
probably more advanced scripters will see this..
but whats the point of this script actually?
like u wanna replace SERVER:Unknown Command ?
theres a very simple way to replace that >.>


Re: cmdtext's cases can't be read - ZecKo - 03.10.2010

No it's similar to strtok, I didn't give the whole script.


Re: cmdtext's cases can't be read - MadeMan - 03.10.2010

You need to show more code, because the problem shouldn't be there.


Re: cmdtext's cases can't be read - ZecKo - 03.10.2010

No, the problem is here. A print() before the while() works, not after.


Re: cmdtext's cases can't be read - MadeMan - 03.10.2010

Did you try a print inside the loop?