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



script help - GeneralAref - 09.10.2016

hi.i have a database and table and it has id , ip , aka , how can i get all rows with same ip with easy-mysql and then get aka?


Re: script help - ChristolisTV - 09.10.2016

We can help more if you show us code.


Re: script help - GeneralAref - 09.10.2016

is it true?
Код:
if(SQL::RowExistsEx("mrp_aka","ip",PlayerIp(playerid)))
    {
        while(handle=SQL::OpenEx(SQL::READ,"mrp_aka","ip",PlayerName(playerid)))
		{
		    new str[256];SQL::ReadString(handle,"ip",str);print(str);
		}
	}



Re: script help - azzerking - 09.10.2016

Sorry, can I ask what MYSQL plugin you are you using?

I don't recognize the plugin you are using.


Re: script help - GeneralAref - 09.10.2016

R6 of this https://sampforum.blast.hk/showthread.php?tid=56564
and this include https://sampforum.blast.hk/showthread.php?tid=606930


Re: script help - iLearner - 09.10.2016

i got this in my script:

PHP код:
public recentlyUsedNicks(playerid)
{
    new 
query[200], ip[16], pName[24],pName1[10][24], playerName[24];
    
GetPlayerIp(playeridipsizeof(ip));
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    
mysql_format(1querysizeof(query),"SELECT playerName FROM `playerdata` WHERE `playerIP`='%s' LIMIT 10"ip);
    new 
Cache:cacheid mysql_query(1query);
    new 
rows cache_num_rows(); 
    new 
string[128];//, string1[128];
    
if(rows 1)
    {
        
format(stringsizeof(string),"Player %s has previously connected with following %d names:"playerNamerows);
    
//    adminchat(COLOR_GREEN, string);

        
for(new 0rowsi++)
        {
            
cache_get_field_content(i"playerName"pName150);
            
pName1[i] = pName;
            
format(stringsizeof(string),"%s \n%s",stringpName1[i]);
        }
        
adminchat(COLOR_GREENstring);
        
IRC_GroupSay(gGroupIDIRC_CHANNELstring);

    }
    
cache_delete(cacheid);

and call the function once player has logged in.


Re: script help - GeneralAref - 09.10.2016

is it working?


Re: script help - iLearner - 09.10.2016

obv (lol).

remember to replace the tables names etc


Re: script help - Konstantinos - 09.10.2016

That's R33+ version of the plugin.

Can you post the table's structure for "mrp_aka" table? I can only write an example of it with the normal way (without the use of that include) if you want to and are there any duplicates (same ip and aka in more than one row) in the table?


Re: script help - azzerking - 09.10.2016

I don't know why I decided to do this, other then the fact I hate messing code. But I fixed up your code for your recentlyUsedNicks( playerid ) function.

Код:
public recentlyUsedNicks(playerid)
{
    static 
    	query[ 84 ], 
    	ip[ 16 ], 
    	pName[ 24 ], 
    	playerName[ 24 ]
    ;

    GetPlayerIp( playerid, ip, sizeof( ip ) );
    GetPlayerName( playerid, playerName, sizeof( playerName ) );

    mysql_format( 1, query, sizeof( query ),"SELECT `playerName` FROM `playerdata` WHERE `playerIP` = '%s' LIMIT 10", ip );

    new 
    	Cache:cacheid = mysql_query( 1, query ),
    	rows = cache_num_rows(),
    	string[ 256 ]
    ;

    if( rows )
    {
        format( string, sizeof( string ),"Player %s has previously connected with following %d names:", playerName, rows );

        for( new i = 0; i < rows; i++ )
        {
            cache_get_field_content( i, "playerName", pName, 1, sizeof( pName ) );
            format( string, sizeof( string ),"%s\n%s", string, pName );
        }

        adminchat( COLOR_GREEN, string );
        IRC_GroupSay( gGroupID, IRC_CHANNEL, string );
    }

    cache_delete(cacheid); // Your deleting the cache right after saving it? This makes it pointless to cache
}
However as long as you code works in other places with the same setup, it should work here.