cvar lock

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

cvar lock

Post by BBmac »

Hi... I was wondering how I would go about locking certain cvars?
I have some certain cvars that I dont want my admins using without me allowing them to... I want to create sort of a lock by having those cvars check if my cvar is on or off sort of. How would I call a function to check that first and im sure I need the IF statements? And the cvars are ones I created that turn you invisible, invincible, and sorts of things like that. Its nothing like default cvars, so I am able to go right to them and not allow them to be called unless my cvar is set to unlocked... but I dont know how to call it.

Also... I would like to script a message to the admin that called it where it says like "Admin BB has locked this command". How would I script it to to only appear to the admin?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

which cvars do you want to lock- list them. all custom ones?
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

well... what you do is you call the cmd on a client... # = client number
!# invisy (invisibility)
!# invin (invincibility)
!# noclip (noclip)

now the commands that when these are called are:
invisy - self hide
invin - self dog
noclip - self noclip

This is what the inside of the Invisible.scr looks like and its the same for the others...

Code: Select all

invisibility:

self hide
end
Yes its that simple... and the code for the thing that turns it into a cmd looks like this...

Code: Select all

case "invisy":
exec Commands/Cmd_Invisy.scr local.cmdvar
break
If you are familiar with JimbobsPunishmentScript then you know how all that functions. I based mine on his design.

Can you help?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

This looks like your developing an advantage on your own server - for what purpose do you do this and without your admins knowledge.
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

sometimes we turn all the players big, small, invisible and stuff and we have fun days... but I dont like having to switch pk3s for all of that. So I leave that 1 pk3 on there... yet... they like to have fun when they arent suppose to and "abuse" the commands. So I would like to lock them until we are ready to use them. Im not doing anything to an advantage/disadvantage i promise you. I am in full control of my server and clan and Im responsible.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

that isnt really a cvar. unless you have a cvar to toggle the effects on or off (especially for hide/show). In that case there's nothing to stop admins from jst typing 'rcon set <cvar> <value>' and changing it, without using the script.

however messing with the cvar under that context pretty much doesn't do anything, they'd have to call the scripts' function to change the ingame effect of the command.

But as far as controlling admin usage of the commands, just make a password. It's a server-side mod, so you can hardcode one into the script and have them pass it with the command.

Even better, give them a menu to do it. something simple like a text field for the clientnumber to affect and the password they want to use, and a bunch of buttons for the effects. have it do a stufftext to do the command.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

well... we have enough menus in our games. But take my invisibility command for example.

Code: Select all

invisibility: 

self hide 
end 
Now im thinking if I created another .scr somewhere that was execed by the DM_Precache then it would create the cvar for me... I dont have much experience in creating my own cvar but I might be able to do this by myself... would it look like this?

Code: Select all

main:

if(getcvar "bblock" == "1")
{
level.bblock = 1
}
if(getcvar "bblock" == "0")
{
level.bblock = 0
}
end
Thats the lock.scr I have to create my cvar. I dunno if that works or not but Im hoping it does.

Now if we go back to the invisibility.scr, isnt there a way I should just be able to do this...

Code: Select all

invisibility: 
if (*function to check my cvar bblock == 0) {
self hide 
}
if (*function to check my cvar bblock == 1) {
centerprint "Admin BB has locked this command!"
}
end 
Now lizardkid, I liked your idea about creating a password. I was thinking about that too but I thought that was a little complicated for me so I didnt ask. You lost me at the menu part though lol.

Now what I just did above seems simple to me seing as jimbob has sort of already done something kinda like this but his doesnt check for cvar. So if no one thinks this can be done could you atleast just give me the fuction to check the status of the cvar with the if statement? I rather fail myself then to just be let down.
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

so I should just give up?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

sorry, didnt see this had replies.

ok well what i was thinking was like this (pseuducode)


Code: Select all

// lock.scr

commandRequest: local.command local.password

if(local.password == game.BBpassword)
{
// determine command, just a switch statement.
}
end


invisibility:

if(game.BBblock_invisiblility == 0)
{
centerprint Your Message :(
}
else
{
// invisibility code
}

end

So, for this to work, you'd need a menu. (incase you dont know) Menus are just GUI containers that hold outlines, text boxes, buttons, and the like. they have the extension .urc, you can learn most of the commands from the stock ones. They're not hard.

so for this, you'd just make a simple menu with a textfield (where they type the password) and a series of buttons (for the effects).

The idea being, an admin enters his password, hits a button and this script is called. If his password is wrong, the command is rejected (with a frowny face note).

this is all under the assumption that you have a way to run this on your server... i havent seen the "JimbobsPunishmentScript", so i don't know how you're doing it. But all this should be serverside (except the menu, obviously). that way, no sneaky admin can change the password that's being checked on his end.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

Thanks alot. I will try this out. I do have a bit of experience with making menus... Ill give it a try... Thank you!

Now im slightly confused with game.BBpassword and game.BBblock_invisibility... gameBBpassword is where I define my actual password? And where does game.BBblock_invisibility get its properties from?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

BBblock_invisibility is to keep track of whether the player is shown or hidden, since there's no toggle command (afaik) for show/hide.

BBpassword is the CORRECT password to check against, the idea is to take the password typed into the textfield in the menu and test against BBpassword.

i used game.<variable> but i'm not totally sure that makes it a global cvar, it's actually probably better to use it like you did, with setcvar and getcvar.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

ok thank you... And I do have a toggle sort of. To hide its the command "invisy" and to show its the command "normal". Now since they are not the same command but they do have the opposite effects, does that make a difference with anything?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

well, what i meant by "toggle command" is one command you can use to just toggle an effect. Like 'noclip'. Toggles on and off with one command.

For commands like hide/show that have two commands to toggle on and off, the simplest way to do it is make a variable for if they're invisible (BBinvisibility).
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply