You are not logged in.
Pages: 1
We have several user levels
8 is a new member
level 12+ has access to setlevel
However, I want to restrict level 12 to only allow them to set users to level 8 something like the following where I remove the flag setlevel from 12 and make them use !member instead
**********
name = member
exec = !setlevel [1] 8
desc = Sets a user as a new member level 8
levels = 12, 13, 14, 15, 16, 17, 18, 19, 20
But I don't think that will work as 1) I'm not sure you can use an admin command (!setlevel) in the exec? and 2) if I remove the flag setlevel from 12 it wouldn't work anyway would it?
Is there any way to do this?
Offline
Add the following code into a .lua file (create a .txt file and just rename it to maxsetlevel.lua)
Alternative download it here: http://www.mnwa.bplaced.net/ftpfiles/Lua/
--setlevel command
setlevel_cmd = "!setlevel"
--Maximal level to set
maxlevel = 8
--Admins over/same level are allowed to setlevel each value
allowedadmins = 20
--Text which is shown to the admins
text = "^1WARNING: ^3Maximal value of setlevel command is^1"
----------------------end of config-----------------------------
function et_ClientCommand(clientNum, command)
local arg0 = string.lower(et.trap_Argv(0))
if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then
if string.find(et.trap_Argv(1), "^" .. setlevel_cmd .. "") then
if et.trap_Argv(2) then
if tonumber(et.trap_Argv(3)) > maxlevel and tonumber(et.G_shrubbot_level(clientNum)) < allowedadmins then
et.trap_SendServerCommand(clientNum,"chat \""..text.." "..maxlevel.."\"")
return 1
end
end
end
end
return 0
end
---------------------------------------------------------------------
Put this lua into your mod folder and search in your server.cfg for lua_modules "" and add maxsetlevel.lua.
set lua_modules"maxsetlevel.lua"
Last edited by Micha (20-Mar-13 20:34:17)
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
Wow, thanks for that, the only thing is if it's overwriting the setlevel command rather than a new command it will affect other members as well.
Basically if possible
Level 12 can max set a user to 8
Level 13 can max set a user to 10
Level 14 & 15 can max set a user to 11
Level 16 can max set a user to 12
Level 17 can max set a user to 14
Or if it makes it easier admins 16 and below can only set a member to a level 4 below their own, level 17 - 20 it works as it normally would
Last edited by Kode (21-Mar-13 11:03:20)
Offline
I tested the following lua on etpub so I don't know if the lua works correctly. Just give an answer here
--Script made for Kodes needs :P
--Setlevel command (!setlevel will work with this too)
setlevel_cmd = "!set"
--Admins over/same level are allowed to setlevel each value
allowedadmins = 18
--getadminlevel is the level of the executing admin
--maxlevel is the maximal level he is allowed to set
level_table = {
{ getadminlevel = 11, maxlevel = 8, }, --this line is the new maxlevelrest
{ getadminlevel = 12, maxlevel = 8, },
{ getadminlevel = 13, maxlevel = 10, },
{ getadminlevel = 14, maxlevel = 11, },
{ getadminlevel = 15, maxlevel = 11, },
{ getadminlevel = 16, maxlevel = 12, },
{ getadminlevel = 17, maxlevel = 14, },
}
--Text which is shown to the admins
text = "^1WARNING: ^3You are just allowed to use "..setlevel_cmd.." till^1"
----------------------end of config-----------------------------
function et_ClientCommand(clientNum, command)
local cmd = string.lower(command)
local arg0 = string.lower(et.trap_Argv(0))
if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then
if string.find(et.trap_Argv(1), "^" .. setlevel_cmd .. "") then
if et.trap_Argv(2) and tonumber(et.trap_Argv(3)) then --if admin typed in console
for _, line in ipairs(level_table) do
if tonumber(et.G_shrubbot_level(clientNum)) <= line.getadminlevel then
local maxlevel = line.maxlevel
if tonumber(et.trap_Argv(3)) > maxlevel then
et.trap_SendServerCommand(clientNum,"chat \""..text.." "..maxlevel.."\"")
return 1
end
end
end
else --if admin typed in chat window
for _, line in ipairs(level_table) do
local findnumber = string.gfind(et.trap_Argv(1), "%s"..line.maxlevel.."") --need a way to find the number. "et.trap_Argv(1)" is always the whole text (!set name number).
if findnumer == nil then et.trap_SendServerCommand(clientNum,"chat \"^3Use console to use '"..setlevel_cmd.."' command, please. Open it with ^\"") return 1 end
--[[ --Took it out since I don't know a way to find out the number
if tonumber(et.G_shrubbot_level(clientNum)) <= line.getadminlevel then
local maxlevel = line.maxlevel
if tonumber(findnumber) > maxlevel then
et.trap_SendServerCommand(clientNum,"chat \""..text.." "..maxlevel.."\"")
return 1
end
end
--]]
end
end
end
elseif string.find(cmd, "^" .. setlevel_cmd .. "") then --in case admin used a slash (/) before ! -> /!set player 4
if et.trap_Argv(1) then
for _, line in ipairs(level_table) do
if tonumber(et.G_shrubbot_level(clientNum)) <= line.getadminlevel then
local maxlevel = line.maxlevel
if tonumber(et.trap_Argv(2)) > maxlevel then
et.trap_SendServerCommand(clientNum,"chat \""..text.." "..maxlevel.."\"")
return 1
end
end
end
end
end
return 0
end
---------------------------------------------------------------------
Last edited by Micha (25-Mar-13 11:43:38)
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
you rock, I will give it a try tonight, thanks so much for that
Offline
Hi again, sorry to be a pain but it doesn't seem to work.
In server.cfg I have:
//=============================LUA==========================//
set lua_modules "balanceteams.lua"
set lua_modules "maxlevel.lua"
and maxlevel.lua is in the nitmod folder
It just doesnt seem to do anything at all, any ideas for somethiing i've done wrong?
Offline
Ahh extra lua files should be space seperated right?
*edit* That still doesn't work =/
*edit2*
The Lua file is being loaded, just sin't working:
Lua API: showing lua information ( 2 modules loaded )
VM Modname Signature Filename
-- ------------------------ ---------------------------------------- ------------------------
0 6B8DCC3A3F2986896FEDC200564AD3DD1E292E9D balanceteams.lua
1 25DACADDE6D508F56B79D6130C87B39292409929 maxlevel.lua
-- ------------------------ ---------------------------------------- ------------------------
Last edited by Kode (23-Mar-13 13:34:56)
Offline
If you run "nitmod-2.2-091712" that might be the problem. I was not able to run lua with that one.
And, yes, space seperated.
Offline
The balance teams lua works though, we are running nitmod_2.2.1_r772
Offline
I will download this mod and try it on local host. Should be a mod problem since it worked on etpub
Where can I get nitmod_2.2.1_r772?
*EDIT*
I tested on nitmod 2.2 and I fixed a little error. Re download the lua above and it should work.
Last edited by Micha (24-Mar-13 01:42:22)
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
Hi Micha,
Thanks for everything you have done so far, I'm sure it must be something I'm doing wrong, lol.
I reuploaded the lua.
Tried !readconfig asked a level 17 to set someone who was level 13 to 16 and they were set to 16 so he set him back to 13
I tried restarting the server and the same thing happened.
Could I put something in the code to output a message to the person doing !setlevel so we can debug if the script is even getting executed?
I'm a PHP dev, so I have a basic understanding of what the script is doing, but I have zero experience with lua so don't really know where to start to fix it.
*edit*
I tried adding an extra et.trap_SendServerCommand(clientNum,"chat \""..text.." "..maxlevel.."\"")
after
local arg0 = string.lower(et.trap_Argv(0))
to try and debug if the script was being executed.
Then I did a !readconfig
Nothing displayed when I tried it (level 20)
So either the script isn't being executed, !readconfig doesn't reload the lua and I would need to do a server restart, or I can't just put a SendServerCommand in without setting the return status right after it? If i've read it correctly, return 0 will continue with the normal execution of !setlevel whereas return 1 should interrupt it, but like I said, I don't know enough about it really.
Last edited by Kode (24-Mar-13 14:38:40)
Offline
Lol, it's started working
Offline
Lol, it's started working
I updated the lua once again. It should fix all ways I know now -> console, chat window, console with a / before !set
I think your guy used chat window so it didn't worked.
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
elseif tonumber(et.trap_Argv(3)) <= maxlevelrest and tonumber(et.G_shrubbot_level(clientNum)) < allowedadmins then
Should that not be
elseif tonumber(et.trap_Argv(3)) > maxlevelrest and tonumber(et.G_shrubbot_level(clientNum)) < allowedadmins then
because weirdly if a level 12 tries to set a member to less than 8 (i.e. level 1- 7) they get the message they can only set till 8 although I would have thought they would get caught by the if and not fall to the elseif
http://bayimg.com/hakKhAAEp <-- example
it's not really an issue though, the rest seems to work fine, just trying to understand it
Offline
Ok this is really weird, it seems to work sometimes but not others.
one of the level 12s gets the warning whatever level they try to set (screenshot above) the level 17 could set any level up to 16 (max should have been 14) I set him to 12 and he could set users to any level except 8 where he got a warning, I set him back to 17 and then he could only set up to level 14, then randomly a few minutes later he could set up to 16 again. For some other members it seems to work as expected.
Offline
Kode wrote:Lol, it's started working
I updated the lua once again. It should fix all ways I know now -> console, chat window, console with a / before !set
I think your guy used chat window so it didn't worked.
I just saw this message, the lua I've been using was the version before, I will update to the latest one and see if that makes any difference, sorry for the confusion
Offline
Micha wrote:Kode wrote:Lol, it's started working
I updated the lua once again. It should fix all ways I know now -> console, chat window, console with a / before !set
I think your guy used chat window so it didn't worked.I just saw this message, the lua I've been using was the version before, I will update to the latest one and see if that makes any difference, sorry for the confusion
I updated it once again and it should work 100% now. I tested all cases on me.
Sorry for this but my brain failed
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
heh, bet you wish you never tried to help
I will test it out when I get home.
can I change:
text = "^1WARNING: ^3You are just allowed to use "..setlevel_cmd.." till^1"
to
text = "^1WARNING: ^3You are just allowed to use !setlevel till^1"
because you have changed setlevel_cmd to !set which is better because it will work with shortcuts like !setl but !set doesnt actually work for changing the level so might confuse people
Offline
heh, bet you wish you never tried to help
I will test it out when I get home.
can I change:
text = "^1WARNING: ^3You are just allowed to use "..setlevel_cmd.." till^1"
to
text = "^1WARNING: ^3You are just allowed to use !setlevel till^1"because you have changed setlevel_cmd to !set which is better because it will work with shortcuts like !setl but !set doesnt actually work for changing the level so might confuse people
Sure you can set it to everything you want.
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
heh, was just checking that changing it wouldn't break anything
Offline
Offline
Pages: 1