Hello! So I am developing a dedicated Gmod Server and there is a job where the model is a dog... for this job I wanted to set the view of the player closer to the model's actual view height. For this, in the PlayerSpawn function i set a piece to say "ply:SetViewOffset(Vector(0,0,40))" however this changes the player's view height permanently. Here is the full class:
[code]
TEAM_ASQUIRTLE = DarkRP.createJob("A Healing Kitty", {
level = 1,
color = Color(0, 0, 0, 255),
model = "models/player_sylveon.mdl",
description = [[Heal your master meow meow!]],
weapons = {"weapon_medkit", "weapon_pet"},
command = "asquirtle",
max = 1,
salary = 500,
admin = 0,
vote = false,
category = "Custom Classes",
hasLicense = false,
//customCheck = function(ply) return ply:SteamID() == "STEAM_0:0:74109730" end, --Commented out for testing on the server--
CustomCheckFailMsg = "This job is Petra Ral's class only!",
PlayerSpawn = function(ply)
if( ply:Team() == TEAM_ASQUIRTLE ) then
ply:SetRunSpeed(450)
ply:SetWalkSpeed(250)
ply:SetViewOffset(Vector(0,0,40))
end
end
})
[/code]
Since you are required to respawn when switching jobs, I put another function in saying:
[code]
PlayerDeath = function(ply)
ply:SetViewOffset(Vector(0,0,100))
end
[/code]
thinking that when you switch jobs, you would die and it would reset your height... this didn't work. I also tried a OnPlayerChangedTeam function...
[code]
OnPlayerChangedTeam = function(ply)
ply:SetViewOffset(Vector(0,0,100))
end
[/code]
that didn't work. Then i removed the SetViewOffset from the job and tried a custom function: Keep in mind I never really made my own function before...
[code]
WorkYouDamnThing = function(ply) if (ply:Team() == TEAM_ASQUIRTLE) then ply:SetViewOffset(Vector(0,0,40)) else then return false end end
// Also Tried
WorkYouDamnThing = function(ply) if (ply:Team() == TEAM_ASQUIRTLE) then ply:SetViewOffset(Vector(0,0,40)) else then return end end
//Also Tried
WorkYouDamnThing = function(ply) if (ply:Team() == TEAM_ASQUIRTLE) then ply:SetViewOffset(Vector(0,0,40)) else then return false end
[/code]
I then started looking anywhere online... and couldn't find anything helpful. I could go through all the other classes and add the ply:SetViewOffset(Vector(0,0,100)) to them, but their are 57 more classes and I would like it so that the other classes don't have to be touched. Any suggestions or ideas?
Thank you!
Just wanted to bump this. It was on the second page and I didn't want anyone that could help to miss it!
[code]
PlayerSpawn = function(ply)
if( ply:Team() == TEAM_ASQUIRTLE ) then
ply:SetRunSpeed(450)
ply:SetWalkSpeed(250)
ply:SetViewOffset(Vector(0,0,40))
end
end
})
[/code]
So this didnt work at all?
[editline]2nd March 2016[/editline]
Make a file in /lua/autorun/ with this code:
[code]
function GM:PlayerSpawn( ply )
if ply:Team() == TEAM_ASQUIRTLE then ply:SetViewOffset(Vector(0,0,40)
else then ply:SetViewOffset(Vector(0,0,100)
end
end
[/code]
So this worked:
[code]
PlayerSpawn = function(ply)
if( ply:Team() == TEAM_ASQUIRTLE ) then
ply:SetRunSpeed(450)
ply:SetWalkSpeed(250)
ply:SetViewOffset(Vector(0,0,40))
end
end
})
[/code]
except it would set the view offset permanently until they left and rejoined the server. So if they switched to another class they would still be looking at a view from the floor. I will try the function in autorun and see if it works. Thank you
Add:
[code]
PlayerDeath = function( ply )
ply:SetRunSpeed(<lazy, set this to default>)
ply:SetWalkSpeed(<lazy, set this to default>)
ply:SetViewOffset(Vector(<lazy, set this to default>))
end
[/code]
[editline]2nd March 2016[/editline]
However, I'm not sure if they change jobs that it will change it. Just try it out and let me know.
Sorry, you need to Log In to post a reply to this thread.