SA-MP Forums Archive
Mysql - 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: Mysql (/showthread.php?tid=511738)



Mysql - n00el - 07.05.2014

How can i to retrieve data from mysql?
The player is offline, but i have to know what is his/her faction number.
Among all the registered player show you who they are in no. 1 fraction into a SendClientMessage

A lot of thanks.


Re: Mysql - n00el - 07.05.2014

up pls


Re : Mysql - S4t3K - 07.05.2014

Get all the datas with a for(each) loop, then check if the player's faction corresponds to the faction number you renseigned.
If it does, get the datas of the player with a usual cache_get_field_content(_int/_float)
If it doesn't, simply use "continue;" to skip this value of the number then check the next one.

Good luck.


Re: Mysql - n00el - 07.05.2014

can you give me an example?
Код:
      			for(new i=0; 10000; i++)
    			{ 
        			if(What i put here?)
        			{
						    format(string, sizeof(string), "%s\n",GetRPName(i));
						    strcat(dialogstr,string);
						    Dialog_Show(playerid, PDLeaderAlkalmazott, DIALOG_STYLE_LIST, "Alkalmazottak kezelйse", dialogstr, "Ok", "Mйgsem");
		           	}
				}



Re : Mysql - S4t3K - 07.05.2014

10000 is too much.
MAX_PLAYERS should be 500 if you have the "regular" server package.

The 800 and the 1000 players package are available but it will most likely be useless in your case.

Do like that

PHP код:

for(new 0MAX_PLAYERSi++)
{
   
format(querysizeof(query), "SELECT * FROM `Players` WHERE `uid` = '%d' "PlayerInfo[i][pUID]);
   
mysql_tquery(1query"OnPlayerDataFetched""i"i);
}
forward OnPlayerDataFetched(playerid);
public 
OnPlayerDataFetched(playerid)
{
   new 
fac cache_get_field_content_int(0"FactionNumber");
   if(
fac == FactionNumberYouImpose)
   {
         
// the format and others things go here
   

But show the dialog ONLY at the end of the loop, means OUT of the loop, either it will show as many dialogs as members of the factionto "playerid'

EDIT : Edited, small fail from me, sorry.


Re: Mysql - n00el - 07.05.2014

Its ok for me. But its not good. Its list only the online players who in the faction. I would to list all player (include offline) who in the faction


Re : Mysql - S4t3K - 07.05.2014

Edited, sorry.
I use "uid", which stands for "unique id", because it's the system I use to see, and the system I use.

Use a random at register to create and assign the number to the player, then use it instead of the player's name to do more things than using name.


Re: Mysql - n00el - 07.05.2014

thats it! thanks man! +


Re: Mysql - n00el - 07.05.2014

PHP код:
forward OnPlayerDataFetched(playerid);
public 
OnPlayerDataFetched(playerid)
{
    new 
string[128],dialogstr[3000];
    new 
frakcio cache_get_field_content_int(0,"34");
     if(
frakcio == 1)
       {
        
format(stringsizeof(string), "%s\n",GetRPName(playerid));
           
strcat(dialogstr,string);
           
Dialog_Show(playeridPDLeaderAlkalmazottDIALOG_STYLE_LIST"Alkalmazottak kezelйse"dialogstr"Ok""Mйgsem");
       }

PHP код:
                for(new 0MAX_PLAYERSi++)
                {
                   
format(querysizeof(query), "SELECT * FROM `users` WHERE `id` = '%d' "PlayerInfo[i][pID]);
                   
mysql_tquery(1query"OnPlayerDataFetched""i"i);
                } 
uuhm. its not working :/ what's wrong?


AW: Mysql - Macronix - 07.05.2014

pawn Код:
forward OnPlayerDataFetched(i);
public OnPlayerDataFetched(i)
{
    new string[128],dialogstr[3000];
    new frakcio = cache_get_field_content_int(0,"34");
     if(frakcio == 1)
       {
        format(string, sizeof(string), "%s\n",GetRPName(i));
           strcat(dialogstr,string);
           Dialog_Show(i, PDLeaderAlkalmazott, DIALOG_STYLE_LIST, "Alkalmazottak kezelйse", dialogstr, "Ok", "Mйgsem");
       }