09.09.2014, 08:14
So, I've created an faction system, but for some reason I get this error.
If I change it to just do "while..." without checking the db, then "CreateFaction" stock doesn't work(in-game errors, stuff like "Couldn't create faction")
and
If I change it to just do "while..." without checking the db, then "CreateFaction" stock doesn't work(in-game errors, stuff like "Couldn't create faction")
pawn Код:
stock FindNextSlot()
{
new id, Query[100], DBResult:result;
format(Query, sizeof(Query), "SELECT `ACTIVE` FROM `FACTIONS` WHERE `ID` = '%d'", id);
result = db_query(Factions, Query);
if(result)
{
do
{
new Field[70];
db_get_field_assoc(result, "ACTIVE", Field, sizeof(Field));
}
while(FactionInfo[id][Active]) id ++; //error line
}
db_free_result(result);
return id;
}
pawn Код:
stock CreateFaction(ownerid, name[])
{
new DBResult:result, Query[360], factID = FindNextSlot();
format(Query, sizeof(Query), "INSERT INTO `FACTIONS` (`ID`, `NAME`, `LOCKED`, `ACTIVE`, `MAXMEMBERS`, `MEMBERS`, `LEADER`, `HASLEADER`, `RANK1`, `RANK2`, `RANK3`, `RANK4`, `RANK5`) VALUES ('%d', '%s', '1', '1', '10', '1', '%s', '1', 'Trial Member', 'Member', 'Senior Member', 'Assistant', 'Leader')", factID, DB_Escape(name), DB_Escape(GetName(ownerid)));
result = db_query(Factions, Query);
if(result) SendClientMessage(ownerid, -1, "{64CC66}Faction successfully created!"), SendClientMessage(ownerid, -1, "{64CC66}You can use '/settings' to edit the faction info!");
else SendClientMessage(ownerid, -1, "{FC4949}Failed to create faction, contact server owner(s).");
db_free_result(result);
}