Hello. How do I make it so when a player joins my gamemode, it automatically makes it thirdperson?
shoot a mail to [email]contact@facepunchstudios.com[/email] for more information on this matter
[code]function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
return view
end
hook.Add("CalcView", "TPerson", TPerson)
hook.Add("ShouldDrawLocalPlayer", "ShouldDrawLocalPlayer", function(ply)
return true
end)[/code]
[editline]23rd July 2014[/editline]
[QUOTE=Elexar;45478801]shoot a mail to [email]contact@facepunchstudios.com[/email] for more information on this matter[/QUOTE]
Looks like some of [redacted] spilled out into the GMod forum.
[QUOTE=code_gs;45478931][code]local function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
return view
end
hook.Add("CalcView", "TPerson", TPerson)
hook.Add("ShouldDrawLocalPlayer", "ShouldDrawLocalPlayer", function(ply)
return true
end)[/code]
Not my code, but should work fine. Will look kind of ugly backing into a wall.
[editline]23rd July 2014[/editline]
Looks like some of ktt spilled out into the GMod forum.[/QUOTE]
Thanks!
Edit: What should I set pos, angles, and fov to? Because it says something about angles being nil or something like that.
[QUOTE=code_gs;45478931]
Looks like some of ktt spilled out into the GMod forum.[/QUOTE]
looks like some of ur dad spilled out of the condom lol rekt
[highlight](User was banned for this post ("Either be helpful or don't post! Flaming/trolling" - NiandraLades))[/highlight]
[QUOTE=boynedmaster;45478978]Thanks!
Edit: What should I set pos, angles, and fov to? Because it says something about angles being nil or something like that.[/QUOTE]
Can you post the exact error? [URL="http://wiki.garrysmod.com/page/GM/CalcView"]CalcView[/URL] should provide the correct arguments.
[QUOTE=code_gs;45479439]Can you post the exact error? [URL="http://wiki.garrysmod.com/page/GM/CalcView"]CalcView[/URL] should provide the correct arguments.[/QUOTE]
[code]
[ERROR] gamemodes/xernia/gamemode/shared.lua:9: attempt to index local 'angles' (a nil value)
[/code]
Line 9:
[code]view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)[/code]
oh and also, in case this matters, the player is invisible (except for the weapon)
[QUOTE=boynedmaster;45479508][code]
[ERROR] gamemodes/xernia/gamemode/shared.lua:9: attempt to index local 'angles' (a nil value)
[/code]
Line 9:
[code]view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)[/code]
oh and also, in case this matters, the player is invisible (except for the weapon)[/QUOTE]
That's probably from calling CalcView serverside; it's clientside.
[QUOTE=code_gs;45478931][code]function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
return view
end
hook.Add("CalcView", "TPerson", TPerson)
hook.Add("ShouldDrawLocalPlayer", "ShouldDrawLocalPlayer", function(ply)
return true
end)[/code]
[/QUOTE]
What about camera collisions? It will be OK?
[QUOTE=code_gs;45479674]That's probably from calling CalcView serverside; it's clientside.[/QUOTE]
I'll try that.
Edit:
[code]
[ERROR] gamemodes/xernia/gamemode/cl_init.lua:6: attempt to index local 'angles' (a nil value)
1. TPerson - gamemodes/xernia/gamemode/cl_init.lua:6
2. unknown - gamemodes/xernia/gamemode/cl_init.lua:18
Couldn't Load Init Script: 'xernia/gamemode/cl_init.lua'
[/code]
cl_init:
[code]
include("shared.lua")
function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
return view
end
hook.Add("CalcView", "TPerson", TPerson)
hook.Add("ShouldDrawLoclaPlayer", "ShouldDrawLocalPlayer", function(ply)
return true
end)
TPerson(LocalPlayer())
[/code]
[QUOTE=Dexter127;45479697]What about camera collisions? It will be OK?[/QUOTE]
No, it's probably going to have some clipping issues when walking near walls. I'll try to write a better one soon.
Bump.
A lot of people seem to disregard a very useful function of CalcView which is used in the 3rd-person mode of vehicles. Basically set view.drawviewer = true; and ignore needing the ShouldDrawLocalPlayer hook.
[QUOTE=Acecool;45494928]A lot of people seem to disregard a very useful function of CalcView which is used in the 3rd-person mode of vehicles. Basically set view.drawviewer = true; and ignore needing the ShouldDrawLocalPlayer hook.[/QUOTE]
?
[QUOTE=boynedmaster;45500383]?[/QUOTE]
What is there not to understand about his statement?
[code][SUB][/SUB]
function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
view.drawviewer = true // This basicly removes the need of the hook.
return view
end
hook.Add("CalcView", "TPerson", TPerson)
// hook.Add("ShouldDrawLoclaPlayer", "ShouldDrawLocalPlayer", function(ply)
// return true
//end)
[/code]
Basicly what Ace said, but in the code
[QUOTE=Tomelyr;45500554][code][SUB][/SUB]
function TPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) + (angles:Right()*0) + (angles:Up()*10)
view.angles = angles
view.fov = fov
view.drawviewer = true // This basicly removes the need of the hook.
return view
end
hook.Add("CalcView", "TPerson", TPerson)
// hook.Add("ShouldDrawLoclaPlayer", "ShouldDrawLocalPlayer", function(ply)
// return true
//end)
[/code]
Basicly what Ace said, but in the code[/QUOTE]
Angles still is undefined.
[QUOTE=boynedmaster;45500565]Angles still is undefined.[/QUOTE]
Post your code. I have a feeling you are trying to call it outside of the hook.
[QUOTE=code_gs;45500569]Post your code. I have a feeling you are trying to call it outside of the hook.[/QUOTE]
I did. Look back.
I meant the new code, but this still applies. Delete TPerson(LocalPlayer()).
[QUOTE=code_gs;45500589]I meant the new code, but this still applies. Delete TPerson(LocalPlayer()).[/QUOTE]
Hold on.
Edit: Deleting TPerson seemed to do the trick. I still get the default "no animates all black" figure, but it works.
Sorry, you need to Log In to post a reply to this thread.