01.07.2012, 15:47
pawn Код:
forward LoadFactions();
public LoadFactions()
{
new
Query[300],
string[128],
FactionCount;
mysql_query("SELECT * FROM Factions");
mysql_store_result();
new i = 0;
while(mysql_fetch_row_format(Query, "|"))
{
sscanf(Query, "e<p<|>is[128]s[128]dfff>", FInfo[i]);
format(string,sizeof(string),"Faction Name: %s \nOwned by: %s\nFaction Value: %d", FInfo[i][Name], FInfo[i][Owner], FInfo[i][Value]);
CreateDynamicPickup(1239, 1, FInfo[i][LocationX], FInfo[i][LocationY], FInfo[i][LocationZ], -1, -1, -1, 100.0);
CreateDynamic3DTextLabel(string, COLOR_RED, FInfo[i][LocationX], FInfo[i][LocationY], FInfo[i][LocationZ], 100.0);
FactionCount++;
i++;
}
mysql_free_result();
return FactionCount;
}
pawn Код:
forward SaveFactions();
public SaveFactions()
{
new query[1024];
for(new i = 0; i < FactionCount; i++)
{
format(query, sizeof(query), "UPDATE Factions SET \
Name = '%s',\
Owner = '%s',\
Value = '%d',\
LocationX = '%f',\
LocationY = '%f',\
LocationZ = '%f'\
WHERE FactionID = '%i'",
FInfo[i][Name],
FInfo[i][Owner],
FInfo[i][Value],
FInfo[i][LocationX],
FInfo[i][LocationY],
FInfo[i][LocationZ],
FInfo[i][FactionID]);
mysql_query(query);
}
}
pawn Код:
forward SaveFaction(i);
public SaveFaction(i)
{
new query[1024];
format(query, sizeof(query), "UPDATE Factions SET \
Name = '%s',\
Owner = '%s',\
Value = '%d',\
LocationX = '%f',\
LocationY = '%f',\
LocationZ = '%f'\
WHERE FactionID = '%i'",
FInfo[i][Name],
FInfo[i][Owner],
FInfo[i][Value],
FInfo[i][LocationX],
FInfo[i][LocationY],
FInfo[i][LocationZ],
FInfo[i][FactionID]);
mysql_query(query);
}