Need help with 4errors
#1

Hello,
I'm getting these errors
Код:
(2439) : error 003: declaration of a local variable must appear in a compound block
(2439) : warning 217: loose indentation
(2439) : error 017: undefined symbol "string"
(2439) : warning 215: expression has no effect
(2439) : error 001: expected token: ";", but found "]"
(2439) : fatal error 107: too many error messages on one line
this is the command I'm making
pawn Код:
CMD:a(playerid, params[])
{
    if(Player[playerid][pAdminLevel] >= 1)
    {
        if(!isnull(params))
       
            new string[128];//This is the errors line 2439

            if(Player[playerid][pAdminLevel] == 1) format(string, sizeof(string), "[Admin Chat] {kleur}Retired Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 2) format(string, sizeof(string), "[Admin Chat] {kleur}Junior Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 3) format(string, sizeof(string), "[Admin Chat] {kleur}General Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 4) format(string, sizeof(string), "[Admin Chat] {kleur}Senior Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 5) format(string, sizeof(string), "[Admin Chat] {kleur}Head Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 6) format(string, sizeof(string), "[Admin Chat] {kleur}Server Owner{FFFFFF} %s: %s", GetName(playerid, params);

            return SendClientMessage(playerid, -1, "Syntax: /a(dmin) [text]");
        }
        SendToAdmins(0xF2FF00FF, string);
    }
    return 1;
}
Reply
#2

Which one is the line number 2439?
Reply
#3

This one
pawn Код:
new string[128]
Reply
#4

pawn Код:
CMD:a(playerid, params[])
{
    if(Player[playerid][pAdminLevel] >= 1)
    {
        if(!isnull(params))
        {
            SendClientMessage(playerid, 0x505000FF, "USAGE : /a [text]");
        }
        else
        {
            new string[128];//This is the errors line
            if(Player[playerid][pAdminLevel] == 1) format(string, sizeof(string), "[Admin Chat] {kleur}Retired Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 2) format(string, sizeof(string), "[Admin Chat] {kleur}Junior Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 3) format(string, sizeof(string), "[Admin Chat] {kleur}General Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 4) format(string, sizeof(string), "[Admin Chat] {kleur}Senior Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 5) format(string, sizeof(string), "[Admin Chat] {kleur}Head Admin{FFFFFF} %s: %s", GetName(playerid, params);
            else if(Player[playerid][pAdminLevel] == 6) format(string, sizeof(string), "[Admin Chat] {kleur}Server Owner{FFFFFF} %s: %s", GetName(playerid, params);
            SendToAdmins(0xF2FF00FF, string);
        }
    }
    return 1;
}
Reply
#5

Quote:

003: declaration of a local variable must appear in a compound block

The declaration of a local variable must appear between braces ("{...}") at the active scope level.

When the parser flags this error, a variable declaration appears as the only statement of a function or the only statement below an if, else, for, while or do statement. Note that, since local variables are accessible only from (or below) the scope that their declaration appears in, having a variable declaration as the only statement at any scope is useless.

****
Reply
#6

Then I get these errors:
Код:
(2444) : warning 202: number of arguments does not match definition
(2444) : error 001: expected token: ",", but found ";"
(2445) : warning 202: number of arguments does not match definition
(2445) : error 001: expected token: ",", but found ";"
(2446) : warning 202: number of arguments does not match definition
(2446) : error 001: expected token: ",", but found ";"
(2447) : warning 202: number of arguments does not match definition
(2447) : error 001: expected token: ",", but found ";"
(2448) : warning 202: number of arguments does not match definition
(2448) : error 001: expected token: ",", but found ";"
(2449) : warning 202: number of arguments does not match definition
(2449) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#7

try to remember ";" cuz it's very important! replace it with this new string[128];
Reply
#8

Quote:
Originally Posted by McFellow
Посмотреть сообщение
Then I get these errors:
Код:
(2444) : warning 202: number of arguments does not match definition
(2444) : error 001: expected token: ",", but found ";"
(2445) : warning 202: number of arguments does not match definition
(2445) : error 001: expected token: ",", but found ";"
(2446) : warning 202: number of arguments does not match definition
(2446) : error 001: expected token: ",", but found ";"
(2447) : warning 202: number of arguments does not match definition
(2447) : error 001: expected token: ",", but found ";"
(2448) : warning 202: number of arguments does not match definition
(2448) : error 001: expected token: ",", but found ";"
(2449) : warning 202: number of arguments does not match definition
(2449) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
You're missing a parenthesis on the end of every format line. ' ) '

Also this code won't work, as you're checking if the string is NOT null (!isnull). Remove the exclamation mark.
Reply
#9

Quote:
Originally Posted by Angel.Why
Посмотреть сообщение
try to remember ";" cuz it's very important! replace it with this new string[128];
I use
pawn Код:
new string[128];
Reply
#10

Quote:
Originally Posted by LarzI
Посмотреть сообщение
You're missing a parenthesis on the end of every format line. ' ) '
huh I have this
pawn Код:
if(Player[playerid][pAdminLevel] == 1) format(string, sizeof(string), "[Admin Chat] {kleur}Retired Admin{FFFFFF} %s: %s", GetName(playerid, params);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)