20.08.2014, 12:23
Hi guys well, i trying to select only the rows that have the users, userid on them to give the player his weapons that were saved. I am using MySQL R5. Heres what ive tried:
I tried this, but it doesnt seem to work at all. Can anyone tell me whats the problem? Thank you.
pawn Код:
public OnLoadPlayerWeapons(playerid)
{
new
weaponid,
MySQLQuery[100],
temp[50],
row[4000],
query[300],
ammo;
format(MySQLQuery, sizeof(MySQLQuery), "SELECT * FROM ginklai WHERE userid = '%d'", GetPVarInt(playerid, "AccID"));
mysql_query(MySQLQuery);
mysql_store_result();
new queryResult = mysql_query(MySQLQuery);
if (!queryResult) {
printf("Query failed, errno %d", mysql_errno());
} else {
print("Apparently query succeeded");
}
while(mysql_fetch_row_format(MySQLQuery, "|"))
{
mysql_fetch_field_row(temp, "weaponid"); weaponid = strval(temp);
mysql_fetch_field_row(temp, "Ammo"); ammo = strval(temp);
GivePlayerWeapon(playerid, weaponid, ammo);
}
// }
mysql_free_result();
/* if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)
{
printf("[info] Warning: OnLoadPlayerWeapons - Unknown weaponid '%d'. Skipping.", weaponid);
continue;
}*/
// GivePlayerWeapon(playerid, weaponid, ammo);
// }
return;
}

