must be a constant expression; assumed zero
#1

I've tried to hide IP's that are being mentioned ingame to prevent advertising,
Wrote a little code for it, however its returning the error
Код:
error 008 : must be a constant expression; assumed zero
Its on the following piece of code.
Код:
public OnPlayerText(playerid, text[])
{

	new result[128] = text;
    for(new i = 0, j = strlen(result); i < j; i++)
    {
        if('0' <= result[i] <= '9')
        {
            result[i] = '*';
        }
    }

    SendPlayerMessageToAll(playerid, result);
return 0;
}
The error is on the line where im making the variable :: new result[128] = text;
Reply
#2

use strpack
PHP код:
strpack(resulttext); 
Reply
#3

Does not seem to work.
Reply
#4

Why don't you use strcat/strcpy when dealing with strings? I thought that is common sense, You'll have problems if you keep dealing with strings same way you work on ints.
simply strcat text into result, since you JUST created it, it's empty hence concatenate works as copying.
Reply
#5

Error is fixed, however now its showing the IP, its not changing the numbers to asterixes.
Reply
#6

You should know that this piece of code changes ANY number to an asterisk. Even in normal sentences like "I have 500 ammo". People have come up with many methods to recognize IP addresses in strings. You should look at those rather than trying to devise your own method.
Reply
#7

Thanks vince, i'll check out something else instead hehe.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)