AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to bind a key ? (https://forums.alliedmods.net/showthread.php?t=93917)

K.K.Lv 06-04-2009 10:26

How to bind a key ?
 
Hi ! everybody!
I just want to bind a key to call a menu!
please look at the following code:
PHP Code:

 register_clcmd("amx_info""CmdMenu")
 
//...
public client_putinserver(id)
{
 
set_task(4.0"bind_key"id)
 return 
PLUGIN_CONTINUE
}
 
public 
bind_key(id)
{
 
client_cmd(id"bind l amx_info")
//...
}
 
public 
CmdMenu(id)
{
 
//..


but when i press the "L" key, will print "unknow command: amx_info" in the console!
do I wrong ??
please tell me the mistake!!
thanks for you all!!!!

ConnorMcLeod 06-04-2009 11:12

Re: How to bind a key ?
 
Bind a key is not allow if you don't ask player's permission first.

fysiks 06-04-2009 15:37

Re: How to bind a key ?
 
It's working as it should :). return PLUGIN_HANDLED

K.K.Lv 06-04-2009 23:19

Re: How to bind a key ?
 
Quote:

Originally Posted by ConnorMcLeod (Post 841470)
Bind a key is not allow if you don't ask player's permission first.

why?

K.K.Lv 06-04-2009 23:22

Re: How to bind a key ?
 
Quote:

Originally Posted by fysiks (Post 841628)
It's working as it should :). return PLUGIN_HANDLED

you mean add return PLUGIN_HANDLED behind the client_cmd(id, "bind l amx_info")

Exolent[jNr] 06-04-2009 23:39

Re: How to bind a key ?
 
Quote:

Originally Posted by K.K.Lv (Post 841904)
why?

Because you are changing a client's settings without their permission, and it is not allowed here.

Quote:

Originally Posted by K.K.Lv (Post 841905)
you mean add return PLUGIN_HANDLED behind the client_cmd(id, "bind l amx_info")

No, he meant in the function that handles the command.

K.K.Lv 06-05-2009 01:11

Re: How to bind a key ?
 
can you give me a example???

fysiks 06-05-2009 01:15

Re: How to bind a key ?
 
Quote:

Originally Posted by K.K.Lv (Post 841952)
can you give me a example???

PHP Code:

public CmdMenu(id)
{
 
//..
 
return PLUGIN_HANDLED


I'm smart :). As far as asking permission, that's a bit more involved, I'm not that smart (well . . .) LOL :).

K.K.Lv 06-05-2009 02:10

Re: How to bind a key ?
 
Quote:

I'm smart :)
may be you are right!!:?:


thanks you code!!!


All times are GMT -4. The time now is 14:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.