SA-MP Forums Archive
Invalid character constant - 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: Invalid character constant (/showthread.php?tid=619565)



Invalid character constant - NeXoR - 19.10.2016

Hey guys (ignore my previous thread, I am trying to create my own script)
Why am I having this error ?
PHP код:
    for(new 04i++)
    {
        if(!
IsNumeric(s[i]))
        {
            for(new 
05j++)
            {
                switch(
s[i][j])
                {
                    case 
0..9: continue;
                     default: 
s[i][j] = '';
                }
            }
        }
    } 
Код:
error 027: invalid character constant
PHP код:
default: s[i][j] = ''



Re: Invalid character constant - RoboN1X - 19.10.2016

You can't do that, what you want is to replace the character with another character, you can't make it empty except you fill it with space, therefore if you have this string: "12ab3" and you replace each non numeric character with a space it would be:
Код:
{'1', '2', ' ', ' ', '3' '\0'}
{49, 50, 32, 32, 51, 0} // just for instance
"12  3"
Or even if you replace it with a null terminator '\0' or 0, therefore it would give you:
Код:
{'1', '2', '\0', '\0', '3', '\0'}
{49, 50, 0, 0, 51, 0} // just for instance
"12"
If you are expecting to have "123", you have to make an extra string and copy only the numbers instead of replacing the whole characters (skipping the non numeric and copy the number instead). If you are really wanting to make an anti-advert, then i suggest you to follow the code answered in your previous threads since your code is wrong especially at how you check the numbers
Код:
if(!IsNumeric(s[i])) // Redudant

case 0..9: continue; // Wrong, 0 to 9 are: 	 (you can't see these special characters/symbols, but you can copy paste it)
Sorry for my poor english.


Re: Invalid character constant - SickAttack - 19.10.2016

You do realize that's still not going to get the job done (along with your two other threads)?


Re: Invalid character constant - NeXoR - 19.10.2016

Alright I go with you, what do I do if someone adverts a domain ? E.G: server.blabla.com:4444


Re: Invalid character constant - Kaliber - 19.10.2016

Its not that easy to filter sth like this: https://sampforum.blast.hk/showthread.php?tid=568668