26.06.2014, 10:08
Ok, so I have dynamic factions on this script but the ranks and stuff won't save for some reason after server restart.
There is a /saveall command that saves all the dynamic stuff... but I went and looked at the SaveFactions part in the .pwn and realize it wasn't saving to any .ini in the script file.
That's what it looks like in the script. How could I change this to make it save to a .ini so it doesn't reset after a server restart.
There is a /saveall command that saves all the dynamic stuff... but I went and looked at the SaveFactions part in the .pwn and realize it wasn't saving to any .ini in the script file.
Код:
SaveFactions() { new var[48], query[1024]; for (new i = 1; i < MAX_FACTIONS + 1; i ++) { if (FactionTaken[i]) { format(query, sizeof(query), "UPDATE `Factions` SET `FactionName` = '%s', `FactionLeader` = '%s', `FactionMembers` = '%d', `FactionType` = '%d' WHERE `FactionID` = '%d'", FactionName[i], FactionLeader[i], FactionMembers[i], FactionInfo[i][FactionType], i); db_query(ServerDB, query); format(query, sizeof(query), "UPDATE `Factions` SET "); for (new r = 1; r < MAX_RANKS + 1; r ++) { format(var, sizeof(var), "`FactionRank%d` = '%s', ", r, FactionRank[i][r]); strcat(query, var); } for (new r = 1; r < MAX_RANKS + 1; r ++) { if (r == MAX_RANKS) { format(var, sizeof(var), "`FactionPay%d` = '%d'", r, FactionPay[i][r]); } else format(var, sizeof(var), "`FactionPay%d` = '%d', ", r, FactionPay[i][r]); strcat(query, var); } format(var, sizeof(var), " WHERE `FactionID` = '%d'", i); strcat(query, var); db_query(ServerDB, query); format(query, sizeof(query), "UPDATE `Factions` SET `MaximumSkins` = '%d', `FactionSkin0` = '%d', `FactionSkin1` = '%d', `FactionSkin2` = '%d', `FactionSkin3` = '%d', `FactionSkin4` = '%d', `FactionSkin5` = '%d', `FactionSkin6` = '%d', `FactionSkin7` = '%d', `FactionSkin8` = '%d', `FactionSkin9` = '%d', `FactionSkin10` = '%d', `FactionSkin11` = '%d', `FactionSkin12` = '%d', `FactionColor` = '%d', `FactionDivisions` = '%d' WHERE `FactionID` = '%d'", FactionInfo[i][MaximumSkins], FactionInfo[i][FactionSkins][0], FactionInfo[i][FactionSkins][1], FactionInfo[i][FactionSkins][2], FactionInfo[i][FactionSkins][3], FactionInfo[i][FactionSkins][4], FactionInfo[i][FactionSkins][5], FactionInfo[i][FactionSkins][6], FactionInfo[i][FactionSkins][7], FactionInfo[i][FactionSkins][8], FactionInfo[i][FactionSkins][9], FactionInfo[i][FactionSkins][10], FactionInfo[i][FactionSkins][11], FactionInfo[i][FactionSkins][12], FactionInfo[i][FactionColor], FactionInfo[i][FactionDivisions], i ); db_query(ServerDB, query); format(query, sizeof(query), "UPDATE `Factions` SET `EvidenceDrugs1` = '%d', `EvidenceDrugs2` = '%d', `EvidenceDrugs3` = '%d', `EvidenceDrugs4` = '%d', `EvidenceDrugs5` = '%d' WHERE `FactionID` = '%d'", EvidenceDrugs[i][0], EvidenceDrugs[i][1], EvidenceDrugs[i][2], EvidenceDrugs[i][3], EvidenceDrugs[i][4], i ); db_query(ServerDB, query); } } return 1; } LoadFactions() { new query[128], DBResult:result, field[128], var[32] ; for (new i = 1; i < MAX_FACTIONS + 1; i ++) { format(query, sizeof(query), "SELECT * FROM `Factions` WHERE `FactionID` = '%d'", i); result = db_query(ServerDB, query); if (db_num_rows(result) != 0) { db_get_field_assoc(result, "FactionName", field, sizeof(field)); format(FactionName[i], 64, field); db_get_field_assoc(result, "FactionLeader", field, sizeof(field)); format(FactionLeader[i], 24, field); db_get_field_assoc(result, "FactionMembers", field, sizeof(field)); FactionMembers[i] = strval(field); db_get_field_assoc(result, "FactionType", field, sizeof(field)); FactionInfo[i][FactionType] = strval(field); for (new r = 1; r < MAX_RANKS + 1; r ++) { format(var, sizeof(var), "FactionRank%d", r); db_get_field_assoc(result, var, field, sizeof(field)); format(FactionRank[i][r], 64, field); format(var, sizeof(var), "FactionPay%d", r); db_get_field_assoc(result, var, field, sizeof(field)); FactionPay[i][r] = strval(field); } db_get_field_assoc(result, "MaximumSkins", field, sizeof(field)); FactionInfo[i][MaximumSkins] = strval(field); for (new s = 0; s < 13; s ++) { format(var, sizeof(var), "FactionSkin%d", s); db_get_field_assoc(result, var, field, sizeof(field)); FactionInfo[i][FactionSkins][s] = strval(field); } db_get_field_assoc(result, "FactionColor", field, sizeof(field)); FactionInfo[i][FactionColor] = strval(field); db_get_field_assoc(result, "FactionDivisions", field, sizeof(field)); FactionInfo[i][FactionDivisions] = strval(field); for (new e = 0; e < 5; e ++) { format(var, sizeof(var), "EvidenceDrugs%d", e); db_get_field_assoc(result, var, field, sizeof(field)); EvidenceDrugs[i][e] = strval(field); } FactionTaken[i] = 1; } db_free_result(result); } return 1; } }