You are not logged in.
Pages: 1
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
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
Even if shrubbot-command doesn't work, ... in my opinion at least /rcon testcommand
should do it
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
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
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. ^^
Offline
lvl = et.G_shrubbot_level(client)
This line is great
At the moment i do a workaround with creating an array containing all known GUIDs of our admins.
This line makes it way easier
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
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
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
Pages: 1