17.12.2011, 02:08
pawn Код:
for(new i = 0;i<MAX_ORGS;i++)
I'll rewrite the whole thing for you.
pawn Код:
CMD:orgs(playerid,params[])
{
new orgsid, orgsname[50],lname[30], orgstr[150];
format(query, sizeof(query), "SELECT * FROM orgs"); //This shouldn't be used too often
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 0)
{
mysql_free_result();
return SendClientMessage(playerid, -1, "There are no organisations!");
}
SendClientMessage(playerid, -1, "Organizations:");
while(mysql_retrieve_row())
{
//You can use fetch row and split it as well
mysql_fetch_field_row(orgstr, "orgid"); orgsid = strval(orgstr);
mysql_fetch_field_row(orgsname, "Name");
mysql_fetch_field_row(lname, "Leader");
format(orgstr, sizeof(orgstr), "Organization ID: %d || Organization Name: %s || Organization Leader: %s",orgsid,orgsname,lname);
SendClientMessage(playerid,-1,str);
}
mysql_free_result();
return 1;
}