Faction System Errors
#1

I was making a faction system with the help of this tutorial(https://sampforum.blast.hk/showthread.php?tid=392856), but when I created it as instructed(except for adding a Rank 6), it gives me the following errors:
Код:
Gamemode.pwn(156) : error 017: undefined symbol "MAX_FACTIONS"
Gamemode.pwn(624) : error 017: undefined symbol "MAX_FACTIONS"
Gamemode.pwn(627) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(787) : error 017: undefined symbol "Total_FactionsCreated"
Gamemode.pwn(804) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(821) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(836) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(852) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(867) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(882) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(897) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(911) : error 035: argument type mismatch (argument 1)
Gamemode.pwn(2322) : warning 203: symbol is never used: "facid"
This is the code:
OnGameModeInit
pawn Код:
mysql_connect(MYSQLIP, MYSQLUSER, MYSQLDB, MYSQLPASSWORD);
    mysql_debug(1);
   
    LoadFactions();
Enum
pawn Код:
enum faction
{
    ID, //Faction ID
    Name[32],
    Type, //Type, criminal, law, etc
    Rank1[32],
    Rank2[32],
    Rank3[32],
    Rank4[32],
    Rank5[32],
    Rank6[32]
};
New
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
new Factions[MAX_FACTIONS][faction], Total_Factions_Created, facid[MAX_PLAYERS];
Stocks
pawn Код:
stock LoadFactions()
{
    new query[400];
    for(new id; id < MAX_FACTIONS; id++)
    {
        format(query, sizeof(query), "SELECT * FROM Factions WHERE ID = %d, id");
        mysql_query(query);
        mysql_store_result();
        if(mysql_num_rows())
        if(mysql_fetch_row_format(query,"|"))
        {
            sscanf(query, "p<|>e<is[64]ds[32]s[32]s[32]s[32]s[32]>",Factions[id]);
            Total_Factions_Created++;
        }
    }
    printf("> %d factions have been loaded from the database.", Total_Factions_Created);
    return 1;
}
Commands
pawn Код:
CMD:fcreate(playerid, params[])
{
    new string[128], query[400], fname[32];
    if(sscanf(params, "s[32]", fname))  return SendClientMessage(playerid, -1, "USAGE: /fcreate [factionname]");
    Total_Factions_Created++;
   
    format(Factions[Total_Factions_Created][Name], 64, "%s", fname);
    Factions[Total_Factions_Created][ID] = Total_Factions_Created;
   
    format(string, sizeof(string), "You have created a faction named: %s(ID:%d).",Factions[Total_FactionsCreated][Name], Factions[Total_Factions_Created][ID]);
    SendClientMessage(playerid, -1, string);
   
    format(Factions[Total_Factions_Created][Rank1], 32, "Rank 1 - Lowest");
    format(Factions[Total_Factions_Created][Rank2], 32, "Rank 2");
    format(Factions[Total_Factions_Created][Rank3], 32, "Rank 3");
    format(Factions[Total_Factions_Created][Rank4], 32, "Rank 4");
    format(Factions[Total_Factions_Created][Rank5], 32, "Rank 5");
    format(Factions[Total_Factions_Created][Rank6], 32, "Rank 6 - Leader");
   
    format(query, sizeof(query), "INSERT INTO 'Factions' (ID, Name, Rank1, Rank2, Rank3, Rank4, Rank5, Rank6) VALUES(%d,'%s','%s','%s','%s','%s','%s', '%s')",
   
        Factions[Total_Factions_Created][ID], Factions[Total_Factions_Created][Name],
        Factions[Total_Factions_Created][Rank1], Factions[Total_Factions_Created][Rank2],
        Factions[Total_Factions_Created][Rank3], Factions[Total_Factions_Created][Rank4],
        Factions[Total_Factions_Created][Rank5], Factions[Total_Factions_Created][Rank6]);
       
        mysql_query(query);
       
        return 1;
}

CMD:editfname(playerid, params[])
{
    new string[128], query[400], fname[32], fid;
   
    if(sscanf(params, "ds[32]", fid,fname)) return SendClientMessage(playerid, -1, "USAGE: /editname [factionid] [newfactionname]");
   
    format(Factions[fid][Name], 32, "%s", fname);
   
    format(string, sizeof(string), "You have renamed faction id %d to %s", fid, Factions[fid][Name]);
    SendClientMessage(playerid, -1, string);
   
    format(query, sizeof(query), "UPDATE Factions SET Name = '%s' WHERE ID = %d", Factions[fid][Name],fid);
    mysql_query(query);
   
    return 1;
}

CMD:editrank1(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank1 factionid newrankname");
   
    format(Factions[fid][Rank1], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 1 to %s", fid, Factions[fid][Rank1]);
   
    // UPDATES THE INFORMATION ON THE TABLE
    format(query, sizeof(query), "UPDATE Factions SET Rank1 = '%s' WHERE ID = %d", Factions[fid][Rank1],fid);
    mysql_query(query);
    //======================================
    return 1;
}


CMD:editrank2(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank2 factionid newrankname");

    format(Factions[fid][Rank2], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 2 to %s", fid, Factions[fid][Rank2]);

    // UPDATES THE INFORMATION ON THE TABLE
    format(query, sizeof(query), "UPDATE Factions SET Rank2 = '%s' WHERE ID = %d", Factions[fid][Rank2],fid);
    mysql_query(query);
    //======================================
    return 1;
}

CMD:editrank3(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank3 factionid newrankname");

    format(Factions[fid][Rank3], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 3 to %s", fid, Factions[fid][Rank3]);

    // UPDATES THE INFORMATION ON THE TABLE
    format(query, sizeof(query), "UPDATE Factions SET Rank3 = '%s' WHERE ID = %d", Factions[fid][Rank3],fid);
    mysql_query(query);
    //======================================
    return 1;
}

CMD:editrank4(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank4 factionid newrankname");

    format(Factions[fid][Rank4], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 4 to %s", fid, Factions[fid][Rank4]);

    // UPDATES THE INFORMATION ON THE TABLE
    format(query, sizeof(query), "UPDATE Factions SET Rank4 = '%s' WHERE ID = %d", Factions[fid][Rank4],fid);
    mysql_query(query);
    //======================================
    return 1;
}

CMD:editrank5(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank5 factionid newrankname");

    format(Factions[fid][Rank5], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 5 to %s", fid, Factions[fid][Rank5]);

    // UPDATES THE INFORMATION ON THE TABLE
    format(query, sizeof(query), "UPDATE Factions SET Rank5 = '%s' WHERE ID = %d", Factions[fid][Rank5],fid);
    mysql_query(query);
    //======================================
    return 1;
}

CMD:editrank6(playerid, params[])
{
    new string[128], rname[32], query[400], fid;
    if(sscanf(params, "ds[32]", fid,rname)) return SendClientMessage(playerid, -1, "USAGE: /editrank6 [factionid] [newrankname]");
   
    format(Factions[fid][Rank6], 32, "%s", rname);
    format(string, sizeof(string), "You have set faction ids %d rank 6 to %s", fid, Factions[fid][Rank6]);
   
    format(query, sizeof(query), "UPDATE Factions SET Rank6 = '%s' WHERE ID = %d", Factions[fid][Rank6],fid);
    mysql_query(query);
   
    return 1;
}
Reply
#2

Please show me where are these errors.
Reply
#3

new factions[MAX_FACTIONS]*Everything Else* Line 156
for(new id; id < MAX_FACTIONS; id++) Line 624
mysql_query(query); Line 627
format(string, sizeof(string), "You have created a faction named: %s(ID:%d).",Factions[Total_FactionsCreated][Name], Factions[Total_Factions_Created][ID]); Line 787
mysql_query(query); Line 804
Reply
#4

you haven't bothered to define MAX_FACTIONS. if you do that you should get further.

Also the error about Total_FactionsCreated - that's because on the line where the error is you mistyped it - it should be Total_Factions_Created not Total_FactionsCreated.

Read the compiler output - it usually tells you exactly what the problem is.
Reply
#5

You forgot
pawn Код:
#define MAX_FACTIONS 10 // Max amount of factions you could create/have
new Total_FactionsCreated = 0;
Change :
pawn Код:
format(query, sizeof(query), "SELECT * FROM Factions WHERE ID = %d, id");
To :
pawn Код:
format(query, sizeof(query), "SELECT * FROM Factions WHERE ID = %d", id);
Reply
#6

lol, thanks guys, i'm a newb. Gonna test the code out later on
Reply
#7

Hmm, it seems that
pawn Код:
mysql_query(query)
Is causing the rest of the issues. Am I doing something wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)