ETPro lua scripting

Hello,
I'm trying to create a simple .lua script that would disallow users from using certain commands until they authenticate themselves using a simple command such as /login.

The only problem is that I'm dabbling with the unknown here, as I've never touched LUA before in my life. Here's what I have so far, which I mainly achieved by shamelessly combining elements of the TJMod.lua thing.
Quoteloggedin=0

function login(clientNum)
loggedin=1
et.trap_SendServerCommand( clientNum, "cp \"You're now logged in\n\"" )
return 1
return 0
end

function block(clientNum)
et.trap_SendServerCommand( clientNum, "cp \"You're not allowed to do that\n\"" )
return 1
end

function et_ClientCommand( clientNum, command )
if command=="random_disallowed_command" and loggedin==0 then
block(clientNum)
return 1
end

if command=="login" then
login(clientNum)
return 1
end
return 0
end


However, the problem is that it simply doesn't work. When I enable it on the server, typing in the "disallowed commands" still works and the /login command will just respond with "unknown command". Another problem is that it's likely horridly shitty and poorly done.

So, how could I make this work as intended? I mean, so that players cannot use command /random_disallowed_command before they have done /login?

Also, is there a way to do the same for cvars, so that people wouldn't be able to set, say, cg_autoreload 1 until they do login.

PS: Sorry for fucking up indentation - it's just Crossfire.
Comments
7
rtfm hehe :PPP
I tried, the ETPro LUA scripting tutorial was about 200 lines maximum, and didn't really provide any real info.

Anyways, what I'm trying to achieve is painfully simple so I just hoped someone could point me to the right direction.
Parent
save yourself from the worst and get etadmin mod for logins \o
Parent
ask at etpro forums..

i found lua for etpro frustrating at the best of times....
i would imagine you have to register/set the cvar first:
et.trap_Cvar_Set( cvarname, cvarvalue )

then i would imagine you need a callback/event listener so you know when the client enters a command:
et_ClientCommand( clientNum, command )

you would then need to check if the command == "login" and call a function to handle it
which gets the value with:
et.trap_Cvar_Get( cvarname )

and then performs any logic you want

never used LUA but I am a programmer this is how i would imagine its done
I guess the functions are somewhat right, but would imagine you would actually have to 'catch' the command entered, before you check it. Atm i'd imagine these are never actually called.
I figured (based on the TJMod.lua thing) that the
function et_ClientCommand( clientNum, command )
gets called when a client types something in their console. However, I might be wrong.

I guess I'll ask on the ETPro forums, which seem awfully dead though.
Parent
Back to top