[HELP]Script errors.. conflict
#1

Error in my code onplayertext... give this error, and conflict the symbol i

Код:
warning 219: local variable "i" shadows a variable at a preceding level
error 076: syntax error in the expression, or invalid function call
Код:
    new
        i;
    while (text[++i])
	{
        if ('A' <= text[i] <= 'Z') text[i] |= 0x20;
    }
    //
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        {
            if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
            {
				new
					s[128];
                format(s, sizeof(s), "%s: %s", name, text[0]);
                SendClientMessageToAll(-1, s);
                return 0;
            }
            return 0;
        }
    }
Reply
#2

should kill the first warning
pawn Код:
new
        iText;
    while (text[++iText])
    {
        if ('A' <= text[iText] <= 'Z') text[iText] |= 0x20;
    }
    //
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        {
            if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
            {
                new
                    s[128];
                format(s, sizeof(s), "%s: %s", name, text[0]);
                SendClientMessageToAll(-1, s);
                return 0;
            }
            return 0;
        }
    }
point us to the line for the error!
Reply
#3

pawn Код:
new
        i;
Remove it,you are already defining "i" with the loop.

Also,the error 076,post the line.
Reply
#4

error 076: syntax error in the expression, or invalid function call

Код:
    new
        iText;
    while (text[++iText])
    {
        if ('A' <= text[iText] <= 'Z') text[iText] |= 0x20;
    }
    //
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        {
            if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
            {
                new
                    s[128];
                /* ------>>>>>>>> LINE ERROR ! */format(s, sizeof(s), "%s: %s", name, text[0]);
                SendClientMessageToAll(-1, s);
                return 0;
            }
            return 0;
        }
    }
Reply
#5

Not related to your problem but you should remove the return 0's from the loop because it's only going to send one message. Put them outside the loop.

Also try replacing text[0] with just 'text'.
Reply
#6

You might like to show us some of the codes above and below this code 'cause when I compiled it gave me no errors!

And why do I see return inside the loop? It will just stop it after the first player. Remove it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)