Rcon commands (DCMD)
#1

Hey.

The only thing i havn't learned yet, is how to make a command be used by rcon admins only..
i have this.
http://pastebin.com/f2701ce7c

But when i add it as filterscript it doesnt work doing the commands?
Can anyone tell why it doesnt work, and how to make it work?

(Yes, i have dcmd defined. i dont get any errors)
Reply
#2

I am not really sure if you can get DCMD working with RCON commands, but try this:

pawn Code:
public OnRconCommand(cmd[])
{
  dcmd(kick, 4, cmd);
  dcmd(kill, 4, cmd);
  dcmd(ban, 3, cmd);
  return 1;
}
Reply
#3

You mean,

Code:
public OnRconCommand(playerid, cmd[])
{
	dcmd(kick, 4, cmd);
	dcmd(kill, 4, cmd);
	dcmd(ban, 3, cmd);
	return 1;
}

dcmd_kick(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
			id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
			SendClientMessage(id, 0x00FF00AA, "You've been kicked from the server [by: %s]", playerid);
			SendClientMessage(playerid, 0x00FF00AA, "Player kicked");
			Kick(id);
		}
	}
	else
	{
	  SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_kill(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kill <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  SendClientMessage(id, 0x00FF00AA, "You've been killed [by: %s]", playerid);
		  SendClientMessage(playerid, 0x00FF00AA, "Player killed");
		  SetPlayerHealth(id, 0.00);
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_ban(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		new
			reason[64];
		if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage:\"/ban <playerid> <reason>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  BanEx(id, reason);
		  format(reason, sizeof(reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
			SendClientMessage(id, 0xFF0000AA, reason);
			SendClientMessage(playerid, 0x00FF00AA, "Player banned");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
	return 1;
}
Like that?
Reply
#4

OnRconCommand doesn't have an 'playerid' param, that callback is only for console-commands.
Reply
#5

So you say that this proberly would work?

Code:
public OnRconCommand(cmdtext[])
{
	dcmd(kick, 4, cmdtext);
	dcmd(kill, 4, cmdtext);
	dcmd(ban, 3, cmdtext);
	return 1;
}

dcmd_kick(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
			id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
			SendClientMessage(id, 0x00FF00AA, "You've been kicked from the server [by: %s]", playerid);
			SendClientMessage(playerid, 0x00FF00AA, "Player kicked");
			Kick(id);
		}
	}
	else
	{
	  SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_kill(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kill <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  SendClientMessage(id, 0x00FF00AA, "You've been killed [by: %s]", playerid);
		  SendClientMessage(playerid, 0x00FF00AA, "Player killed");
		  SetPlayerHealth(id, 0.00);
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_ban(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		new
			reason[64];
		if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage:\"/ban <playerid> <reason>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  BanEx(id, reason);
		  format(reason, sizeof(reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
			SendClientMessage(id, 0xFF0000AA, reason);
			SendClientMessage(playerid, 0x00FF00AA, "Player banned");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
	return 1;
}
Reply
#6

It won't because you don't have a playerid to pass to the dcmd function.
Reply
#7

Well, how to i do then?

Thats my question

Quote:
Originally Posted by Niixie
Can anyone tell why it doesnt work, and how to make it work?

(Yes, i have dcmd defined. i dont get any errors)
Reply
#8

Maybe you could trick the DCMD somehow, for example:

pawn Code:
public OnRconCommand(cmd[])
{
  new playerid;

  dcmd(kick, 4, cmd);
  dcmd(kill, 4, cmd);
  dcmd(ban, 3, cmd);
  return 1;
}
Reply
#9

if i do that:

Quote:
Originally Posted by Finn
Maybe you could trick the DCMD somehow, for example:

pawn Code:
public OnRconCommand(cmd[])
{
  new playerid;

  dcmd(kick, 4, cmd);
  dcmd(kill, 4, cmd);
  dcmd(ban, 3, cmd);
  return 1;
}
then i have this:
Code:
public OnRconCommand(playerid, cmdtext[])
{
	new playerid;
	dcmd(kick, 4, cmdtext);
	dcmd(kill, 4, cmdtext);
	dcmd(ban, 3, cmdtext);
	return 1;
}

dcmd_kick(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
			id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
			SendClientMessage(id, 0x00FF00AA, "You've been kicked from the server [by: %s]", playerid);
			SendClientMessage(playerid, 0x00FF00AA, "Player kicked");
			Kick(id);
		}
	}
	else
	{
	  SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_kill(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kill <playerid>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  SendClientMessage(id, 0x00FF00AA, "You've been killed [by: %s]", playerid);
		  SendClientMessage(playerid, 0x00FF00AA, "Player killed");
		  SetPlayerHealth(id, 0.00);
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
}

dcmd_ban(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))
	{
		new
		  id;
		new
			reason[64];
		if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage:\"/ban <playerid> <reason>\"");
		else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		else
		{
		  BanEx(id, reason);
		  format(reason, sizeof(reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
			SendClientMessage(id, 0xFF0000AA, reason);
			SendClientMessage(playerid, 0x00FF00AA, "Player banned");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "You're not RCON admin!");
	}
	return 1;
}
with these errors:
Code:
C:\Alt\x Niixies 0.3 server\filterscripts\test2.pwn(61) : error 025: function heading differs from prototype
C:\Alt\x Niixies 0.3 server\filterscripts\test2.pwn(63) : warning 219: local variable "playerid" shadows a variable at a preceding level
C:\Alt\x Niixies 0.3 server\filterscripts\test2.pwn(80) : warning 202: number of arguments does not match definition
C:\Alt\x Niixies 0.3 server\filterscripts\test2.pwn(101) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#10

http://forum.sa-mp.com/index.php?topic=113647.0
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)