SA-MP Forums Archive
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)
+--- Thread: Problem "~" (/showthread.php?tid=609172)



Problem "~" - Ugaustin - 09.06.2016

I have /cnn and /cnnn I added

PHP код:
if(strfind(string"~"true) != -1)
                        {
                            return 
SendClientMessage(playeridCOLOR_RED"Can't use in /cnn or /cnnn '~' ");
                        } 
and still doesn't work, I don't want "~" in my /cnn or /cnnn !!


Re: Problem "~" - zSuYaNw - 09.06.2016

This function check caracter by caracter:
PHP код:
for(new istring[i]; ++i){
     if(
string[i] == '~'){
         break;
     }
}

if(
string[i] != EOS){
     return 
SendClientMessage(playeridCOLOR_RED"Can't use in /cnn or /cnnn '~' ");

you can test it?


Re: Problem "~" - Ugaustin - 09.06.2016

I put those in my cmds??


Re: Problem "~" - zSuYaNw - 09.06.2016

Quote:
Originally Posted by Ugaustin
Посмотреть сообщение
I put those in my cmds??
Yeees!

u can post the full cmd?


Re: Problem "~" - Ugaustin - 09.06.2016

but only ~ without ' ' yes?


Re: Problem "~" - Sjn - 09.06.2016

Quote:
Originally Posted by Ugaustin
Посмотреть сообщение
but only ~ without ' ' yes?
Yes. The apostrophes are there to hold the ~ symbol inside the check function. Otherwise, script will give error. If you don't know, how to use this with your command, post your command script as said above.

Edit: The code posted above doesn't seem to work.

This one should work.
PHP код:
for (new istrlen(string); != ji++)
{
    if (
string[i] == '~')
    {
        return 
SendClientMessage(playerid, -1"Can't use in /cnn or /cnnn '~' ");
    }

Ofc, you will have to replace the string with the one you're checking the symbol in.


Re: Problem "~" - Gammix - 09.06.2016

Quote:
Originally Posted by zSuYaNw
Посмотреть сообщение
This function check caracter by caracter:
PHP код:
for(new istring[i]; ++i){
     if(
string[i] == '~'){
         break;
     }
}
if(
string[i] != EOS){
     return 
SendClientMessage(playeridCOLOR_RED"Can't use in /cnn or /cnnn '~' ");

you can test it?
This is what strfind is going to do.

I guess there is problem related to your string.