#1

I wanna add
PHP код:
GetPlayerName(playeridnamesizeof(name)); 
in
PHP код:
public OnRconLoginAttempt(ip[], password[], success)
{
    return 
1;

but it's giving errors on playerid



i wanna code it like this:

PHP код:
public OnRconLoginAttempt(ip[], password[], success)
{
   if(
success)
  {
       new 
name[MAX_PLAYER_NAME], string[128];
       
GetPlayerName(playeridnamesizeof(name));
       
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name);
       
SendClientMessageToAll(COLOR_WHITEstring);
       return 
1;
   }

Reply
#2

Take a look at Example Usage here, https://sampwiki.blast.hk/wiki/OnRconLoginAttempt
Reply
#3

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Take a look at Example Usage here, https://sampwiki.blast.hk/wiki/OnRconLoginAttempt
how i can add GetPlayerName if theres no playerid in public OnRconLoginAttempt(ip[], password[], success)
Reply
#4

playerid isn't defined in OnRconLoginAttempt
This is the standard way for getting the player's name:
PHP код:
public OnRconLoginAttempt(ip[], password[], success

       if(
success
    {
        new 
IP[32], name[MAX_PLAYER_NAME], string[128];

        for(new 
ij=GetPlayerPoolSize(); i<ji++)
        {
            
GetPlayerIp(iIPsizeof(IP));
            if(!
strcmp(ipIPfalse))
            {
                
GetPlayerName(inamesizeof(name));

                
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name); 

                break;
            }
        }       
    } 

If you're using foreach, it can be done like so:
PHP код:
public OnRconLoginAttempt(ip[], password[], success

       if(
success
    {
        new 
IP[32], name[MAX_PLAYER_NAME], string[128];

        foreach(new 
Player)
        {
            
GetPlayerIp(iIPsizeof(IP));
            if(!
strcmp(ipIPfalse))
            {
                
GetPlayerName(inamesizeof(name));

                
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name); 

                break;
            }
        }       
    } 

Reply
#5

Quote:
Originally Posted by DeStRoY232
Посмотреть сообщение
how i can getplayername if theres no playerid in public OnRconLoginAttempt(ip[], password[], success)
Using loop, get the player id by matching the ip[] with the player's IP in the loop.
PHP код:
for(new GetPlayerPoolSize(); != -1; --i//Loop through all players
        
{
            
GetPlayerIp(ipipsizeof(pip));
            if(!
strcmp(ippiptrue)) //If a player's IP is the IP that failed the login
            
{
                
SendClientMessage(i0xFFFFFFFF"Wrong Password. Bye!"); //Send a message
                
Ban(i); //They are now banned.
            
}
        } 
^^ As I told you, more information on the usage with example is here, https://sampwiki.blast.hk/wiki/OnRconLoginAttempt
Reply
#6

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
playerid isn't defined in OnRconLoginAttempt
This is the standard way for getting the player's name:
PHP код:
public OnRconLoginAttempt(ip[], password[], success

       if(
success
    {
        new 
IP[32], name[MAX_PLAYER_NAME], string[128];
        for(new 
ij=GetPlayerPoolSize(); i<ji++)
        {
            
GetPlayerIp(iIPsizeof(IP));
            if(!
strcmp(ipIPfalse))
            {
                
GetPlayerName(inamesizeof(name));
                
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name); 
                break;
            }
        }       
    } 

If you're using foreach, it can be done like so:
PHP код:
public OnRconLoginAttempt(ip[], password[], success

       if(
success
    {
        new 
IP[32], name[MAX_PLAYER_NAME], string[128];
        foreach(new 
Player)
        {
            
GetPlayerIp(iIPsizeof(IP));
            if(!
strcmp(ipIPfalse))
            {
                
GetPlayerName(inamesizeof(name));
                
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name); 
                break;
            }
        }       
    } 

it got compiled but not working ig
Reply
#7

Quote:
Originally Posted by DeStRoY232
Посмотреть сообщение
it got compiled but not working ig
Because he forgot to add this here.
PHP код:
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name);
SendClientMessage(i, -1string); //This 
Reply
#8

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Because he forgot to add this here.
PHP код:
format(stringsizeof(string), "{FF6600}%s {FFFFFF} has logged in as RCON Administrator"name);
SendClientMessage(i, -1string); //This 
LOL thanks man i'm just started learning scripting xD thx for the help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)