Missing a bracket, code working
#1

Alright so uhm I am not sure why but why the fuck is this working lol


I have opened 3 brackets, closed only 2, Im not getting any errors for some odd reason. When I try to close 3 of them I do get an error saying "Umatching bracket"

pawn Code:
stock createFactionRank(faction_id, rank_name[], power) { //first bracket
    for(new = 0; i< MAX_FACTION_RANKS; i++) { //second
        if(rankInfo[i][fr_Valid] == 0) { //third
            rankInfo[i][fr_ID] = i;
            rankInfo[i][fr_Valid] = 1;
        format(rankInfo[i][fr_Name],sizeof(rankInfo[i][fr_Name]),"%s",rank_name);
        rankInfo[i][fr_Power] = power;
        new query[128];
        mysql_format(mysql,query,sizeof(query),"INSERT INTO faction_rank (`faction_id`,`rank_name`,`faction_rank_power`) VALUES (%d,'%e',%d)",faction_id, rank_name, power);
        mysql_tquery(mysql,query,"");
        break;
        } //first closing
    } //second second
Reply
#2

try this
PHP Code:
stock createFactionRank(faction_idrank_name[], power)

    for(new = 
0iMAX_FACTION_RANKSi++)
    { 
        if(
rankInfo[i][fr_Valid] == 0)
        {
            
rankInfo[i][fr_ID] = i;
            
rankInfo[i][fr_Valid] = 1;
        }
        
format(rankInfo[i][fr_Name],sizeof(rankInfo[i][fr_Name]),"%s",rank_name);
        
rankInfo[i][fr_Power] = power;
        new 
query[128];
        
mysql_format(mysql,query,sizeof(query),"INSERT INTO faction_rank (`faction_id`,`rank_name`,`faction_rank_power`) VALUES (%d,'%e',%d)",faction_idrank_namepower);
        
mysql_tquery(mysql,query,"");
        break;
    }

Reply
#3

Thats not what Im trying to achieve.

This is the code with brackets placed normaly

pawn Code:
stock createFactionRank(faction_id, rank_name[], power)
{
    for(new = 0; i< MAX_FACTION_RANKS; i++)
    {
        if(rankInfo[i][fr_Valid] == 0)
        {
               rankInfo[i][fr_ID] = i;
               rankInfo[i][fr_Valid] = 1;
           format(rankInfo[i][fr_Name],sizeof(rankInfo[i][fr_Name]),"%s",rank_name);
           rankInfo[i][fr_Power] = power;
           new query[128];
           mysql_format(mysql,query,sizeof(query),"INSERT INTO faction_rank (`faction_id`,`rank_name`,`faction_rank_power`) VALUES (%d,'%e',%d)",faction_id, rank_name, power);
          mysql_tquery(mysql,query,"");
          break;
        }
    }
As you can see, there is 1 missing to close the function
Reply
#4

Do you even call createFactionRank anywhere? You'd definitely get errors:
Code:
//error 001: expected token: "-identifier-", but found "="
for(new = 0; i< MAX_FACTION_RANKS; i++)
// to:
for(new i = 0; i< MAX_FACTION_RANKS; i++)
pawn Code:
format(rankInfo[i][fr_Name],sizeof(rankInfo[i][fr_Name]),"%s",rank_name);
unless you use Zeex's compiler patch, it'd give an error 001: expected token: "]", but found "-integer value-".
strcpy is also recommended instead of format.
Reply
#5

Ah that explains it, I was wondering why I was getting the unmatched error with 3 brackets, didnt know that mistake like that can cause a loop like that to be ignore by the compiler. Thanks man

Adding i basically got rid of the extra bracket error
Reply
#6

-too late-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)