09.01.2019, 13:36
Hello everyone, so basically i have a problem with this faction system in sampdb (non sqlite):
Seems to not work. Or to be more precise, works at 50%.
When i create a faction, its assigned ID is 1, but when i create another one it's again 1 (should be 2), and gets replaced the first faction i created.
Also sometimes doesn't even create anything.
pawn Код:
CMD:fcreate(playerid,params[])
{
new query[115], DBResult: result, string[128];
if(isnull(params)) return SendClientMessage(playerid, -1, "{3498db}* [USAGE]: {FFFFFF} /fcreate [faction name]");
if(!strcmp(params,"INVALID",true)) return SendClientMessage(playerid, COLOR_LIGHTRED, "* Chosen faction name is invalid.");
format(query,sizeof(query),"SELECT FactionName FROM Factions WHERE FactionName = '%q'",params);
result = db_query(Database, query);
if(db_num_rows(result))
{
db_free_result(result);
return SendClientMessage(playerid, COLOR_LIGHTRED, "* This faction name already has been taken.");
}
db_free_result(result);
ShowPlayerDialog(playerid,DIALOG_FACTION_COLOR,DIALOG_STYLE_LIST,"Faction Color",""BLUE"Blue\n"RED"RED\n"WHITE"White\n"PINK"Pink\n"CYAN"Cyan\n"ORANGE"Orange\n"GREEN"Green\n"YELLOW"Yellow","Select","Cancel");
new Query[217];
format( Query, sizeof(Query), "INSERT INTO Factions (FactionName,FactionColor) VALUES ('%q','%q')", FactionInfo[playerid][factionname],FactionInfo[playerid][factioncolor]);
db_query(Database,Query);
result = db_query(Database, "SELECT last_insert_rowid()");
FactionInfo[playerid][factionid] = db_get_field_int(result);
db_free_result(result);
SendClientMessage(playerid, COLOR_YELLOW, "* You have sucessfully created a faction!");
format(string,sizeof(string),""GREEN"%s "WHITE"has created a new faction named "GREEN"%s!"WHITE"",FactionInfo[playerid][username],FactionInfo[playerid][factionname]);
SendClientMessageToAll(-1,string);
return 1;
}
When i create a faction, its assigned ID is 1, but when i create another one it's again 1 (should be 2), and gets replaced the first faction i created.
Also sometimes doesn't even create anything.