SA-MP Forums Archive
doubt (++rep) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: doubt (++rep) (/showthread.php?tid=637747)



doubt (++rep) - Shaheen - 20.07.2017

hai all
i have a doubt
i am currently working with a /myhouses command.
it should actually give a dialog showing the houses owned by the player
so how can i do it ?
i am using mysql r39-2
so i have stuck with this
PHP код:
new query[200],cache:houses;
format(query,sizeof(query),select houseid where owner = %s,getplayername(playerid));
houses=....... 
and how to do the remaining like getting the houseid and saving.
can we do with sscanf ?
i am new with mysql r39..

thanks in advance.


Re: doubt (++rep) - skuller12 - 20.07.2017

Example:
Код:
new Cache: r, houseid, rows, fields;
mysql_format(handle, query, 200, "SELECT * FROM `houses` WHERE `Owner` = '%s'", getplayername(playerid));
r = mysql_query(handle, query);
cache_get_data(rows, fields, handle);
if(rows == 0) cache_delete®, SendClientMessage(playerid, -1, "You don't have a house."), return 1;
cache_get_row_int(0, "ID", houseid);
cache_delete®;



Re: doubt (++rep) - Runn3R - 20.07.2017

Why don't you simply load up the houses owned by player and loop through them looking for playerid's sqlid then format the results into a dialog rather than requesting a result from a database.