PDA

View Full Version : ID Bug Again.


Laure
05/06/2014, 04:24 AM
I am having a serious problem with my server, yesterday i saw someone hacking in my server, then when i tried the /ban command on him over Client message it returned that Jockey_Hary has been banned from the server by an admin, but actually instead of him the server banned me.. and the unban is only possible by /rcon unbanip what is this i didnt understand at all, help me out please.

Parallex
05/06/2014, 04:25 AM
Are we meant to guess your code?

Laure
05/06/2014, 04:27 AM
Well sure, here you go, thats not just ban requires rcon unban but also auto ban require /rcon unban. Alright here's the code

CMD:ban(playerid, params[])
{
new playerb, ip;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

if(PlayerInfo[playerid][pAdmin] > 1) {
new player, reason[126];
if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
SendClientMessageToAll(COLOR_DARKRED, string);
}

format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
SendClientMessageToAll(COLOR_DARKRED, string);
Ban(playerid);
AddBan(ip);
}
return 1;
}

HyperZ
05/06/2014, 04:29 AM
CMD:ban(playerid, params[])
{
new playerb, ip;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

if(PlayerInfo[playerid][pAdmin] > 1) {
new player, reason[126];
if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
SendClientMessageToAll(COLOR_DARKRED, string);
}

format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
SendClientMessageToAll(COLOR_DARKRED, string);
Ban(playerb); // you were using "playerid" as targeted player
AddBan(ip);
}
return 1;
}

Laure
05/06/2014, 04:30 AM
CMD:ban(playerid, params[])
{
new playerb, ip;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

if(PlayerInfo[playerid][pAdmin] > 1) {
new player, reason[126];
if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
SendClientMessageToAll(COLOR_DARKRED, string);
}

format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
SendClientMessageToAll(COLOR_DARKRED, string);
Ban(playerb);
AddBan(ip);
}
return 1;
}

Still unsure what i did wrong.

HyperZ
05/06/2014, 04:32 AM
Still unsure what i did wrong.

Edited.

Laure
05/06/2014, 04:32 AM
What did you edit can i know?

HyperZ
05/06/2014, 04:34 AM
What did you edit can i know?

You were using "playerid" as targeted playerid, that's why you got banned instead of the targeted player.

It should be:
Ban(playerb);
Instead of:
Ban(playerid);

Could you tell show me "AddBan" function too? As i can see you're doing "AddBan(ip)" thingy wrong.

Laure
05/06/2014, 04:35 AM
Here you go mate.

stock AddBan(playerid)
{
new string[24];
new File:ban = fopen("ban.cfg", io_append);
format(string, sizeof(string), "%s\r\n", RPIP(playerid));
fwrite(ban, string);
fclose(ban);
}

HyperZ
05/06/2014, 04:38 AM
Here is your fixed code, and i removed some useless, or unneeded vars. Now your ban system is script sided.
CMD:ban(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

if(PlayerInfo[playerid][pAdmin] > 1)
{
new playerb, reason[126];
if(sscanf(params, "us[126]", playerb, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
SendClientMessageToAll(COLOR_DARKRED, string);
}

format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
SendClientMessageToAll(COLOR_DARKRED, string);

AddBan(playerb);
}
return 1;
}

Laure
05/06/2014, 04:47 AM
So, the issue of rcon banning will be solved?

HyperZ
05/06/2014, 04:49 AM
So, the issue of rcon banning will be solved?

Your code is fixed, means now it will ban the targeted player. Check my previous post again.

You could unban yourself from rcon remote console.

Laure
05/06/2014, 04:51 AM
Also is there any way to script a code to disable SendRconCommand from in game?

Parallex
05/06/2014, 04:58 AM
Also is there any way to script a code to disable SendRconCommand from in game?

Well - We can't disable it but we can do something.
If someone successfully logs in from RCON - he gets banned. In this way, no one can use Send Rcon Commands from In-Game.

public OnRconLoginAttempt(ip[], password[], success)
{
if(success)
{
Ban(ip);
return 1;
}
Not sure if the above code will work but you still got the idea.

HyperZ
05/06/2014, 05:00 AM
Also is there any way to script a code to disable SendRconCommand from in game?
Not really, but it's possible to disable RCON use from in-game, using this snippet:

public OnRconLoginAttempt(ip[], password[], success)
{
new gzIP[16];
for(new i; i < GetMaxPlayers(); i++)
{
GetPlayerIp(i, gzIP, 16);
if(!strcmp(ip, gzIP))
{
SendClientMessage(playerid, -1, "We don't allow RCON use.");
Kick(playerid); // kicks the player
break;
}
}
}

Laure
05/06/2014, 05:07 AM
One more thing when i got banned myself when trying to ban the hacker it was rcon ban not ban by server's script, Neither /unban worked, So how had that happen?

HyperZ
05/06/2014, 05:23 AM
One more thing when i got banned myself when trying to ban the hacker it was rcon ban not ban by server's script, Neither /unban worked, So how had that happen?

You were using Ban() (http://wiki.sa-mp.com/wiki/Ban), that's what you call it RCON ban which is now removed from your command/code.

Please check this post, it's edited http://forum.sa-mp.com/showpost.php?p=3064975&postcount=10

You need to be logged in as rcon in order to unban IP addresses, use /rcon unbanip ip_goes_here and then reload the bans using /rcon reloadbans.