Server binding F4 to console command "thirdperson", HELP
13 replies, posted
Hello!
I would like to have the option to switch to thirdperson in my server. I think this is fairly easy to code, but I cannot pull it off (im the biggest lua noob out theere :quagmire: )
My idea is that when a player presses "F4" in the server his console runs the command "thirdperson"
Please help! D:
[CODE]I want my code here :( also, the person making this little code will recieve a lot of points when the server is up! :)[/CODE]
[url]http://lmgtfy.com/?q=gmod+lua+f4+bind[/url]
[highlight](User was banned for this post ("lmgtfy" - Orkel))[/highlight]
[QUOTE=dingusnin;41881474][url]http://lmgtfy.com/?q=gmod+lua+f4+bind[/url][/QUOTE]
Okay haha, I was that far too, but I cannot find the string that does the command in the console and only at that player, because the following code does it serverwide... Some help me?
[CODE]function GM:ShowSpare2( ply )
ply:ConCommand("thirdperson")
end[/CODE]
Doesn't this command require sv_cheats 1? You'll need to code custom 3rd person camera.
[QUOTE=Robotboy655;41881840]Doesn't this command require sv_cheats 1? You'll need to code custom 3rd person camera.[/QUOTE]
Yes, I had to add sv_cheat 1 to my server.cfg. I guess thats not smart from me...?
[QUOTE=Ho7s0;41881853]Yes, I had to add sv_cheat 1 to my server.cfg. I guess thats not smart from me...?[/QUOTE]
Yeah, that will basically allow all users to create entities, use god and buddha commands, so yeah, that's not a smart idea.
No because people can do noclip and god in console.
Okay, I kept the sv_cheat 1 and asked some friends to join. And they were not able to use any command like noclip, god because the ULX Admin doesn't let them to.
Now, back to the lua :p
[CODE]function GM:ShowSpare2( ply )
ply:ConCommand("thirdperson")
end[/CODE]
What is wrong here? (I want only the player that pressed F4 to run "thirdperson" in his console)
I think that's the commands limitation. Try asking one of your friends to enter the command using the console and see if it will force everyone into thirdperson by doing that.
[QUOTE=Robotboy655;41882100]I think that's the commands limitation. Try asking one of your friends to enter the command using the console and see if it will force everyone into thirdperson by doing that.[/QUOTE]
It doesn't, but isn't this the same with a shop? When pressing F3 it opens a shop (!shop)
Then you can try something like this:
[lua]
hook.Add("PlayerBindPress","thirdPersona", function(ply, cmd, pressed)
if ( cmd == "gm_showspare2" && pressed ) then RunConsoleCommand("thirdperson") end
end)
[/lua]
This goes to your [b]cl_init.lua[/b] or anywhere [b]clientside[/b]
[QUOTE=Robotboy655;41882714]Then you can try something like this:
[lua]
hook.Add("PlayerBindPress","thirdPersona", function(ply, cmd, pressed)
if ( cmd == "gm_showspare2" && pressed ) then RunConsoleCommand("thirdperson") end
end)
[/lua]
This goes to your [b]cl_init.lua[/b] or anywhere [b]clientside[/b][/QUOTE]
Thanks for all the work! But when I implement this into my server, on join the player sees himself inside him + the F4 only works when pressed once, the second one doesn't go back to firstperson view.
Anyways, thanks a lot!
[QUOTE=Ho7s0;41882928]Thanks for all the work! But when I implement this into my server, on join the player sees himself inside him + the F4 only works when pressed once, the second one doesn't go back to firstperson view.
Anyways, thanks a lot![/QUOTE]
I don't know what's up with the "camera inside players head" bug, it is also happening to my Hoverboards addon for some reason, (maybe it's ULX problem?), but the "thirdperson" commad isn't supposed to put you back into first person afaik. Try this:
[code]hook.Add("PlayerBindPress","thirdPersona", function(ply, cmd, pressed)
if ( cmd == "gm_showspare2" && pressed && !ply.ThirdPerson ) then
RunConsoleCommand("thirdperson")
ply.ThirdPerson = true
elseif ( cmd == "gm_showspare2" && pressed && ply.ThirdPerson ) then
RunConsoleCommand("firstperson")
ply.ThirdPerson = false
end
end)[/code]
[QUOTE=Robotboy655;41883252]I don't know what's up with the "camera inside players head" bug, it is also happening to my Hoverboards addon for some reason, (maybe it's ULX problem?), but the "thirdperson" commad isn't supposed to put you back into first person afaik. Try this:
[code]hook.Add("PlayerBindPress","thirdPersona", function(ply, cmd, pressed)
if ( cmd == "gm_showspare2" && pressed && !ply.ThirdPerson ) then
RunConsoleCommand("thirdperson")
ply.ThirdPerson = true
elseif ( cmd == "gm_showspare2" && pressed && ply.ThirdPerson ) then
RunConsoleCommand("firstperson")
ply.ThirdPerson = false
end
end)[/code][/QUOTE]
[B]That worked like a charm. Bless you mister Lua king![/B]
[IMG]http://i43.tinypic.com/fue03.jpg[/IMG]
Sorry, you need to Log In to post a reply to this thread.