1. Post #361
    aurum481's Avatar
    November 2008
    2,386 Posts
    While raising the timer countdown time would lighten up the calculations it would also have a huge impact on precision on roads like this: http://shrani.si/f/1p/M0/ZdaaBDn/1/example.png

    Hmm, based on speed, I could try to squeeze something out.
    Code:
    distance = distance + LocalPlayer():GetVelocity():Length() / (1 / timer) * 0.00001905
    This is probably lighter?
    so we are stuck on this question
    local distance = 0 --we need this outside the function
    local pos1 = LocalPlayer():GetPos() --initial pos so its not nil and we also need this to save outside func
    function calcDist()
    local pos2 = LocalPlayer():GetPos() --current position vector
    local lenght = pos1:Lenght(pos2)
    distance = distance + lenght --might want to throw in your unit conversion here
    pos1 = pos2 --so we get correct distance next time
    end
    timer.Create("distancecalculate interval",1,0,calcDist) -- check if interval is 1 second and times repeated = infinity

    Again, no way for me to check if this works. Look which way is better for you.
    Damnit page king
    Reply With Quote Edit / Delete Lithuania Show Events

  2. Post #362
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    Could someone explain how I could make this camera rotate from a y axis around to move the camera slowly in front of me instead of just snapping to this view?
    hook.Add("CalcView", "CalcTheView", function(ply, pos, angles, fov)
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = (LocalPlayer():EyePos() - view.origin):Angle()
        view.fov = fov
        return view
    end)
     
    hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply)
           return true
    end
    
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  3. Post #363
    ~ ducks ~
    Kwaq's Avatar
    April 2011
    2,323 Posts
    how do i get an int value of player velocity and remove Z (up down)? i just want a value that shows directional velocity (flat surface)
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  4. Post #364
    pennerlord's Avatar
    February 2011
    501 Posts
    Could someone explain how I could make this camera rotate from a y axis around to move the camera slowly in front of me instead of just snapping to this view?
    hook.Add("CalcView", "CalcTheView", function(ply, pos, angles, fov)
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = (LocalPlayer():EyePos() - view.origin):Angle()
        view.fov = fov
        return view
    end)
     
    hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply)
           return true
    end
    

    I haven't worked with CalcView yet, but I think you need this:
    G.RealTime
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  5. Post #365
    SFArial's Avatar
    May 2009
    1,174 Posts
    how do i get an int value of player velocity and remove Z (up down)? i just want a value that shows directional velocity (flat surface)
    local dir = player:GetVelocity()
    dir.z = 0
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events Lua Helper Lua Helper x 1 (list)

  6. Post #366
    Fantym420's Avatar
    October 2010
    892 Posts
    Could someone explain how I could make this camera rotate from a y axis around to move the camera slowly in front of me instead of just snapping to this view?
    hook.Add("CalcView", "CalcTheView", function(ply, pos, angles, fov)
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = (LocalPlayer():EyePos() - view.origin):Angle()
        view.fov = fov
        return view
    end)
     
    hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply)
           return true
    end
    
    This is what I do:

    Create a variable to store the last time and one for last Angle

    Then in CalcView make a variable to store the delta from CurTime() and lastTime

    Set lastTime to CurTime()

    LerpAngle the new angle with the last angle using the delta time for the percent

    Set lastAngle to the new Lerp'd Angle

    Repeat

    like this

    local lastCalcView = CurTime()
    local lastAngle = Angle(0,0,0)
    
    function MyCalcView(ply, pos, angles, fov)
    
        local deltaTime = CurTime() - lastCalcView
        lastCalcView = CurTime()
    
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = LerpAngle(deltaTime, lastAngle, (LocalPlayer():EyePos() - view.origin):Angle())
        lastAngle = view.angles
        view.fov = fov
        return view
    end
    hook.Add("CalcView", "CalcTheView", MyCalcView)
    
    


    not tested, but that's how it should work, if the angles aren't going fast enough multiply the deltaTime part of LerpAngle.

    Hope that helps.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  7. Post #367
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,547 Posts
    What the hell does this error mean?

    Code:
    [autorun\client\cl_test.lua:24] attempt to call local 'TestMenu' (a userdata value)
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  8. Post #368
    PENISCORP DIRECTOR
    Gran PC's Avatar
    August 2007
    3,087 Posts
    Thanks for giving us the code so we can see how you caused it.
    Reply With Quote Edit / Delete Windows 7 Spain Show Events Funny Funny x 2 (list)

  9. Post #369
    Title

    August 2009
    300 Posts
    if ((t == TEAM_SUPERTHIEF || t == TEAM_HITMAN || t == TEAM_MERCENARY || t == TEAM_EXGOV || t == TEAM_SNIPER) and not self:IsUserGroup("vip") || self:IsUserGroup("admin") || self:IsUserGroup("superadmin")) then
    

    I did this and it works however only being in group VIP works, if you are in admin or superadmin it still says you need to be VIP. I'm guessing it's my brackets or something.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  10. Post #370
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,264 Posts
    if ((t == TEAM_SUPERTHIEF || t == TEAM_HITMAN || t == TEAM_MERCENARY || t == TEAM_EXGOV || t == TEAM_SNIPER) and not self:IsUserGroup("vip") || self:IsUserGroup("admin") || self:IsUserGroup("superadmin")) then
    

    I did this and it works however only being in group VIP works, if you are in admin or superadmin it still says you need to be VIP. I'm guessing it's my brackets or something.
    I can only guess if this is what you are trying to achieve:

    if (t == TEAM_SUPERTHIEF || t == TEAM_HITMAN || t == TEAM_MERCENARY || t == TEAM_EXGOV || t == TEAM_SNIPER)
    	and not (self:IsUserGroup("vip") || self:IsUserGroup("admin") || self:IsUserGroup("superadmin"))
    then
    
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Lua Helper Lua Helper x 1 (list)

  11. Post #371
    Title

    August 2009
    300 Posts
    I can only guess if this is what you are trying to achieve:

    if (t == TEAM_SUPERTHIEF || t == TEAM_HITMAN || t == TEAM_MERCENARY || t == TEAM_EXGOV || t == TEAM_SNIPER)
    	and not (self:IsUserGroup("vip") || self:IsUserGroup("admin") || self:IsUserGroup("superadmin"))
    then
    
    What did you change?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  12. Post #372
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,264 Posts
    I added brackets to group the different usergroups. I assume that was your intention.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 1 (list)

  13. Post #373
    Title

    August 2009
    300 Posts
    I added brackets to group the different usergroups. I assume that was your intention.
    Ah right I see, yeah that works. I thought it was brackets or something. Thanks.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Friendly Friendly x 1 (list)

  14. Post #374
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,547 Posts
    Thanks for giving us the code so we can see how you caused it.
    Well, I was actually only needing a explanation about what the error means, not how to fix it.

    Edited:

    In case, this is the line.

    local TestMenu = vgui.Create( "DFrame" )

    Edited:

    Ah, finally got it working. But it seems like I can't include my sh_test.lua as it says
    Code:
    Couldn't include file 'autorun\sh_test.lua' (File not found) (@autorun\client\cl_test.lua (line 1))
    No clue why, as my sv_test.lua finds it?

    After looking through my code 1000 more times I finally managed to fix it.
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  15. Post #375
    Gold Member
    ralle105's Avatar
    October 2005
    4,629 Posts
    What the hell does this error mean?

    Code:
    [autorun\client\cl_test.lua:24] attempt to call local 'TestMenu' (a userdata value)
    Well, I was actually only needing a explanation about what the error means, not how to fix it.

    Edited:

    In case, this is the line.

    local TestMenu = vgui.Create( "DFrame" )
    It means that somewhere in your code you're doing TestMenu() ie trying to call TestMenu as a function. But TestMenu is a vgui component (userdata) hence the error.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Friendly Friendly x 1 (list)

  16. Post #376
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,432 Posts
    does file.Size work properly in retail GMod? Specifically for files NOT in the data folder.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 2 (list)

  17. Post #377
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    This is what I do:

    Create a variable to store the last time and one for last Angle

    Then in CalcView make a variable to store the delta from CurTime() and lastTime

    Set lastTime to CurTime()

    LerpAngle the new angle with the last angle using the delta time for the percent

    Set lastAngle to the new Lerp'd Angle

    Repeat

    like this

    local lastCalcView = CurTime()
    local lastAngle = Angle(0,0,0)
    
    function MyCalcView(ply, pos, angles, fov)
    
        local deltaTime = CurTime() - lastCalcView
        lastCalcView = CurTime()
    
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = LerpAngle(deltaTime, lastAngle, (LocalPlayer():EyePos() - view.origin):Angle())
        lastAngle = view.angles
        view.fov = fov
        return view
    end
    hook.Add("CalcView", "CalcTheView", MyCalcView)
    
    


    not tested, but that's how it should work, if the angles aren't going fast enough multiply the deltaTime part of LerpAngle.

    Hope that helps.
    Thank you so much it worked! How would I lock it to start at a certain angle always? ex. When I look at the ground I see all black and that's not what I want.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  18. Post #378
    G-Enigma's Avatar
    June 2011
    326 Posts
    Is there any reason that this simple reload code :
    Code:
    if self.Owner:KeyPressed(IN_RELOAD) then	
    		self.Busy = true
    		self.Weapon:DefaultReload(ACT_VM_RELOAD) 
    		self.Busy = false
    	end
    Would still be interrupted by this ironsights code:
    Code:
             if self.Owner:KeyPressed(IN_ATTACK2) and self.Busy == false then
    				if !self.Owner:KeyDown(IN_DUCK) and !self.Owner:KeyDown(IN_WALK) then
    				self:SetWeaponHoldType("rpg") else self:SetWeaponHoldType("ar2")  
    				end  
    			self.Weapon:SetNextPrimaryFire(CurTime()+0.3)
    			self.Owner:SetFOV( self.Secondary.IronFOV, 0.3 )
    			self.IronSightsPos = self.SightsPos					// Bring it up
    			self.IronSightsAng = self.SightsAng					// Bring it up
    			self:SetIronsights(true, self.Owner)
    			self:SendWeaponAnim(ACT_VM_LOWERED_TO_IDLE)
    			self.Ironsighted = true
    			-- Set the ironsight true
    
    			if CLIENT then return end
     	end
    except that in the ironsights code, only the animation, (ACT_VM_LOWERED_TO_IDLE) is played, while the rest of the function acts as if the self.Busy check is working.

    PS: Basically what I'm trying to do is prevent the player cutting short the reload animation by ironsighting (which plays an ironsighting animation). The offending (?) code is underlined.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  19. Post #379
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    It looks like you're setting the weapon to busy, playing the animation, and then immediately setting it back to not be busy. You'll need to add a timer with the duration of the animation that runs self.Busy = false, rather than what you're doing.

    Edit:

    This may do the trick.

    if self.Owner:KeyPressed(IN_RELOAD) then	
    	self.Busy = true
    	self.Weapon:DefaultReload(ACT_VM_RELOAD) 
    		
    	local animationDuration = 1.5 	-- set this to the duration of
    									-- the reload animation, in seconds
    	timer.Simple( animationDuration, function()
    		self.Busy = false
    	end )
    end
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua Helper Lua Helper x 1 (list)

  20. Post #380
    DefaultText.ini
    Charrax's Avatar
    February 2011
    1,339 Posts
    I need help with Lua itself. Arguments confuse the shit out of me. Oh and hooks.

    Can somebody nice please point me in the right direction?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  21. Post #381
    G-Enigma's Avatar
    June 2011
    326 Posts
    It looks like you're setting the weapon to busy, playing the animation, and then immediately setting it back to not be busy. You'll need to add a timer with the duration of the animation that runs self.Busy = false, rather than what you're doing.
    Well thanks, *cough*, better come clean, *cough*... I literally have no freaking coding background whatsoever, just started fiddling with gmod Swep coding a few months ago, so...
    How would I do that, exactly?

    I need help with Lua itself. Arguments confuse the shit out of me. Oh and hooks.

    Can somebody nice please point me in the right direction?
    Try dis: http://maurits.tv/data/garrysmod/wik...utorial_Series
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  22. Post #382
    DefaultText.ini
    Charrax's Avatar
    February 2011
    1,339 Posts
    Thank you :)
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  23. Post #383
    G-Enigma's Avatar
    June 2011
    326 Posts
    It looks like you're setting the weapon to busy, playing the animation, and then immediately setting it back to not be busy. You'll need to add a timer with the duration of the animation that runs self.Busy = false, rather than what you're doing.

    Edit:

    This may do the trick.

    if self.Owner:KeyPressed(IN_RELOAD) then	
    	self.Busy = true
    	self.Weapon:DefaultReload(ACT_VM_RELOAD) 
    		
    	local animationDuration = 1.5 	-- set this to the duration of
    									-- the reload animation, in seconds
    	timer.Simple( animationDuration, function()
    		self.Busy = false
    	end )
    end
    Well, thanks for trying to help, but it seems that ironsighting animation is too stubborn to be defeated so easily :(
    Even if I remove the "Self.Busy = false" at the end of the reload, the ironsight animation still plays, even though the code above and below it doesn't.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #384
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    Try changing self.Busy == false to !self.Busy
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  25. Post #385
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    How would I lock it to start at a certain angle always? ex. When I look at the ground I see all black and that's not what I want.

    local lastCalcView = CurTime()
    local lastAngle = Angle(0,0,0)
     
    function MyCalcView(ply, pos, angles, fov)
     
        local deltaTime = CurTime() - lastCalcView
        lastCalcView = CurTime()
     
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = LerpAngle(deltaTime, lastAngle, (LocalPlayer():EyePos() - view.origin):Angle())
        lastAngle = view.angles
        view.fov = fov
        return view
    end
    hook.Add("CalcView", "CalcTheView", MyCalcView)
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  26. Post #386
    G-Enigma's Avatar
    June 2011
    326 Posts
    Try changing self.Busy == false to !self.Busy
    :(
    Maybe the check is glitchy, or if it sees an animation with no other animation to play if the check fails, then it just plays the animation anyway.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  27. Post #387
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    How would I lock it to start at a certain angle always? ex. When I look at the ground I see all black and that's not what I want.

    local lastCalcView = CurTime()
    local lastAngle = Angle(0,0,0)
     
    function MyCalcView(ply, pos, angles, fov)
     
        local deltaTime = CurTime() - lastCalcView
        lastCalcView = CurTime()
     
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = LerpAngle(deltaTime, lastAngle, (LocalPlayer():EyePos() - view.origin):Angle())
        lastAngle = view.angles
        view.fov = fov
        return view
    end
    hook.Add("CalcView", "CalcTheView", MyCalcView)
    You could change the components of view.angles. For example,
    view.angles.p = 0

    :(
    Maybe the check is glitchy, or if it sees an animation with no other animation to play if the check fails, then it just plays the animation anyway.
    That doesn't sound right. Maybe you're changing the animation somewhere else?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #388
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    You could change the components of view.angles. For example,
    view.angles.p = 0



    That doesn't sound right. Maybe you're changing the animation somewhere else?
    Well I still need to to make the animation of moving to the player but I don't want it to be underground if a player looks up.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  29. Post #389
    Fantym420's Avatar
    October 2010
    892 Posts
    How would I lock it to start at a certain angle always? ex. When I look at the ground I see all black and that's not what I want.

    local lastCalcView = CurTime()
    local lastAngle = Angle(0,0,0)
     
    function MyCalcView(ply, pos, angles, fov)
     
        local deltaTime = CurTime() - lastCalcView
        lastCalcView = CurTime()
     
        local view = {}
        view.origin = LocalPlayer():GetPos()-(LocalPlayer():GetAngles():Forward()*60)+Vector(0,-10,50)
        view.angles = LerpAngle(deltaTime, lastAngle, (LocalPlayer():EyePos() - view.origin):Angle())
        lastAngle = view.angles
        view.fov = fov
        return view
    end
    hook.Add("CalcView", "CalcTheView", MyCalcView)
    just set the line lastAngle = Angle(0,0,0) to whatever angle you want to start with like
    local lastAngle = Angle(90,0,45)  -- Would be 90 deg. pitch, 0 deg. yaw, 45 deg. roll
    

    and if you don't want the player to be able to look around with the mouse add
    ply:SetEyeAngles(lastAngle)
    

    as the last line of the calcview function.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #390
    G-Enigma's Avatar
    June 2011
    326 Posts
    You could change the components of view.angles. For example,
    view.angles.p = 0



    That doesn't sound right. Maybe you're changing the animation somewhere else?
    No, the only time that animation is set to play is when you ironsight in.
    what about "If CLIENT then return end"?
    What does that do :~0 ?
    Reply With Quote Edit / Delete Windows XP United States Show Events

  31. Post #391
    Title

    August 2009
    300 Posts
    No, the only time that animation is set to play is when you ironsight in.
    what about "If CLIENT then return end"?
    What does that do :~0 ?
    Checks if the script is being ran by the client, if so end the function or w/e.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  32. Post #392
    G-Enigma's Avatar
    June 2011
    326 Posts
    Checks if the script is being ran by the client, if so end the function or w/e.
    Well, I don't think thats causing it. :(
    Reply With Quote Edit / Delete Windows XP United States Show Events

  33. Post #393
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    No, the only time that animation is set to play is when you ironsight in.
    what about "If CLIENT then return end"?
    What does that do :~0 ?
    LMFAO I just realised he answered my question and then your question in his post hahaha,,,
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  34. Post #394

    February 2012
    34 Posts
    I need help! I just got into LUA, and i started out making NPCs, this code like wont work, it doesnt detect my NPC in the spawn list, like its not in there, and I am coding it right! Here is three codes, my code, my original startng code, and a metropolice code showing mine isnt incorrect.

    Metro Police-
    local Category = "Other Civil Protection"

    local NPC = { Name = "Elite Shock Unit",
    Class = "npc_combine_s",
    Model = "models/leet_police2.mdl",
    Health = "200",
    Category = Category }

    list.Set( "NPC", "npc_elitecop", NPC )

    Mine-
    local NPC = { Name = "SAS NPC",
    Class = "npc_combine_s",
    Model = "models/player/ct_sas.mdl",
    Health = "25000",
    Category = Animals}

    list.Set( "NPC", "SAS", NPC

    My starting code-
    local NPC = { Name = "Name here",
    Class = "npc_citizen",
    Model = "models/name_here.mdl",
    Health = "250",
    Category = Category }

    list.Set( "NPC", "npc_name_here", NPC )

    see? there is no prob;lem! :'(
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #395
    PENISCORP DIRECTOR
    Gran PC's Avatar
    August 2007
    3,087 Posts
    Use [lua] tags and tell us the error. I can see two - you're missing a ) after list.Set and category should be Category = "Animals".
    Reply With Quote Edit / Delete Windows 7 Spain Show Events

  36. Post #396

    July 2007
    864 Posts
    I need help! I just got into LUA, and i started out making NPCs, this code like wont work, it doesnt detect my NPC in the spawn list, like its not in there, and I am coding it right! Here is three codes, my code, my original startng code, and a metropolice code showing mine isnt incorrect.

    Metro Police-
    local Category = "Other Civil Protection"

    local NPC = { Name = "Elite Shock Unit",
    Class = "npc_combine_s",
    Model = "models/leet_police2.mdl",
    Health = "200",
    Category = Category }

    list.Set( "NPC", "npc_elitecop", NPC )

    Mine-
    local NPC = { Name = "SAS NPC",
    Class = "npc_combine_s",
    Model = "models/player/ct_sas.mdl",
    Health = "25000",
    Category = Animals}

    list.Set( "NPC", "SAS", NPC

    My starting code-
    local NPC = { Name = "Name here",
    Class = "npc_citizen",
    Model = "models/name_here.mdl",
    Health = "250",
    Category = Category }

    list.Set( "NPC", "npc_name_here", NPC )

    see? there is no prob;lem! :'(
    Use [lua] tags and tell us the error. I can see two - you're missing a ) after list.Set and category should be Category = "Animals".
    http://www.facepunch.com/threads/1165921

    Not like I've already told you so. Comeon..
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  37. Post #397
    Title

    August 2009
    300 Posts
    I'm currently doing

    function MyCalcView(ply, pos, angles, fov)
    	gui.EnableScreenClicker(true)
        local view = {}
        view.origin = pos+(angles:Up()*300)
        view.angles = Angle(90,0,0)
        view.fov = fov
        return view
    end

    To set my camera up and facing down onto the player, however my player faces the wrong way (everything is opposite like WASD is reversed). I'm needing it to aim where my mouse is or w/e. How would I go about doing this?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  38. Post #398
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    I'm currently doing

    function MyCalcView(ply, pos, angles, fov)
    	gui.EnableScreenClicker(true)
        local view = {}
        view.origin = pos+(angles:Up()*300)
        view.angles = Angle(90,0,0)
        view.fov = fov
        return view
    end

    To set my camera up and facing down onto the player, however my player faces the wrong way (everything is opposite like WASD is reversed). I'm needing it to aim where my mouse is or w/e. How would I go about doing this?
    Try this

    function MyCalcView(ply, pos, angles, fov)
    	gui.EnableScreenClicker(true)
    	local view = {}
    	view.origin = pos+(angles:Up()*300)
    	
    	local myAng = angles
    	myAng.p = 90
    	
    	view.angles = myAng
    	view.fov = fov
    	return view
    end

    It's using the player's rotation to determine the angles, but setting the pitch to 90. It should turn with the player.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #399
    Title

    August 2009
    300 Posts
    Try this

    function MyCalcView(ply, pos, angles, fov)
    	gui.EnableScreenClicker(true)
    	local view = {}
    	view.origin = pos+(angles:Up()*300)
    	
    	local myAng = angles
    	myAng.p = 90
    	
    	view.angles = myAng
    	view.fov = fov
    	return view
    end

    It's using the player's rotation to determine the angles, but setting the pitch to 90. It should turn with the player.
    The player faces the correct direction now, however moving the mouse doesn't rotate the player :( The hook is hook.Add("CalcView", "MyCalcView", MyCalcView)

    Aha, you are the one who made the top-down shooter right? It's made me want to develop my old gamemode again but getting stuck with this. I'm pretty much trying to get what you made in that video.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  40. Post #400
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    Ah. Well for one, I don't have the screen clicker enabled. That's probably why you can't rotate with the mouse. I'd remove the "gui.EnableScreenClicker(true)" line and limit the player's range some other way.
    Reply With Quote Edit / Delete Windows 7 United States Show Events