Hey! I was wondering... How would I make a command that would make you go into third person view?
Example of command:
"!thirdperson" or "ulx thirdperson", etc.? :/
Thanks!
Here you go type in "!3p" into chat to toggle third-person on or off
[CODE]
--Thirdperson for ULX working 16 Aug 2014
if ( CLIENT ) then
local on = false
local function toggle()
on = !on
if on == true then
print( 'enabled' )
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode enabled." )
else
print( 'disabled')
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode disabled." )
end
end
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if on and LocalPlayer():Alive() then
return true
end
end )
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles, fov )
if on and ply:Alive() then
local view = {}
view.origin = pos - ( angles:Forward() * 70 ) + ( angles:Right() * 20 ) + ( angles:Up() * 5 )
view.angles = ply:EyeAngles() + Angle( 1, 1, 0 )
view.fov = fov
return GAMEMODE:CalcView( ply, view.origin, view.angles, view.fov )
end
end )
concommand.Add( "thirdperson_toggle", toggle )
end
if ( SERVER ) then
function ulx.thirdperson( calling_ply )
calling_ply:SendLua([[RunConsoleCommand("thirdperson_toggle")]])
end
local thirdperson = ulx.command( "Utility", "ulx thirdperson", ulx.thirdperson, {"!3p"}, true )
thirdperson:defaultAccess( ULib.ACCESS_ALL )
thirdperson:help( "Toggles third person mode" )
end[/CODE]
[QUOTE=King Traitor;45704834]Here you go type in "!3p" into chat to toggle third-person on or off
[CODE]
--Thirdperson for ULX working 16 Aug 2014
if ( CLIENT ) then
local on = false
local function toggle()
on = !on
if on == true then
print( 'enabled' )
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode enabled." )
else
print( 'disabled')
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode disabled." )
end
end
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if on and LocalPlayer():Alive() then
return true
end
end )
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles, fov )
if on and ply:Alive() then
local view = {}
view.origin = pos - ( angles:Forward() * 70 ) + ( angles:Right() * 20 ) + ( angles:Up() * 5 )
view.angles = ply:EyeAngles() + Angle( 1, 1, 0 )
view.fov = fov
return GAMEMODE:CalcView( ply, view.origin, view.angles, view.fov )
end
end )
concommand.Add( "thirdperson_toggle", toggle )
end
if ( SERVER ) then
function ulx.thirdperson( calling_ply )
calling_ply:SendLua([[RunConsoleCommand("thirdperson_toggle")]])
end
local thirdperson = ulx.command( "Utility", "ulx thirdperson", ulx.thirdperson, {"!thirdperson", "!3p"}, true )
thirdperson:defaultAccess( ULib.ACCESS_ALL )
thirdperson:help( "Toggles third person mode" )
end[/CODE][/QUOTE]
calling_ply:ConCommand("thirdperson_toggle")
I add this where?
[QUOTE] addons / ulx / lua / ulx / modules / sh [/QUOTE]
and then put itinto one of the files or create your own.
Ok cool, now how do I get out of thirdperson?
[QUOTE=UnderYouFive;45706557]Ok cool, now how do I get out of thirdperson?[/QUOTE]
The code toggles the command just type in !3p again
So I typed "!thirdperson"... It didn't do anything, do you HAVE to type "!3p"?
[QUOTE=|Legion|;45722293]So I typed "!thirdperson"... It didn't do anything, do you HAVE to type "!3p"?[/QUOTE]
Not by the looks of it no, but why didn't you just try doing !3p as well before posting?
[QUOTE=|Legion|;45722293]So I typed "!thirdperson"... It didn't do anything, do you HAVE to type "!3p"?[/QUOTE]
Obviously.
Look at the script "{"!thirdperson","
[QUOTE=|Legion|;45722891]Look at the script "{"!thirdperson","[/QUOTE]
Pretty sure ulx.command doesn't even accept tables for command parameters.
[QUOTE=code_gs;45723283]Pretty sure ulx.command doesn't even accept tables for command parameters.[/QUOTE]
That's what I was thinking, but I mean I gave brandonj the benefit of the doubt. My skill < His lol
Well, "!thirdperson" works. I knew it did, I guess I fucked the script up some how, now it works! Thanks!
Whats the dman Script plz tell me!
[editline]22nd December 2014[/editline]
NVM
Good Lua, but with some weapon the 3p is not working well like stun stick arrest stick etc, how we can fix it ?
ty
why did you bump and old thread....
Instead of adding ShouldDrawLocalPlayer hook in all the thirdperson scripts, why not just set view.drawviewer = true; in CalcView... Shorter, easier and everything can be done in one hook ( for display.. control would be InputMouseApply, or whatever.. )
Edit: Dang, I didn't even notice the date either.... This should be locked...
I recently installed this and now after deleting it it's still in my server even after being gone out of my FTP and I can't remove this third person I need help perma removing this from my Server.
[highlight](User was banned for this post ("Dumb Bump" - Kiwi))[/highlight]
Sorry, you need to Log In to post a reply to this thread.