SA-MP Forums Archive
Select one or more from mysql db - 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: Select one or more from mysql db (/showthread.php?tid=660255)



Select one or more from mysql db - ShadowMortar - 28.10.2018

Any example how to make that when I in game write a command /detect ip [ip], and that it searches through mysql database and if finds one or more matching IPs to send client message?


Re: Select one or more from mysql db - v1k1nG - 28.10.2018

Actually we know nothing about your db, so it would be quite hard.


Re: Select one or more from mysql db - ShadowMortar - 28.10.2018

to search through table players and find one or more matching IPs


Re: Select one or more from mysql db - TheToretto - 28.10.2018

Is this what you're looking for?

PHP код:
public OnPlayerConnect(playerid)
{
    new 
query[200]; 
    
mysql_format(Databasequerysizeof query"SELECT * FROM `users` WHERE `IP` = '%e'"PlayerIP[playerid]);  
    
mysql_tquery(Databasequery"MultiAccountCheck""i"playerid);     
    return 
1;
}
forward MultiAccountCheck(playerid); 
public 
MultiAccountCheck(playerid

    new 
string[256];  
    for(new 
icache_num_rows(); i++)
    { 
        if(
cache_num_rows() >= 2)
        {
            
TogglePlayerSpectating(playeridtrue);
            
Dialog_Close(playerid);
            
format(stringsizeof(string), "{FFFFFF}You already have {AA3333}%d accounts{FFFFFF} registred on our database with the actual IP: {AA3333}(%s)"cache_num_rows()-1PlayerIP[playerid]);
            
// KickEx(playerid);
            
Dialog_Show(playeridMULTIACCOUNT_KICKDIALOG_STYLE_MSGBOX"Multi-account detected"string"OK"""); 
        }
    }
    return 
1

This is a snippet from my actual gamemode.


Re: Select one or more from mysql db - ShadowMortar - 28.10.2018

Thanks, +repped that's the example I needed.