16.01.2012, 03:26
That script isn't a great example of loading mass amounts of information. There is a much more efficient way that would take 50x less time to load from the database. There is also no mysql_free_result which could after a while cause issues.
pawn Код:
stock LoadCar() // You might want to make this an public so you could call it on an timer.
{
new Query[255],atext[4],ltext[4], id;
mysql_query("SELECT * FROM vehicles"); // Querys the "Query" Variable.
mysql_store_result(); // Stores the result from Query
while(mysql_retrieve_row())
{
mysql_fetch_row(Query);
sscanf(Query, "p<|>e<iffffiis[25]s[25]iiiiiiiii>",CarInfo[id]);
if(CarInfo[id][cAlarm] == 1) atext="ON";
else atext="OFF";
if(CarInfo[id][cAlarm] == 1) ltext="ON";
else ltext="OFF";
printf("CarInfo: %d Owner:%s, Alarm:%s, Insurance:%d Locked: %s",id,CarInfo[id][cOwner],atext,CarInfo[id][cInsurance],ltext);
id++;
}
mysql_free_result();
return 1;
}