• How to make an easy toggle able command.
    10 replies, posted
As the tittle... fx if you type npc_voice 1 my npc will "speak", if npc_voice 0, it will use text? ...If you ain't want to help me then gtfo ... Or if you are a creepy a*s stalker...
[url]http://luasearch.overvprojects.nl/?keywords=convar[/url]
Thanks, but... Can i get a example?
[url=http://luasearch.overvprojects.nl/?keywords=CreateConVar]Spoon[/url] [url=http://luasearch.overvprojects.nl/?keywords=cvars.AddChangeCallback]feed[/url]
Thanks :) I know that i can see the examples both on the search and on the wiki, but it didn't explain that much in the examples... Thanks again^^
Only the server operator or the server itself will be able to run/edit convars. You as an admin will not be able to do npc_voice 1, but you can set it in your servers configuration file. Do you want admins/players to be able to run it?
yes
[lua] concommand.Add("npc_voice",function(ply) if not ply:IsAdmin() then ply:ChatPrint("You must be an admin to run this command.") return end if t == 1 then Msg("npc_voice is now 0") -- do stuff when its off else Msg("npc_voice is now 1") -- do stuff when its on end end) [/lua] You will need something like that then.
Thanks!
[QUOTE=zzaacckk;28274035][lua] concommand.Add("npc_voice",function(ply) if not ply:IsAdmin() then ply:ChatPrint("You must be an admin to run this command.") return end if t == 1 then Msg("npc_voice is now 0") -- do stuff when its off else Msg("npc_voice is now 1") -- do stuff when its on end end) [/lua] You will need something like that then.[/QUOTE] That'll give you a nil value error on t, unless I'm mistaken.
[QUOTE=MegaJohnny;28298578]That'll give you a nil value error on t, unless I'm mistaken.[/QUOTE] yeah he needs to declare t as a var. or he could do something like when the concommand is ran it sets t to 1, then does something, and if t is 1 when the command is ran then do something else.
Sorry, you need to Log In to post a reply to this thread.