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



OnRconLoginAttempt. - ivndosos - 07.03.2018

Why wouldn't it set me level for?

Код:
	   if(success)
	   {
		   	for(new i = 0, j=GetPlayerPoolSize(); i<=j; i++)
		   	{
			  	pInfo[i][Admin] = 4;
			  	new str[128];
			  	format(str, sizeof(str),"{FF0000}(INFO) %s has logged into RCON", PlayerName[i]);
			  	SendMessageToAdmins(str);
		   	}
		}
    }
    return 1;
}



Re: OnRconLoginAttempt. - RedFusion - 07.03.2018

You're looping through playerid 0 to the max playerid connected. Some of the players inbetween those id's could be disconnected. You need to check if they're connected.

You also need to check if that player has the same IP adress as the player attempting to login. Otherwise you will end up promoting every player connected to admin.


Re: OnRconLoginAttempt. - BulletRaja - 07.03.2018

PHP код:
if(success)
       {
               for(new 
p=0;p<MAX_PLAYERS;p++) 
               {
                  new 
name[24], string[120];
                                
GetPlayerName(p,name,24);
                  
format(stringsizeof(string),"{FF0000}(INFO) %s has logged into RCON"name);
                  
SendMessageToAdmins(string);
                                
pInfo[p][Admin] = 4;
               }
        }
    }
    return 
1;

try this


Re: OnRconLoginAttempt. - ivndosos - 07.03.2018

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
You're looping through playerid 0 to the max playerid connected. Some of the players inbetween those id's could be disconnected. You need to check if they're connected.

You also need to check if that player has the same IP adress as the player attempting to login. Otherwise you will end up promoting every player connected to admin.
Mind giving an example?


Re: OnRconLoginAttempt. - RedFusion - 07.03.2018

pawn Код:
public OnRconLoginAttempt(ip[], password[], success) {
    if( success ) {
        new player_ip[15+1], message_str[100];
        for(new playerid, max_playerid = GetPlayerPoolSize(); playerid <= max_playerid; playerid ++) {
            if( !IsPlayerConnected(playerid) ) {
                continue;
            }

            GetPlayerIp(playerid, player_ip, sizeof player_ip);
            if( !strcmp( player_ip, ip) ) {
                pInfo[playerid][Admin] = 4;
                format(message_str, sizeof message_str,"{FF0000}(INFO) %s has logged into RCON", PlayerName[playerid]);
                SendMessageToAdmins(message_str);
            }    
        }
    }
}



Re: OnRconLoginAttempt. - ivndosos - 07.03.2018

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
public OnRconLoginAttempt(ip[], password[], success) {
    if( success ) {
        new player_ip[15+1], message_str[100];
        for(new playerid, max_playerid = GetPlayerPoolSize(); playerid <= max_playerid; playerid ++) {
            if( !IsPlayerConnected(playerid) ) {
                continue;
            }

            GetPlayerIp(playerid, player_ip, sizeof player_ip);
            if( !strcmp( player_ip, ip) ) {
                pInfo[playerid][Admin] = 4;
                format(message_str, sizeof message_str,"{FF0000}(INFO) %s has logged into RCON", PlayerName[playerid]);
                SendMessageToAdmins(message_str);
            }    
        }
    }
}
Okay, I've done this.

Little bit edited

Код:
	if(success)
	{
		new aip[15+1], str[120];
		for(new playerid, max_playerid = GetPlayerPoolSize(); playerid <= max_playerid; playerid ++)
		{
		   if(!IsPlayerConnected(playerid))
		   {
			   continue;
		   }
			   GetPlayerIp(playerid, aip, sizeof(aip));
			   if(!strcmp( aip, ip))
			   pInfo[playerid][Admin] = 4;
			   format(str, sizeof(str), "{FF0000}(INFO) %s has successfully logged into RCON!", PlayerName[playerid]);
			   SendClientMessage(playerid, -1, str);
	    }
	}
	return 1;
}
But there's a really big problem, I've connected with an unregistered account and spawned and I had my existing user stats (including, score,adminlevel, points).


Re: OnRconLoginAttempt. - RedFusion - 07.03.2018

You need to reset those stats either at connect or disconnect.
I prefer to initiate player variables at connect.