Undefined Symbol " playerid "
#1

And yes. I got this error and I have to fix it. Because I'm using it for an important thing.
Do anyone have any idea? For to how to define playerid.
PHP код:
public OnRconLoginAttempt(ip[], password[], success

            if(
success == 1) {
            new 
Name[32], string[128];
            
GetPlayerName(playeridNamesizeof Name); 
            
format(stringsizeof string" %s | %s | %s",Name(playerid), ipsuccess); 
             
fwrite("rcons.txt"string)
          } 
        else 
         { 
          if(
success == 0
          { 
          
Ban(playerid); 
          } 
}
return 
1;

Reply
#2

https://sampwiki.blast.hk/wiki/OnRconLoginAttempt

Check the example they show.
playerid isn't available in OnRconLoginAttempt, which is why you'll have to use a loop to check which player IP matches the IP that attempted to login.
Reply
#3

Since OnRconLoginAttempt doesn't have a playerid parameter, you will have to loop through all online players and compare their ip to the given ip.

Код:
public OnRconLoginAttempt(ip[], password[], success)  
{  
	new playerip[15 + 1];
	for(new playerid = 0, highestPlayerid = GetPlayerPoolSize(); playerid <= highestPlayerid; playerid++) {
		if(IsPlayerConnected(otherplayerid) && !IsPlayerNPC(playerid)) {
		    GetPlayerIp(playerid, playerip, sizeof(playerip));
		    if(!strcmp(ip, playerip, true)) { //If a player's IP is the IP that did the login
		    	if(success) {
		    		//Successful login
			} else {
		    		//Unsuccessful login
			}
			break;
		    }
		}
	}
	return 1; 
}
EDIT:
Stinged was faster.
Reply
#4

So there is no way to get the player name who tried to login to RCON?
Reply
#5

Yes there is, with the code above or in https://sampwiki.blast.hk/wiki/OnRconLoginAttempt.
See this part of my code:
Код:
if(!strcmp(ip, playerip, true)) {
}
Within those brackets, thats the player that did the login. Just use 'playerid' in there.
Reply
#6

Alright, Thank you for the code and explaination. I have given rep to both of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)