Forum

> > CS2D > Scripts > Force a player to use a bind.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Force a player to use a bind.

7 replies
To the start Previous 1 Next To the start

old Force a player to use a bind.

minos
User Off Offline

Quote
Hello, I'm searching to force players in using binds when they join the server is there anyway to make that ?
regards,

old Re: Force a player to use a bind.

Mora
User Playing CS2D

Quote
Before player starting the game(joins team and spawn) you can ask them what the button they would like to use for special action, like setting controls, then recommend them to set controls, if otherwise - the gameplay wont be as it should be with binds.

example like:
"Type the button to do Reload"
and you have to say "R" or "r", w/e.
then next and etc.

old Re: Force a player to use a bind.

minos
User Off Offline

Quote
user Cure Pikachu has written
Use a combination of the cs2d lua cmd addbind function and cs2d lua hook key hook. It won't let you overwrite client's controls though.

how that's working ?
1
2
addbind("space")
parse('bind space "say !help"')
I need an example please !

@user Mora I want something that forces them not ask them for writing binds
like this
1
2
3
4
timer(40,"playerbind","")
function playerbind()
parse(bind leftalt "say !help")
end

old Re: Force a player to use a bind.

Cure Pikachu
User Off Offline

Quote
Using that example:
1
2
3
4
5
6
7
8
9
10
addbind("space") -- Add a custom bind for spacebar

addhook("key","_keybind")
function _keybind(id,key,state) -- id parameter is for player id
	if state == 1 then -- If key is *only* pressed down
		if key == "space" then -- If key is spacebar
			-- Whatever saying !help is supposed to do, put it here
		end
	end
end
Also, read up thread cs2d Bind other players keys, it will tell you why you can't just do a parse cs2d cmd bind in a script.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview