If playername is not then.... -
Nicky_Newsted - 23.03.2012
Okay, so now I'm busy making some script that automaticly bans on wrong RCON passwords (actually copied from SAMP Wiki), but ofcourse I don't want myself being banned if I type it in wrong so what to make up a line/code that gets playerid's name and checks it, if it's not some of those names it will go through the next step, sending a line and ban the user.
I have this code right now but it's not working, giving some errors:
pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success) //If the password was incorrect
{
if(GetPlayerName(playerid, "Nicky_Newsted, [TCL]Nicky"));
{
SendClientMessage(playerid, COLOR_RED, "Wrong password!!");
}
else
printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
new pip[16];
for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
{
GetPlayerIp(i, pip, sizeof(pip));
if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
{
// SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
SendClientMessage(i, COLOR_RED, "You have tried to login at RCON but you don't have the");
SendClientMessage(i, COLOR_RED, "password. You have been banned for trying");
SendClientMessage(i, COLOR_RED, "to hack using RCON");
Ban(i); //They are now banned.
}
}
}
return 1;
}
Код:
D:\Games\Valve\Steam\SteamApps\common\grand theft auto san andreas\SAMP Server\gamemodes\nhendriksgm.pwn(524) : error 017: undefined symbol "playerid"
D:\Games\Valve\Steam\SteamApps\common\grand theft auto san andreas\SAMP Server\gamemodes\nhendriksgm.pwn(524) : error 036: empty statement
D:\Games\Valve\Steam\SteamApps\common\grand theft auto san andreas\SAMP Server\gamemodes\nhendriksgm.pwn(526) : error 017: undefined symbol "playerid"
D:\Games\Valve\Steam\SteamApps\common\grand theft auto san andreas\SAMP Server\gamemodes\nhendriksgm.pwn(528) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
In this script line 524 is the GetPlayerName-line.
I hope somebody could help me with this. I just started to learn Pawn this week and I was wondering, and later on might help if I as admin have multiple names, i.e. hidden admin or something.
Cheers
Re: If playername is not -
new121 - 23.03.2012
try this
PHP код:
name[24], pname;
pname = GetPlayerName(playerid, name, sizeof(name));
if(pname == desired name here || pname == other desired name here)
{
// your code here
}
Oh and if you change your ban code to
BanEx(i, "reason"); This will savethe reason they were banned to the ban log
Re: If playername is not then.... -
Nicky_Newsted - 23.03.2012
Mmm, your script isn't working either

It says that the names aren't found (undefined symbol), and something about assumed 0..

And as well again 'undefined symbol' on 'playerid' in GetPlayerName :S
Re: If playername is not then.... -
Skribblez - 23.03.2012
you can't get the name of the player if he logs in using RCON, so alternatively, you can check through the ip.
try this: (
it compiles without errors or warnings but i haven't TESTED it yet)
pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
if(strcmp(ip, "YOUR IP HERE", true))
{
printf("Wrong password!!");
}
}
else
{
printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
new pip[16];
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerIp(i, pip, sizeof(pip));
if(!strcmp(ip, pip, true))
{
SendClientMessage(i, COLOR_RED, "You have tried to login at RCON but you don't have the");
SendClientMessage(i, COLOR_RED, "password. You have been banned for trying");
SendClientMessage(i, COLOR_RED, "to hack using RCON");
Ban(i);
}
}
}
return 1;
}
Re: If playername is not then.... -
new121 - 23.03.2012
edit nvm try what the guy above me said
Re: If playername is not then.... -
[KHK]Khalid - 23.03.2012
dump
Re: If playername is not then.... -
Skribblez - 23.03.2012
Quote:
Originally Posted by HellSphinX
i think this should be fine
pawn Код:
public OnRconLoginAttempt(ip[], password[], success) { if(!success) //If the password was incorrect { for(new i=0; i<MAX_PLAYERS; i++) { if(GetPlayerName(i, "Nicky_Newsted, [TCL]Nicky")); { SendClientMessage(i, COLOR_RED, "Wrong password!!"); } } else { printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password); new pip[16]; for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players { GetPlayerIp(i, pip, sizeof(pip)); if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login { SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message SendClientMessage(i, COLOR_RED, "You have tried to login at RCON but you don't have the"); SendClientMessage(i, COLOR_RED, "password. You have been banned for trying"); SendClientMessage(i, COLOR_RED, "to hack using RCON"); Ban(i); //They are now banned. } } } } return 1; }
|
that would return errors, the script will not compile.
Re: If playername is not then.... -
Jonny5 - 23.03.2012
omg GetPlayerName(i, "Nicky_Newsted, [TCL]Nicky") cannot be used like that!!
this is to get the user
i's name.
use a new string[MAX_PLAYER_NAME]; and strcmp!
also you need to provide the string length.
https://sampwiki.blast.hk/wiki/GetPlayerName
Re: If playername is not then.... -
Skribblez - 23.03.2012
try this:
pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new playername[24];
GetPlayerName(i, playername, sizeof(playername));
if(strcmp(playername, "Nicky_Newsted", true) == 13 || strcmp(playername, "[TCL]Nicky", true) == 10)
{
SendClientMessage(i, COLOR_RED, "Wrong password!!");
}
}
}
else
{
printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s", ip, password);
new pip[16];
for(new i=0; i<MAX_PLAYERS; i++)
{
GetPlayerIp(i, pip, sizeof(pip));
if(!strcmp(ip, pip, true))
{
SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!");
SendClientMessage(i, COLOR_RED, "You have tried to login at RCON but you don't have the");
SendClientMessage(i, COLOR_RED, "password. You have been banned for trying");
SendClientMessage(i, COLOR_RED, "to hack using RCON");
Ban(i);
}
}
}
return 1;
}
Re: If playername is not then.... -
Nicky_Newsted - 23.03.2012
The one which gets the IP worked for me and using that. And yeah I I was at school and thought about it, nobody is executing this script so thats why playerid wouldn't work.
And is there a possibility to get the playername of the failing person into the RCON Screen?