ETMods.net

N!tmod, a Wolfenstein: Enemy Territory Modification!

You are not logged in.

Announcement

You can donate to help us keeping services online.

#1 13-Dec-10 17:12:28

KoSH
Member
Registered: 14-Aug-10
Posts: 31

Re: Problem with et_ConsoleCommand()

Hi Guys,

i've started dealing with lua-scripting, and encountered a little problem. I thought, maybe one of you
can give me a little hint smile
What i want basically is, to call a LUA function from a custom-shrubbot command. Therefor i
wrote this custom command:

command = test
exec = testcommand; cpm Test
desc = text
levels = 4 5 6 7 

This command should call following function

function et_ConsoleCommand()
  if et.trap_Argv(0) == "testcommand" then
	et.trap_SendConsoleCommand(et.EXEC_NOW, "cp works ") 
	-- doing some calculations and actions
        return 1
  end
  return 0
end

The problem is, that i do not manage to call the function at all  hmm
Even if shrubbot-command doesn't work, ... in my opinion at least /rcon testcommand
should do it  question
Am i just too dumb to find the right way to call the function? or is that just not possible?


If i use

et_ClientCommand(clientNum, command)

i can call my function perfectly well with typing /testcommand in console. But i want to restrict my function to certain shrubbot levels. Of course i could read in the shrubbot.cfg and check if the client, who calls this function has sufficient rights, but i fear that would cause too much calculating time, especially as N!tmods shrub cfg is not very small smile


http://www.attawaybaby.de
ET://213.239.202.61:27040


"If there are no stupid questions, then what kind of questions do stupid people ask? Do they get smart just in time to ask questions?"
— Scott Adams

Offline

#2 13-Dec-10 19:24:37

N!trox*
Administrator
Registered: 30-Mar-10
Posts: 1,098

Re: Problem with et_ConsoleCommand()

If you want to use et_ClientCommand( clientNum, command ), you can do it this way :

function et_ClientCommand( client, command )
     command = string.lower(command)
     lvl = et.G_shrubbot_level(client)

          if (lvl > 1) and ( command == "test" ) then
               et.trap_SendConsoleCommand(et.EXEC_NOW, "cp works")
               return 1
          end
     return 0
end

If you want to use et_ConsoleCommand( command ), I guess some people will be able to help you out, i'm not really good in LUA coding, yet. ^^


iluvnitmod.png

Offline

#3 13-Dec-10 19:35:39

KoSH
Member
Registered: 14-Aug-10
Posts: 31

Re: Problem with et_ConsoleCommand()

N!trox* wrote:
     lvl = et.G_shrubbot_level(client)

This line is great smile
At the moment i do a workaround with creating an array containing all known GUIDs of our admins.
This line makes it way easier smile

Sadly there is no possiblity to call a "ClientCommand()" function from a custom shrubbot command, is there?

If i could find a solution for that i would be perfectly satisfied smile

thank you N!trox


http://www.attawaybaby.de
ET://213.239.202.61:27040


"If there are no stupid questions, then what kind of questions do stupid people ask? Do they get smart just in time to ask questions?"
— Scott Adams

Offline

#4 15-Dec-10 02:03:48

soak
BETA Tester
Registered: 03-Sep-10
Posts: 23

Re: Problem with et_ConsoleCommand()

You could scan what the client says to see if:

a) the command matches the text they enter
b) their level is high enough to use it

Offline

Board footer

Powered by FluxBB