Posts: 368
Threads: 24
Joined: Feb 2012
Quote:
Originally Posted by vernz
Another question, if I want to know what items I have, is there a better way than that:
PHP Code:
CMD:myitems(playerid, params[])
{
new query[128];
mysql_format(mysql, query, sizeof(query), "SELECT ItemID, ItemQuantity FROM inventory WHERE Userid=%d", PlayerInfo[playerid][pID]);
mysql_tquery(mysql, query, "myitems", "i", playerid);
return 1;
}
forward myitems(playerid);
public myitems(playerid)
{
new itemid, itemquantity;
for(new i, j = cache_get_row_count(mysql); i < j; i++)
{
itemid = cache_get_row_int(i, 0, mysql);
itemquantity = cache_get_row_int(i, 1, mysql);
SendInfoMessage(playerid, "ItemID: %d | ItemQuantity: %d", itemid, itemquantity);
}
return 1;
}
or this is the right way ?
|
you don't need to use mysql_format when you don't escape.
other then that, you don't check for race condition (if player uses the cmd and /q and another player connects with same ID and the callback is executed for him).