Forum

> > CS2D > Scripts > I wanna disable a rcon command!
Forums overviewCS2D overview Scripts overviewLog in to reply

English I wanna disable a rcon command!

15 replies
To the start Previous 1 Next To the start

old Re: I wanna disable a rcon command!

Infinite Rain
Reviewer Off Offline

Quote
It's not a RCon command.
And you cannot stop people from using /kill.

But you can do a thing to stop them. Make so that player will be insta respawned on the same position with same health/wealth/armor, if a player hasn't been killed by a legitimate reason (killed, died by environment).

old Re: I wanna disable a rcon command!

DC
Admin Off Offline

Quote
Simply use the cs2d lua hook die hook (maybe cs2d lua hook kill works as well). I think the parameters killer and victim should have the same value when someone commits suicide with kill. The weapon id also probably has a special value or is just zero. Simply test it with:

1
2
3
4
addhook("die","diefunc")
function diefunc(victim, killer, weapon)
	msg("victim: "..victim..", killer: "..killer..", weapon: "..weapon)
end
and by executing /kill yourself to see what msg prints.

If it works you can use a conidition like the following one. 0 might have to be replaced with another displayed value from your test:
1
2
3
if victim == killer and weapon == 0 then
	-- dosomething like kick
end

It might be sufficient to test if killer equals victim but this depends on the server settings. It's possible to kill yourself with grenades and other explosives when friendly fire is on for example. This would trigger your scripted action as well when you skip the weapon check.

old Re: I wanna disable a rcon command!

Infinite Rain
Reviewer Off Offline

Quote
1
2
3
4
5
6
addhook("die","diefunc")
function diefunc(victim, killer, weapon)
	if victim == killer then
		parse('kick '.. killer ..' "You're not allowed to use \'/kill\' command!"')
	end
end

old Re: I wanna disable a rcon command!

mafia_man
User Off Offline

Quote
@user Infinite Rain:
Player is going to get kicked when his turret kills him, or he kills himself with grenade/gas grenade etc.

1
2
3
4
5
6
addhook("die","diefunc")
function diefunc(victim, killer, weapon)
     if victim == killer and weapon == 0 then
          parse('kick '.. killer ..' "You're not allowed to use \'/kill\' command!"')
     end
end

old Re: I wanna disable a rcon command!

DC
Admin Off Offline

Quote
cs2d lua hook parse only works for commands entered by the server (or which are sent to the server with RCon). It's clearly not the right solution here.

Clientside command execution can NOT be prevented because the commands are not sent to the server at all. Only the resulting action is sent (if necessary - changes in local settings for instance aren't sent to the server at all). Scripts however run on the server only so it's impossible to intercept the actual command execution for clients. You can only handle the resulting action with hooks (if appropiate hooks are provided by the CS2D Lua API).

old Re: I wanna disable a rcon command!

DC
Admin Off Offline

Quote
I think it's impossible to do that. You currently can't avoid deaths (for technical reasons because that would potentially lead to a lot of bugs and problems) and there is no extra hook for suicides with cs2d cmd kill. It would theoretically be possible for me to add such a hook but I don't see a way to do what you want with the current CS2D release.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview