Faction, MySQL
#1

pawn Код:
CMD:factions(playerid, params[])
{
    new string[128];
    for(new i=0;i<MAX_FACTIONS;i++)
    {
        if(strlen(fInfo[i][fName]) == 0) continue;
        format(string, sizeof(string), "MySQL ID: %d (ID: %d) "#DIALOG_GREEN#" %s", fInfo[i][fID], i, fInfo[i][fName]);
        SCM(playerid, -1, string);
    }
    return 1;
}

CMD:deletefaction(playerid, params[])
{  
    new facID, szQuery[128];
    if(sscanf(params, "d", facID)) return SCM(playerid, -1, "Usage: /deletefaction <faction ID>");
    format(szQuery, sizeof(szQuery), "DELETE FROM `factions` WHERE `fID` = %d", fInfo[facID][fID]);
    mysql_pquery(dbHandle, szQuery);
    format(fInfo[facID][fName], 0, "");
    fInfo[facID][fID] = 0;
   
    LoadFactions();
    return 1;
}
When I delete a faction it is removed from the MySQL database, it's still listed IG via /factions however, how do I fix this?
Reply
#2

Most likely due to the fact that you're executing concurrent queries (DELETE vs the SELECT in the LoadFactions function) resulting in a race condition. Create a callback for the DELETE query and execute the reset procedure and the LoadFactions in there. This way you'll be sure that the query has been completed.
Reply
#3

pawn Код:
forward thread_DeleteFaction(facID);
public thread_DeleteFaction(facID)
{
    format(fInfo[facID][fName], 0, "");
    LoadFactions();
    return 1;
}
I added that, still not working. Again, the faction is removed from the MySQL database, but not IG when you use /factions. It's probably something simple, I got back into MySQL today.
Reply
#4

Look at the query, be sure that it takes an existing variable to save in an existing column
Reply
#5

Hmm? The MySQL part works, it's just messing up in game.
Reply
#6

Ah, my fault.

What's wrong ? Can you still be in the faction/using the faction's commands after deleting it ?
Or is the faction still remaining on the list but nobody can use faction's features ?
Reply
#7

Yes you can still use the commands. It exists IG, not in the MySQL DB though.
Reply
#8

When you use the commands, do you check the database or the stats ?

If you check the stats, be sure that they update enough often

If you use the database (a mysql_get_field or the macro), don't know ;3
Reply
#9

Okay, I almost solved the problem.

Say I have three factions, and I delete the number 2, number 3 takes its place but also keeps the third slot, why? Remember that this is all visual IG, nothing is wrong with the tables or the database.
Код:
Faction 1
Faction 2 - Delete this
Faction 3

Ends up looking like this.

Faction 1
Faction 3
Faction 3
Read the original post for the /factions and /deletefaction command.

EDIT:
Added
pawn Код:
for(new i=0;i<MAX_FACTIONS;i++)
    {
        strdel(fInfo[i][fName], 0, 65);
    }
before loading, now I have to type /deletefaction <faction id> twice to delete a faction, then after I have deleted one faction I can continue deleting with /deletefaction, not needing to use it twice. :S
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)