• Derma menu help!
    21 replies, posted
I have been going through many tutorials trying to make my own menu, which isn't really the problem. The problem is that i don't really know where to put the .lua file and how to open it. I have a server that i would like to open it in, and have the admins be able to access it also. Help me!
If the Derma Panel is completely finished you would place it inside of lua/autorun/client/ this will automatically run it. If you're still progressing on it in singleplayer you can place it in your own garrysmod at [B]lua/autorun/client[/B] or just the [B]lua/[/B] folder itself. Then you can reload the file in-game with: [CODE]lua_openscript_cl autorun/<YourFileName>.lua[/CODE] or [CODE]lua_openscript_cl <YourRFileName>.lua[/CODE]
Thanks i didn't know the command to open the scripts, it thought i was open_<whateverfile> like some menus. Do you know how to program in lua scripts to open through chat ex: !menu
[LUA] hook.Add( "PlayerSay", "Chatcmd", function(ply, text, pblc) if string.lower(text) == "!menu" then ply:ConCommand("menuconcommand") end end) [/LUA]
If you don't already know. [lua] function MyDermaMenu() print("ThisIsSupposedToHaveDermaInsideOfIt") end concommand.Add("menucommand", MyDermaMenu) [/lua]
[QUOTE=brandonj4;37349189]If you don't already know. [lua] function MyDermaMenu() print("ThisIsSupposedToHaveDermaInsideOfIt") end concommand.Add("menucommand", MyDermaMenu) [/lua][/QUOTE] Ok i understand it now, i'm new to programming :) [editline]22nd August 2012[/editline] [QUOTE=I Fail At Lua;37349146][LUA] hook.Add( "PlayerSay", "Chatcmd", function(ply, text, pblc) if string.lower(text) == "!menu" then ply:ConCommand("menuconcommand") end end) [/LUA][/QUOTE] Perfect! Now is there anyway i could play a sound instead?
[LUA] function Menu( ) -- ClientSide surface.PlaySound( "/music/hl2_song20_submix0.mp3" ) -- Add your menu stuff here end concommand.Add("MenuStuff", Menu) hook.Add( "PlayerSay", "Chatcmd", function(ply, text, pblc) -- Serverside if string.lower(text) == "!menu" then ply:ConCommand("MenuStuff") end end) [/LUA]
[QUOTE=I Fail At Lua;37349578][LUA] function Menu( ) surface.PlaySound( "/music/hl2_song20_submix0.mp3" ) print("it worked") end concommand.Add("MenuStuff", Menu) hook.Add( "PlayerSay", "Chatcmd", function(ply, text, pblc) if string.lower(text) == "!menu" then ply:ConCommand("MenuStuff") end end) [/LUA][/QUOTE] The [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8519.html"]PlayerSay[/URL] hook is serverside. :tinfoil:
[QUOTE=brandonj4;37349622]The [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8519.html"]PlayerSay[/URL] hook is serverside. :tinfoil:[/QUOTE] Yeah I know I forgot to comment saying its serverside. He could add his Derma Menu after surface.PlaySound
omg so confusing, so your saying that i could just put the surface.playsound in my menu?
Well no you don't have to, if you wanted to have a sound play and then a menu open up you would add your derma menu code after surface.PlaySound. The way it is currently when you say !menu in chat it will play that sound.
You're not actually putting it IN the menu, you're putting it in the same function as the menu, so when the menu is called so is the surface.PlaySound() function.
Well after staring I Fail At Lua's code for a while i understand it, it's somewhat like basic C Language isn't it? kinda [editline]22nd August 2012[/editline] So could i put like 5 or 6 different functions that play different sounds all in side the menu function? [editline]22nd August 2012[/editline] I don't know why it edited my last post but my question was in the last post
Yeah but that'd just end up being a massive clusterfuck of sounds being played at the same time... :v:
i mean different functions so that it doesn't play ALL the sounds at once just separate chat commands that play separate sounds
Wait I'm a bit confused, what're you going for here?
lets say i type "freeman", i want it to play a sound clip from the player globally just 1 soundclip. Does that make some more sense?
Yeah I suppose, here's an easy way of doing it though. [lua] function _R.Player:SendSound(snd) --If you're using GM12 umsg.Send("sendSound",self) umsg.WriteString(snd) umsg.End() --If you're using GM13 net.Start("sendSound") net.WriteString(snd) net.Send(self) end hook.Add("PlayerSay","Test stooph",function(player,text) if text == "freeman" then for k,v in pairs(player.GetAll()) do v:PlaySound("sounddirectoryhere") end end end) --Clientside here --For GM12 usermessage.Hook("sendSound",function(m) surface.PlaySound(m:ReadString()) end) --Or for GM13 net.Receive("sendSound",function() surface.PlaySound(net.ReadString()) end) [/lua]
snip
um i wanted it so its both client and server side so other clients could hear it. Sorry i didn't specify that. Or explain if it does?
it does because I looped through all the players and ran the same function for them. [lua] for k,v in pairs(player.GetAll()) do [/lua] v returns the player(In this case ALL the players) so I can do anything for all players.
oooooo i see now, so would i just repeat the hook if i wanted different sounds? oh and do i just make a folder containing the mp3 in lua? or where? [editline]22nd August 2012[/editline] well either i messed it up or i don't have the files in the correct spots
Sorry, you need to Log In to post a reply to this thread.