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



HELP! - DeStRoY232 - 19.09.2017

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;
   }




Re: HELP! - StrikerZ - 19.09.2017

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


Re: HELP! - DeStRoY232 - 19.09.2017

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)


Re: HELP! - Eoussama - 19.09.2017

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;
            }
        }       
    } 




Re: HELP! - StrikerZ - 19.09.2017

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


Re: HELP! - DeStRoY232 - 19.09.2017

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


Re: HELP! - StrikerZ - 19.09.2017

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 



Re: HELP! - DeStRoY232 - 19.09.2017

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