[HELP] How show data of table sql in server? - 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: [HELP] How show data of table sql in server? (
/showthread.php?tid=523992)
[HELP] How show data of table sql in server? -
iryston - 04.07.2014
I tried but it went wrong. if someone can help me, thank you!
Example, i have a list of admins in my db, and i want show in the server on /listadmins
Re : [HELP] How show data of table sql in server? -
S4t3K - 04.07.2014
Are you sure to know how to use MySQL ? (or just SQL, it's the BASICS of the language)
Use a SELECT query, use cache_num_rows as a maximum to your for loop then display the player names you would have gotten from the SELECT query using cache_get_field_content or cache_get_row using your loop variable as row index.
Re: [HELP] How show data of table sql in server? -
iryston - 04.07.2014
So. Firstly thank you for being here.
Well, sorry, MySQL
in my attempts the most I could get was, showing the amount of admins who was in the table. The name, with level etc.. not returned. did not show. i used SendClientMessage, Printf to show but, dont works..
sorry my english
Re : [HELP] How show data of table sql in server? -
S4t3K - 04.07.2014
Your english is good enough to be understood.
Try this way
PHP код:
// In your command
mysql_tquery(yourHandle, "SELECT `name`, `admin` FROM `Players` WHERE `admin` >= 1", "OnAdminsFound_", "i", playerid); // here, playerid = the id of the player who has launched the command
// At the bottom of your script
forward OnAdminsFound_(playerid);
public OnAdminsFound_(playerid)
{
new name[MAX_PLAYER_NAME+1], rank, string[145];
for(new i = 0; i < cache_num_rows(); i++)
{
cache_get_row(0, 0, name);
rank = cache_get_row_int(0, 1);
format(string, sizeof(string), "Admin name : %s | Admin level : %d", name, rank);
SendClientMessage(playerid, -1, string);
}
return 1;
}
Re: [HELP] How show data of table sql in server? -
iryston - 05.07.2014
I got it! now worked
Thank you so much!
++REP