1. Post #161
    Jinx786's Avatar
    October 2010
    380 Posts
    I fixed it I guess I had the "C" in colors capitalized
    Get gmod lua syntax highlighter, it will light up correct syntax:
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  2. Post #162
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    Get gmod lua syntax highlighter, it will light up correct syntax:
    That only works for GMod functions/variables, his problem was he mistyped his own variable "Colors" (not the GMod object Color) with an incorrect case, which a syntax highlighter wouldn't pick up.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  3. Post #163
    Jinx786's Avatar
    October 2010
    380 Posts
    That only works for GMod functions/variables, his problem was he mistyped his own variable "Colors" (not the GMod object Color) with an incorrect case, which a syntax highlighter wouldn't pick up.
    Sorry, my mistake.
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events Friendly Friendly x 2 (list)

  4. Post #164
    Gold Member
    confinedUser's Avatar
    October 2008
    3,534 Posts
    ok so as far as errors go, their fixed but as for displaying thats another thing. Oh also Jinx I already have the highlighter
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  5. Post #165
    Title

    August 2009
    300 Posts
    I'm trying to set the client's camera position however it doesn't seem to be working.

    function PlayerSpawn( ply )
    	orig = ply:EyePos()
    	ply:EyePos(orig + Vector(0,100,0))
    end
    hook.Add("PlayerSpawn","PlayerSpawn",PlayerSpawn)
    

    It doesn't do anything.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  6. Post #166
    PencilOnDesk's Avatar
    October 2011
    120 Posts
    function bloodtest()
    	for k,v in pairs(player.GetAll()) do
     		if v:Health() >= 25 then 
     			if timer.IsTimer("NextBleedOut") then
     				timer.Destroy("NextBleedOut")
     			end
     		end
     		if v:Health() <= 24 then
     			if timer.IsTimer("NextBleedOut") then return end
     			timer.Create("NextBleedOut",1,0,function()
    				local Pos = v:GetPos() + Vector(0,0,30)
    				local effectdata = EffectData()
    				effectdata:SetStart( Pos )
    				effectdata:SetOrigin( Pos )
    				effectdata:SetScale( 1 )
    				util.Effect( "BloodImpact", effectdata )
    				local trace = {};
    				trace.start = v:GetPos() + Vector(0, 0, 256);
    				trace.endpos = trace.start + Vector(0, 0, -1024);
    				trace.filter = v;
    				trace2 = util.TraceLine(trace);
     				util.Decal("Blood", trace2.HitPos + trace2.HitNormal, trace2.HitPos - trace2.HitNormal)
    
    			end)
    		end
    	end
    end
    hook.Add("Think","Bloodoasdf",bloodtest)
    
    hook.Add("PlayerDeath","ClearTimers", function()
    	if timer.IsTimer("NextBleedOut") then
    		timer.Destroy("NextBleedOut")
    	end
    end)

    Trying to work on some sort of bleeding system where the decal is drawn under the player; However at the moment the Decal only gets drawn when the player dies. Why is this?
    Bump
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  7. Post #167
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,431 Posts
    I'm trying to set the client's camera position however it doesn't seem to be working.

    function PlayerSpawn( ply )
    	orig = ply:EyePos()
    	ply:EyePos(orig + Vector(0,100,0))
    end
    hook.Add("PlayerSpawn","PlayerSpawn",PlayerSpawn)
    
    It doesn't do anything.
    http://maurits.tv/data/garrysmod/wik...r.SetEyeAngles
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 1 (list)

  8. Post #168
    Title

    August 2009
    300 Posts
    I cant seem to get this worked out, I'm playing around with the settings but it's confusing me.
    What I'm wanting is the camera to be about 100 units or so away from the player facing the side of the player (Z Axis) Ill later then make it so the play can only walk on the X axis.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  9. Post #169
    Gold Member
    marvincmarvin's Avatar
    January 2011
    795 Posts
    local Colors =
    {
        border = Color( 255, 255, 255, 255),
        background = Color( 255, 255, 255, 200 ),
        shade = Color( 255, 255, 255, 255 ),
        fill = Color( 0, 0, 0, 255 )-- , <- This comma does not belong.
    };
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #170
    SFArial's Avatar
    May 2009
    1,174 Posts
    I cant seem to get this worked out, I'm playing around with the settings but it's confusing me.
    What I'm wanting is the camera to be about 100 units or so away from the player facing the side of the player (Z Axis) Ill later then make it so the play can only walk on the X axis.
    Use this.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events Agree Agree x 2Lua Helper Lua Helper x 1 (list)

  11. Post #171
    Title

    August 2009
    300 Posts
    Thank you :) Also, this has worked for me:

        local view = {}
        view.origin = pos-(angles:Right()*-300)
        view.angles = angles + Angle(0,90,0)
        view.fov = fov
        return view
    

    How would I go about locking the camera from moving? Basically rendering the mouse useless.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  12. Post #172
    SFArial's Avatar
    May 2009
    1,174 Posts
    Thank you :) Also, this has worked for me:

        local view = {}
        view.origin = pos-(angles:Right()*-300)
        view.angles = angles + Angle(0,90,0)
        view.fov = fov
        return view
    

    How would I go about locking the camera from moving? Basically rendering the mouse useless.
    I'm not quite sure what you mean. Like disabling the ability to look around with the mouse?
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  13. Post #173
    Title

    August 2009
    300 Posts
    I'm not quite sure what you mean. Like disabling the ability to look around with the mouse?
    Yes, the gamemode that I'm doing is based around the side view of a player, ill also need to somehow make A and D do what W and S do as the camera is beside the player (angled to face the player). I don't want people moving the camera as you can bug it out the world.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  14. Post #174
    Fantym420's Avatar
    October 2010
    892 Posts
    Yes, the gamemode that I'm doing is based around the side view of a player, ill also need to somehow make A and D do what W and S do as the camera is beside the player (angled to face the player). I don't want people moving the camera as you can bug it out the world.
    I am also working on a game mode where the camera is on auto with no player interaction, the way I've been locking the view is to set the player's eye angles every calcview run like this
    ply:SetEyeAngles(view.angle)
    

    I do this at the end of calcview and if the player moves the mouse it shakes the screen but it goes back to where it's supposed to look.

    There is probably a better way to do this, and hopefully someone else can shed some light on the subject.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  15. Post #175
    SFArial's Avatar
    May 2009
    1,174 Posts
    This is a piece of code taken from Ascension, with maybe slight differences:

    function GM:CreateMove(cmd)
    	if LocalPlayer():Alive() then
    		gui.EnableScreenClicker(true)
    		local mx,my = gui.MousePos()
    		local pos = LocalPlayer():GetShootPos():ToScreen()
    		pos = Vector(pos.x,pos.y,0)
    		
    		local ang = (Vector(mx,my,0)-pos):Angle()
    		ang.p = ang.y
    		ang:RotateAroundAxis(Vector(0,0,1),180)
    		
    		local move = cmd:GetSideMove()
    		cmd:SetForwardMove(0)
    		cmd:SetSideMove(0)
    		
    		if mx < pos.x then
    			ang.y = 0
    			cmd:SetForwardMove(-move)
    		else
    			ang.y = 180
    			cmd:SetForwardMove(move)
    		end
    		
    		cmd:SetViewAngles(ang)
    	end
    end
    

    It will take care of all the movement and camera related issues.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  16. Post #176
    Gold Member
    ralle105's Avatar
    October 2005
    4,627 Posts
    local Colors =
    {
        border = Color( 255, 255, 255, 255),
        background = Color( 255, 255, 255, 200 ),
        shade = Color( 255, 255, 255, 255 ),
        fill = Color( 0, 0, 0, 255 )-- , <- This comma does not belong.
    };
    It doesn't break anything though, lua just ignores it just like it ignores semi colons.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  17. Post #177

    January 2012
    10 Posts
    Hello

    local NoDrop = {"weapon_real_cs_scout", "weapon_real_cs_flash"} -- Drop blacklist
    local function DropWeapon(ply)
    	local ent = ply:GetActiveWeapon()
    	if not ValidEntity(ent) then return "" end

    Im trying to add this scout sniper and the flashbang to NoDrop but it doesnt work, any idea whats wrong ?
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  18. Post #178
    werewolf0020's Avatar
    October 2009
    5,619 Posts
    has anyone done an sort of prop placing system? kinda like in RTS Games where when you select a building if there are no objects colliding with it and the terrain is flat it changes its colour to green/red i am triying to do someting similar but im kinda stuck showing it about a few metters away from the player Sight and well..Spawning/Creating the prop itself on the end point
    Reply With Quote Edit / Delete Windows 7 Venezuela Show Events

  19. Post #179
    SFArial's Avatar
    May 2009
    1,174 Posts
    has anyone done an sort of prop placing system? kinda like in RTS Games where when you select a building if there are no objects colliding with it and the terrain is flat it changes its colour to green/red i am triying to do someting similar but im kinda stuck showing it about a few metters away from the player Sight and well..Spawning/Creating the prop itself on the end point
    I don't quite understand where you are stuck, but the way I would make something like this is set up some kind of a grid system for the map and then either setting how many squares a building takes up or using the collision bounds of that prop and then checking if these squares around the prop are already occupied or not. I could draw it in paint if you need me to clarify.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  20. Post #180
    pennerlord's Avatar
    February 2011
    501 Posts
    Is it possible to make a rope between a prop and a swep that is hold by a player?

    My code:
    function SWEP:PrimaryAttack()
    	local ent = self:CreateTaser()
    	
    	local phys = ent:GetPhysicsObject()
    	if not phys:IsValid() then return end
    	phys:SetVelocity(self.Owner:GetAimVector() * 3000)
    	
    	-- Rope start
    	local ent1, ent2 = ent, self
    	local wPos1, wPos2 = ent1:GetPos(), ent2:GetPos()
    	local length = (wPos1 - wPos2):Length()
    	
    	local constraint, rope = constraint.Rope(ent1, ent2, 0, 0, Vector(0,0,0), Vector(0,0,0), length, 1000, 0, 3, "cable/cable", false)
    	-- Rope end
    end
    

    However when I'm using "self.Owner" instead of "self" it's working, but the rope is parented to the player and not his weapon.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  21. Post #181
    werewolf0020's Avatar
    October 2009
    5,619 Posts
    I don't quite understand where you are stuck, but the way I would make something like this is set up some kind of a grid system for the map and then either setting how many squares a building takes up or using the collision bounds of that prop and then checking if these squares around the prop are already occupied or not. I could draw it in paint if you need me to clarify.
    Ok first i am triying to do someting similar to This



    Minute 0-07,0-10

    As you can see the Buildings follows the player mouse and switches its colour if its placeable or not

    Now what i want is that instead of doing an RTS View handle it trough the FPS View basicly put the "Building" a few metters away so far i have a trace and well i guess the end point of the trace is where i should "Spawn" or create the building entity Now i have to do the same trace Every frame and set the building/entity position to the Trace end location too? or theres a simplier way to do it?
    Reply With Quote Edit / Delete Windows 7 Venezuela Show Events Optimistic Optimistic x 1 (list)

  22. Post #182
    Casual Bananas
    E X C L's Avatar
    February 2011
    1,709 Posts
    Has anyone ever experienced this before?
    The playermodel is turned 90 degrees for some reason, their gun and torso face 90 degrees away.
    Reply With Quote Edit / Delete Mac Netherlands Show Events Agree Agree x 1 (list)

  23. Post #183
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,431 Posts

    Is this fixed in gmod13? It started happening since some engine update in december.
    didn't you answer your own question?

    Edited:


    anyone have any idea why this happens or how to fix it? every vehicle I spawn does this :(
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #184
    Casual Bananas
    E X C L's Avatar
    February 2011
    1,709 Posts
    didn't you answer your own question?

    Edited:


    anyone have any idea why this happens or how to fix it? every vehicle I spawn does this :(
    They were diffirent. The post in gmod11 thread was ClientsideModel facing to the corner. This one is with actual playermodels that players have.
    This happens when they simply walk arround.
    Reply With Quote Edit / Delete Mac Netherlands Show Events Informative Informative x 1 (list)

  25. Post #185
    PencilOnDesk's Avatar
    October 2011
    120 Posts
    function bloodtest()
    	for k,v in pairs(player.GetAll()) do
     		if v:Health() >= 25 then 
     			if timer.IsTimer("NextBleedOut") then
     				timer.Destroy("NextBleedOut")
     			end
     		end
     		if v:Health() <= 24 then
     			if timer.IsTimer("NextBleedOut") then return end
     			timer.Create("NextBleedOut",1,0,function()
    				local Pos = v:GetPos() + Vector(0,0,30)
    				local effectdata = EffectData()
    				effectdata:SetStart( Pos )
    				effectdata:SetOrigin( Pos )
    				effectdata:SetScale( 1 )
    				util.Effect( "BloodImpact", effectdata )
    				local trace = {};
    				trace.start = v:GetPos() + Vector(0, 0, 256);
    				trace.endpos = trace.start + Vector(0, 0, -1024);
    				trace.filter = v;
    				trace2 = util.TraceLine(trace);
     				util.Decal("Blood", trace2.HitPos + trace2.HitNormal, trace2.HitPos - trace2.HitNormal)
    
    			end)
    		end
    	end
    end
    hook.Add("Think","Bloodoasdf",bloodtest)
    
    hook.Add("PlayerDeath","ClearTimers", function()
    	if timer.IsTimer("NextBleedOut") then
    		timer.Destroy("NextBleedOut")
    	end
    end)

    Trying to work on some sort of bleeding system where the decal is drawn under the player; However at the moment the Decal only gets drawn when the player dies. Why is this?
    Bump
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  26. Post #186
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    I had your same problem, it's because the player is standing there, the decal gets drawn onto the player not the floor, I couldn't think of a way of doing it so I just made it so there's 1 second timer before the decal is drawn, so if the player is moving it does leave a trail behind them. If they stand still for a while the problem persists though.

    If anyone knows a proper way to do this I would also appreciate it.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Lua Helper Lua Helper x 1 (list)

  27. Post #187
    SFArial's Avatar
    May 2009
    1,174 Posts
    Ok first i am triying to do someting similar to This



    Minute 0-07,0-10

    As you can see the Buildings follows the player mouse and switches its colour if its placeable or not

    Now what i want is that instead of doing an RTS View handle it trough the FPS View basicly put the "Building" a few metters away so far i have a trace and well i guess the end point of the trace is where i should "Spawn" or create the building entity Now i have to do the same trace Every frame and set the building/entity position to the Trace end location too? or theres a simplier way to do it?
    Yes, putting the prop at your trace every frame, I think that's simple enough.

    Edited:

    Has anyone ever experienced this before?
    The playermodel is turned 90 degrees for some reason, their gun and torso face 90 degrees away.
    Try resetting the pose parameters.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  28. Post #188
    Casual Bananas
    E X C L's Avatar
    February 2011
    1,709 Posts
    Try resetting the pose parameters.
    Wouldn't that be kind of weird. It's just a Player.SetModel. I don't know anyone who does that.
    If I should do it then which function would I use?
    Reply With Quote Edit / Delete Mac Netherlands Show Events

  29. Post #189
    SFArial's Avatar
    May 2009
    1,174 Posts
    Wouldn't that be kind of weird. It's just a Player.SetModel. I don't know anyone who does that.
    If I should do it then which function would I use?
    Entity.ClearPoseParameters
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  30. Post #190
    NickCC5's Avatar
    June 2011
    75 Posts
    function GM:Move(ply, movedata)
    	movedata:SetForwardSpeed(0)
    	movedata:SetSideSpeed(0)
    	movedata:SetVelocity(novel)
    	if SERVER then ply:SetGroundEntity(NULL) end
    
    	local ball = ply:GetBall()
    	if IsValid(ball) then
    		movedata:SetOrigin(ball:GetPos())
    	end
    
    	return true
    end
    
    local Player = FindMetaTable("Player")
    
    function Player:SetBall(ent)
    	self:SetOwner(ent)
    end
    
    function Player:GetBall()
    	return self:GetOwner()
    end

    [gamemodes\nintendorr\gamemode\shared.lua:18] attempt to index local 'self' (a nil
    value)(Hook: PlayerSpawn) Any help with this? please?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #191
    Gold Member
    ralle105's Avatar
    October 2005
    4,627 Posts
    I don't see a PlayerSpawn hook in there.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  32. Post #192
    NickCC5's Avatar
    June 2011
    75 Posts
    I don't see a PlayerSpawn hook in there.
    How would I add a PlayerSpawn in there?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #193
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    [gamemodes\nintendorr\gamemode\shared.lua:18] attempt to index local 'self' (a nil
    value)(Hook: PlayerSpawn) Any help with this? please?

    How would I add a PlayerSpawn in there?
    ?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  34. Post #194
    NickCC5's Avatar
    June 2011
    75 Posts
    function GM:Move(ply, movedata)
    	movedata:SetForwardSpeed(0)
    	movedata:SetSideSpeed(0)
    	movedata:SetVelocity(novel)
    	if SERVER then ply:SetGroundEntity(NULL) end
    
    	local ball = ply:GetBall()
    	if IsValid(ball) then
    		movedata:SetOrigin(ball:GetPos())
    	end
    
    	return true
    end
    
    local Player = FindMetaTable("Player")
    
    function Player:SetBall(ent)
    	self:SetOwner(ent)
    end
    
    function Player:GetBall()
    	return self:GetOwner()
    end
    [gamemodes\nintendorr\gamemode\shared.lua:18] attempt to index local 'self' (a nil
    value)(Hook: PlayerSpawn) self is not working, anything else I could use?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #195
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,431 Posts
    that isn't where the error is coming from man
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #196
    JustSoFaded's Avatar
    December 2011
    432 Posts
    function GM:Move(ply, movedata)
    	movedata:SetForwardSpeed(0)
    	movedata:SetSideSpeed(0)
    	movedata:SetVelocity(novel)
    	if SERVER then ply:SetGroundEntity(NULL) end
    
    	local ball = ply:GetBall()
    	if IsValid(ball) then
    		movedata:SetOrigin(ball:GetPos())
    	end
    
    	return true
    end
    
    local Player = FindMetaTable("Player")
    
    function Player:SetBall(ent)
    	self:SetOwner(ent)
    end
    
    function Player:GetBall()
    	return self:GetOwner()
    end
    [gamemodes\nintendorr\gamemode\shared.lua:18] attempt to index local 'self' (a nil
    value)(Hook: PlayerSpawn) self is not working, anything else I could use?
    Go to nintendorr\\gamemode\\shared.lua and the post the contents of the file
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #197
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,672 Posts
    Oh hell, I'll post here.

    Basically I'm trying to draw a rotating box using quads. The entity has a similar model, with collisions disabled, and its rotation is dictated serverside, where the quad drawing is (obviously) done client-side.

    It all works fine, except that the top and bottom don't rotate. It appears that :GetAngles():Top() doesn't really change, like the Forward() and Right(). The result is this.



    Anyone got any ideas on how I can make the top and bottom rotate with the rest of the box? I think I need to use RotateAroundAxis, but I don't know how to use that thing worth a damn. I've tried adding the Forward() or Right() to Up(), but that just makes it slanted, which isn't what I want.

    Thanks in advance.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  38. Post #198
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,431 Posts
    It sounds like RotateAroundAxis is what you want. It's a kinda weird function (or at least the outcome), from what I've seen of it, have you tried Forward/Right/Up with negative values as well?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #199
    Ask about my EBOLA fetish
    GameDev's Avatar
    February 2010
    12,354 Posts
    I'm fairly new to LUA, and me and Pyth are making a Marble Blast gamemode; but of course we have no idea what we're doing.

    Basically, we want the player on spawn to change model to:

    Code:
    models/XQM/Rails/gumball_1.mdl
    and then be able to roll around with WASD, and jump. (Similar to melon racer)

    How would we go about doing this? We're completely stumped.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #200
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,672 Posts
    It sounds like RotateAroundAxis is what you want. It's a kinda weird function (or at least the outcome), from what I've seen of it, have you tried Forward/Right/Up with negative values as well?
    Yeah, I figured I need to use RAA, but I just have no idea what to do. I was hoping someone here could point me in the right direction. I'll fuck around with it, and ask around. Hopefully I'll be able to get it.
    Reply With Quote Edit / Delete Windows 7 United States Show Events