SA-MP Forums Archive
Missing a bracket, code working - 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: Missing a bracket, code working (/showthread.php?tid=622702)



Missing a bracket, code working - TwinkiDaBoss - 25.11.2016

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



Re: Missing a bracket, code working - Micko123 - 25.11.2016

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;
    }




Re: Missing a bracket, code working - TwinkiDaBoss - 25.11.2016

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


Re: Missing a bracket, code working - Konstantinos - 25.11.2016

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.


Re: Missing a bracket, code working - TwinkiDaBoss - 25.11.2016

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


Re: Missing a bracket, code working - Micko123 - 25.11.2016

-too late-