06.09.2012, 01:01
Okay, here's a brief summary, my faction system is functional to an extent but is very flimsy. I want a dynamic changeable rank and faction name system that is changeable via the database and via command. Here's my code.
That's about it for code, here's the results.

I'm not sure what the issue is, maybe the conflicting faction IDs.
Here's a SS of how my database works:

pawn Код:
// Here is the faction info Enum
enum factionstats
{
factionid,
factionname[32],
factiontype,
rank10name[32],
rank9name[32],
rank8name[32],
rank7name[32],
rank6name[32],
rank5name[32],
rank4name[32],
rank3name[32],
rank2name[32],
rank1name[32],
factionbank, // Add more info
}
new FVar[MAX_FACTIONS][factionstats];
// -------------------------------
// Here is the on game mode faction loading
public OnGameModeInit()
{
SetGameModeText("SF-RP v0.1b");
AddPlayerClass(1,-2289.6543,211.1139,35.3125, 0,0,0,0,0,0,0);
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
SetWorldTime(Hour);
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
mysql_debug(1);
loadarrowpickups();
loadmaps();
loadfactions();
DisableInteriorEnterExits();
SetTimer("MoneyTimer", 1000, 1);
return 1;
}
// ----------------------------
// Loading the factions from the DB
stock LoadFactionInfo(iFaction)
{
new Query[700];
if(mysql_fetch_row(Query))
{
sscanf(Query, "p<|>e<ds[32]ds[32]s[32]s[32]s[32]s[32]s[32]s[32]s[32]s[32]s[32]d>", FVar[iFaction]);
mysql_free_result();
}
return 1;
}
stock loadfactions()
{
new Query[90], factions;
format(Query, sizeof(Query), "SELECT * FROM `factioninfo`");
mysql_query(Query);
mysql_store_result();
factions = mysql_num_rows();
for(new i = 0; i != factions; i++)
{
LoadFactionInfo(i);
}
print("Factions loaded");
return 1;
}
//-------------------------------
// Displaying the factions code (Debugging command)
// !THIS WORKS!
command(factions, playerid, params[])
{
new str[128];
for(new i = 0; i != MAX_FACTIONS; i++)
{
if(FVar[i][factionid] != 0)
{
format(str, sizeof(str), "%s, (ID %d)", FVar[i][factionname], FVar[i][factionid]);
SendClientMessage(playerid, 0xFFFFFFFF, str);
}
}
return 1;
}
// -------------------
// Faction Chat
command(f, playerid, params[])
{
new str[128], message[128];
if(!sscanf(params, "s[128]", message))
{
if(PVar[playerid][factionID] < 0)
{
SendClientMessage(playerid, 0x66666666, "You are not currently in a faction");
return 1;
}
else
{
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(PVar[i][factionID] == PVar[playerid][factionID])
{
new faction = PVar[playerid][factionID];
new rank = PVar[playerid][factionRank];
new rankdisp[32];
rankdisp = FactionRankToName(faction, rank);
format(str, sizeof(str), "[%s, %s]: %s", rankdisp, RemoveUnderScore(playerid), message);
SendClientMessage(i, 0xFFFFFFFF, str);
}
}
return 1;
}
}
else
{
SendClientMessage(playerid, 0x66666666, "Usage: /f(action) [Message]");
return 1;
}
}

I'm not sure what the issue is, maybe the conflicting faction IDs.
Here's a SS of how my database works:

