I Have created an Derma menu,
but the thing is i want it to put it on my server and bind it to an key, so when players join my server and they press Lets say F8 that they will get that derma menu.
So can anyone help me?
Thanks already,
You are better off binding it to one of the gamemode bindings (F1-4) because the higher function keys perform system tasks, such as saving and loading.
You can do that like this (binds to F4):
[b]Server:[/b]
[lua]hook.Add("ShowSpare2", "SendUMSG", function(ply)
umsg.Start("OpenMenuF4", ply)
umsg.End()
end)[/lua]
[b]Client:[/b]
[lua]usermessage.Hook("OpenMenuF4", function(um)
-- Open menu
end)[/lua]
So i gotta add that to the gamemode folder or somewhere else?
If you are making a gamemode then you can put this into your gamemode init.lua:
[lua]function GM:ShowSpare2(ply)
umsg.Start("OpenMenuF4", ply)
umsg.End()
end[/lua]
and this in your gamemode cl_init.lua:
[lua]usermessage.Hook("OpenMenuF4", function(um)
-- Open menu
end)[/lua]
However, if you are not making a gamemode then you can use what I posted before in autorun.
no, this is a hook, like player spawn or initialspawn. you just need to tell it what to do when it is activated. say if i wanted to search for text i would make the function and all, then i would link it to a hook
hook.add("playersay" , "playersaid", myfunctioniused)
and that would activate the function myfunctioniused.
so you just replace the what nullpoint said, function(um) by yourfunctionname(um) because um is usermessage
So i gotta make an file in the Autorun/server and the other one in autorun/cleint?
[QUOTE=Ningaglio;19799458]no, this is a hook, like player spawn or initialspawn. you just need to tell it what to do when it is activated. say if i wanted to search for text i would make the function and all, then i would link it to a hook
hook.add("playersay" , "playersaid", myfunctioniused)
and that would activate the function myfunctioniused.
so you just replace the what nullpoint said, function(um) by yourfunctionname(um) because um is usermessage[/QUOTE]
What?
[editline]01:34PM[/editline]
[QUOTE=Superkipje;19799469]So i gotta make an file in the Autorun/server and the other one in autorun/cleint?[/QUOTE]
Yes.
[QUOTE=Ningaglio;19799458]no, this is a hook, like player spawn or initialspawn. you just need to tell it what to do when it is activated. say if i wanted to search for text i would make the function and all, then i would link it to a hook
hook.add("playersay" , "playersaid", myfunctioniused)
and that would activate the function myfunctioniused.
so you just replace the what nullpoint said, function(um) by yourfunctionname(um) because um is usermessage[/QUOTE]
He is not calling a function in the hook he is creating a new one
[QUOTE=sweeneypaul;19799648]He is not calling a function in the hook he is creating a new one[/QUOTE]
Don't bother trying to explain something you don't understand.
hook.Add takes a callback function as its third parameter, which is called when the hook type is called. It's similar with usermessages - when it is received, the usermessage hook calls the function that was passed in usermessage.Hook
Thanks i got it working! :D
Now i got an other problem(Not with the derma),
I was making an derma menu to connect to other server but the problem is it doesnt work.
[CODE] RunConsoleCommand( "connect ","77.92.85.203:27015" )[/CODE]
It disconnects the server but after that it says in console
Invalid IP "77.92.85.203:27015"
Anyone haves an solution?
I was having the same problem a few weeks ago, I would also like to know if there is a solution.
Thank you! it worked! :)
[QUOTE=iRzilla;19799815]LocalPlayer():ConCommand("connect 77.92.85.203:27015")[/QUOTE]
Wow, I can't believe I didn't think of that. Thanks.
[editline]02:20PM[/editline]
Wait, now I remember why I didn't use that, I am running this in the Menu environment where LocalPlayer doesn't exist.
[QUOTE=iRzilla;19799925]Yeah, NullPoint you're going to need to use a module or a hacky RunConsoleCommand method something like:
RunConsoleCommand("lol;", "connect ip")
Just toy around using ";"[/QUOTE]
I will give that a try.
Sorry, you need to Log In to post a reply to this thread.