• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=James xX;48167165]When you define the table, don't put "local" in front.[/QUOTE] Alright. AS well, when I want to keep the instance in case the gamemode or Lua refreshs, I do table = table or {}, right?
[QUOTE=Apple_Bloom;48167170]Yikes, yeah forget what I had said FireArrow133. @stev_ where should I be calling the function at? Inside the for loop?[/QUOTE] You'd just replace _validents with _validents().
OH MY GOD would someone please help me with this? I'll love you for ever
[QUOTE=stev_;48167194]You'd just replace _validents with _validents().[/QUOTE] Just saw I did it again with the (), I'm getting a new error now. [CODE][ERROR] gamemodes/skeleton/gamemode/cl_init.lua:63: attempt to get length of a userdata value 1. FindTarget - gamemodes/skeleton/gamemode/cl_init.lua:63 2. v - gamemodes/skeleton/gamemode/cl_init.lua:78 3. unknown - lua/includes/modules/hook.lua:84 [/CODE] I apologize about how annoying I must be with this.
[QUOTE=Apple_Bloom;48167203]Just saw I did it again with the (), I'm getting a new error now. [CODE][ERROR] gamemodes/skeleton/gamemode/cl_init.lua:63: attempt to get length of a userdata value 1. FindTarget - gamemodes/skeleton/gamemode/cl_init.lua:63 2. v - gamemodes/skeleton/gamemode/cl_init.lua:78 3. unknown - lua/includes/modules/hook.lua:84 [/CODE] I apologize about how annoying I must be with this.[/QUOTE] You're only returning one entity from the _validents function, (userdata) then trying to get the length of it, which you can't. I think you're wanting to return multiple entites from _validents, so _validents should be this (I think): [code] local _validents = function() for k, v in pairs(_ents) do local tbl ={}; if ( IsValid(v) and v == ents.FindByClass( "npc_*" ) ) or ( IsValid(v) and v:IsPlayer() ) then // Add to the table tbl[#tbl+1] = v; end // Return the table of entities return tbl; end end [/code]
Is there a way to... idk how to sum this in just a few words. Basically, I want to scale how much a model actually moves when it animates. How to describe this better... where the entire animation plays, except the offset of the bones is scaled. If the bone was supposed to move 3 units, I want to scale that so maybe it only moves 1 unit, or maybe it even moves 4 units. Is there a way to do this? Specifically, to a viewmodel?
[QUOTE=stev_;48167278]-snip-[/QUOTE] Yeah I wanted multiple entities returned in a table like you did. It's not giving me any more errors, but now its not giving me an entity I can use for my target. This is what I have so far: [CODE]function FindTarget() local me = LocalPlayer() local _ents = ents.GetAll() local _validents = function() for k, v in pairs(_ents) do local tbl = {}; if ( IsValid(v) and v == ents.FindByClass( "npc_*" ) ) or ( IsValid(v) and v:IsPlayer() ) then tbl[#tbl + 1] = v; end return tbl; end end for i = 1, #(_validents()) do if me.Counter[i] < #(_validents()) then me.Counter[i] = me.Counter[i+1] print( me.Counter ) net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() else me.Counter[i] = me.Counter[1] net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() end end end[/CODE] I decided to remove the distance calculation function so that I can test this a bit better(it was giving me an error on GetPos()). Basically nothing happens with this is run.
[QUOTE=Apple_Bloom;48167436]-snip-[/QUOTE] [code] function FindTarget() local me = LocalPlayer() local _ents = ents.GetAll() local _validents = function() for k, v in pairs(_ents) do local tbl = {}; // I assume you only want NPCs/players? if IsValid(v) and (v:IsPlayer() or v:IsNPC()) then tbl[#tbl + 1] = v; end return tbl; end end for i = 1, #(_validents()) do if me.Counter[i] < #(_validents()) then me.Counter[i] = me.Counter[i+1] print( me.Counter ) net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() else me.Counter[i] = me.Counter[1] net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() end end end [/code]
Why do you need to create the nested function every time the function is called? why not just have it as a local function in the main scope?
[QUOTE=James xX;48167514]Why do you need to create the nested function every time the function is called? why not just have it as a local function in the main scope?[/QUOTE] Incase new players or npcs spawn and are able to become targets. @stev_ its still not giving me a target for some reason.
[QUOTE=Apple_Bloom;48167596]Incase new players or npcs spawn and are able to become targets. @stev_ its still not giving me a target for some reason.[/QUOTE] Seeing as you are calling the function each time, that won't be a problem? [lua] function FindTarget() local me = LocalPlayer() local _validents = {} for k, v in pairs(ents.GetAll()) do // I assume you only want NPCs/players? if IsValid(v) and (v:IsPlayer() or v:IsNPC()) then table.insert( _validents , v ) end end for i = 1, #_validents do if me.Counter[i] < #_validents then me.Counter[i] = me.Counter[i+1] print( me.Counter ) net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() else me.Counter[i] = me.Counter[1] net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() end end end [/lua]
[QUOTE=James xX;48167684]-snip-[/QUOTE] I'm starting to get confused, also your code is returning this error: [CODE][ERROR] gamemodes/skeleton/gamemode/cl_init.lua:59: attempt to index field 'Counter' (a nil value) 1. FindTarget - gamemodes/skeleton/gamemode/cl_init.lua:59 2. v - gamemodes/skeleton/gamemode/cl_init.lua:73 3. unknown - lua/includes/modules/hook.lua:84 [/CODE] Whats the difference between having _validents return a table as a function, and it just being a table in general? And do I need to return _validents after the k,v in pairs?
[QUOTE=Apple_Bloom;48167783]I'm starting to get confused, also your code is returning this error: [CODE][ERROR] gamemodes/skeleton/gamemode/cl_init.lua:59: attempt to index field 'Counter' (a nil value) 1. FindTarget - gamemodes/skeleton/gamemode/cl_init.lua:59 2. v - gamemodes/skeleton/gamemode/cl_init.lua:73 3. unknown - lua/includes/modules/hook.lua:84 [/CODE] Whats the difference between having _validents return a table as a function, and it just being a table in general? And do I need to return _validents after the k,v in pairs?[/QUOTE] Actually it's your code that has that problem, you never initialize the Player.Counter variable. The difference to it being a table rather than a function is that there's no reason to create a nested function unless the function is designed to work differently depending on the arguments. It also means you aren't creating a function every time you call your function. It also looks a lot nicer, but thats just me. Also, no, you don't return _validents after the for loop because that would stop the execution of the function and most likely throw errors at you for having code after it.
[QUOTE=James xX;48167822]-snip-[/QUOTE] How would I initialize the player.Counter variable? By setting it as LocalPlayer().Counter = {}; in the very beginning under the other local variables but instead have it global? edit: Okay so I changed it to this: [CODE]function FindTarget() local me = LocalPlayer() local _validents = {}; me.Counter = {}; for k, v in pairs(ents.GetAll()) do // I assume you only want NPCs/players? if IsValid(v) and (v:IsPlayer() or v:IsNPC()) then table.insert( _validents , v ) end end for i = 1, #_validents do if me.Counter[i] and me.Counter[i] < #_validents then me.Counter[i] = me.Counter[i+1] print( me.Counter ) net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() else me.Counter[i] = me.Counter[1] net.Start( "SendTargetEntity" ) net.WriteEntity( me.Counter[i] ) net.SendToServer() end end end[/CODE] But its not sending an entity, normally if I have a target then it will show their health bars above their heads. But its not allow me to cast me spells I made on anything, nor showing healthbars which is telling me I don't have a target still. edit: Scratch that, it's telling me my target is Entity[0][Worldspawn]
Is there a collision type that will trigger an ENT:Touch() or ENT:PhysicsCollide() without actually colliding with a player? (If that makes sense, I haven't been to sleep in 2 days now.)
[QUOTE=RedNinja;48167142]Makes the entity disappear. How the hell should I do this?[/QUOTE] Put this in the code: [lua]PrintTable(self:GetSequenceList())[/lua] The list returned is of the available sequences available. AE_THUMPER_THUMP may not exist.
Do you guys know what the default blue color is from ULX? [url]http://i.gyazo.com/46390d50d730e5e6fbd607b2ded9f5bb.png[/url] I can't find out the exact values for the "This color is blue"
[QUOTE=CosmicSeagull;48168327]Is there a collision type that will trigger an ENT:Touch() or ENT:PhysicsCollide() without actually colliding with a player? (If that makes sense, I haven't been to sleep in 2 days now.)[/QUOTE] I've searched for that as well but I don't think something like that actually exists [QUOTE=PigeonTroll;48175674]Do you guys know what the default blue color is from ULX? [url]http://i.gyazo.com/46390d50d730e5e6fbd607b2ded9f5bb.png[/url] I can't find out the exact values for the "This color is blue"[/QUOTE] It's quite clearly 98D4FF (152,212,255). You could've easily found that out by using paint btw.
hello, since i am learning lua by making my script i will not create a thread as the problem will keep changing. i have an issue with this error [CODE][ERROR] addons/sliding project product/lua/autorun/slide.lua:3: 'end' expected near 'else' 1. unknown - addons/sliding project product/lua/autorun/slide.lua:0 [/CODE] here is the code [CODE]local allplayers = player.GetAll() for _,players in pairs ( allplayers ) do if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end function InitFloorSlide () if !IsValid( players ) then return end local pos = ( players:GetPos() + Vector( 0, 0, 45 ) ) players.SlidingSound = players.SlidingSound or CreateSound( players, 'slidemod/floorslide.wav' ) if players:GetVelocity():Length() < 200 then if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end return end players.SlideVelocity = players.SlideVelocity or 0 if players.SlideVelocity == 0 then players.SlideVelocity = 70 * ( math.Clamp( players:GetVelocity():Length() / 500, 0, 1 ) ) end local dir = Angle( 0, players:EyeAngles().y, 0 ):Forward() local tr = util.TraceLine( { start = pos, endpos = pos + dir * 35, filter = players } ) local tr_up = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 43 ) + dir * 25, filter = players } ) local tr_down = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 48 ) + dir * 25, filter = players } ) if !tr_down.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 100, 0.5 ) else players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 0.5 ) end if tr_up.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 2 ) end if tr.Hit and players.SlideVelocity > 0 then if IsValid( tr.Entity ) and ( tr.Entity:IsPlayer() or tr.Entity:IsNPC() ) then end players:ViewPunch( Angle( players.SlideVelocity / 5, 0.3, -1 ) ) players.SlideVelocity = 0 if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() players:EmitSound( 'slidemod/floorslide_hit_hard.wav' ) end return end players:ViewPunch( Angle( 0, 0.3, -1 ) ) players:SetVelocity( dir * players.SlideVelocity ) if !players.SlidingSound:IsPlaying() then players.SlidingSound:Play() end end end end end end [/CODE] am i not supposed to put in so many if statements together? or are my end(s) just placed wrongly? i cant seem to figure out what i should do, just move my if statement? [CODE]if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end [/CODE]
[QUOTE=jellofacey;48176092]hello, since i am learning lua by making my script i will not create a thread as the problem will keep changing. i have an issue with this error [CODE][ERROR] addons/sliding project product/lua/autorun/slide.lua:3: 'end' expected near 'else' 1. unknown - addons/sliding project product/lua/autorun/slide.lua:0 [/CODE] here is the code [CODE]local allplayers = player.GetAll() for _,players in pairs ( allplayers ) do if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end function InitFloorSlide () if !IsValid( players ) then return end local pos = ( players:GetPos() + Vector( 0, 0, 45 ) ) players.SlidingSound = players.SlidingSound or CreateSound( players, 'slidemod/floorslide.wav' ) if players:GetVelocity():Length() < 200 then if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end return end players.SlideVelocity = players.SlideVelocity or 0 if players.SlideVelocity == 0 then players.SlideVelocity = 70 * ( math.Clamp( players:GetVelocity():Length() / 500, 0, 1 ) ) end local dir = Angle( 0, players:EyeAngles().y, 0 ):Forward() local tr = util.TraceLine( { start = pos, endpos = pos + dir * 35, filter = players } ) local tr_up = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 43 ) + dir * 25, filter = players } ) local tr_down = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 48 ) + dir * 25, filter = players } ) if !tr_down.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 100, 0.5 ) else players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 0.5 ) end if tr_up.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 2 ) end if tr.Hit and players.SlideVelocity > 0 then if IsValid( tr.Entity ) and ( tr.Entity:IsPlayer() or tr.Entity:IsNPC() ) then end players:ViewPunch( Angle( players.SlideVelocity / 5, 0.3, -1 ) ) players.SlideVelocity = 0 if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() players:EmitSound( 'slidemod/floorslide_hit_hard.wav' ) end return end players:ViewPunch( Angle( 0, 0.3, -1 ) ) players:SetVelocity( dir * players.SlideVelocity ) if !players.SlidingSound:IsPlaying() then players.SlidingSound:Play() end end end end end end [/CODE] am i not supposed to put in so many if statements together? or are my end(s) just placed wrongly? i cant seem to figure out what i should do, just move my if statement? [CODE]if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end [/CODE][/QUOTE] [lua] then function InitFloorSlide() else [/lua] That's your problem. I would tell you what to do instead but I have no idea what you are trying to do.
[QUOTE=jellofacey;48176092]hello, since i am learning lua by making my script i will not create a thread as the problem will keep changing. i have an issue with this error [CODE][ERROR] addons/sliding project product/lua/autorun/slide.lua:3: 'end' expected near 'else' 1. unknown - addons/sliding project product/lua/autorun/slide.lua:0 [/CODE] here is the code [CODE]local allplayers = player.GetAll() for _,players in pairs ( allplayers ) do if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end function InitFloorSlide () if !IsValid( players ) then return end local pos = ( players:GetPos() + Vector( 0, 0, 45 ) ) players.SlidingSound = players.SlidingSound or CreateSound( players, 'slidemod/floorslide.wav' ) if players:GetVelocity():Length() < 200 then if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end return end players.SlideVelocity = players.SlideVelocity or 0 if players.SlideVelocity == 0 then players.SlideVelocity = 70 * ( math.Clamp( players:GetVelocity():Length() / 500, 0, 1 ) ) end local dir = Angle( 0, players:EyeAngles().y, 0 ):Forward() local tr = util.TraceLine( { start = pos, endpos = pos + dir * 35, filter = players } ) local tr_up = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 43 ) + dir * 25, filter = players } ) local tr_down = util.TraceLine( { start = pos - Vector( 0, 0, 40 ), endpos = pos - Vector( 0, 0, 48 ) + dir * 25, filter = players } ) if !tr_down.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 100, 0.5 ) else players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 0.5 ) end if tr_up.Hit then players.SlideVelocity = math.Approach( players.SlideVelocity, 0, 2 ) end if tr.Hit and players.SlideVelocity > 0 then if IsValid( tr.Entity ) and ( tr.Entity:IsPlayer() or tr.Entity:IsNPC() ) then end players:ViewPunch( Angle( players.SlideVelocity / 5, 0.3, -1 ) ) players.SlideVelocity = 0 if players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() players:EmitSound( 'slidemod/floorslide_hit_hard.wav' ) end return end players:ViewPunch( Angle( 0, 0.3, -1 ) ) players:SetVelocity( dir * players.SlideVelocity ) if !players.SlidingSound:IsPlaying() then players.SlidingSound:Play() end end end end end end [/CODE] am i not supposed to put in so many if statements together? or are my end(s) just placed wrongly? i cant seem to figure out what i should do, just move my if statement? [CODE]if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then function InitFloorSlide() else if players.SlideVelocity = 0 if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end [/CODE][/QUOTE] If you are wanting to call the function InitFloorSlide then u don't need the function in front of it [LUA]if players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) and players:IsOnGround() then InitFloorSlide() elseif players.SlideVelocity = 0 then if players.SlidingSound and players.SlidingSound:IsPlaying() then players.SlidingSound:Stop() end end[/LUA] Think thats what u want. You may want to check it
[QUOTE=Apple_Bloom;48167875]-snip-[/QUOTE] Still having some issues with this function, I'm almost wondering if there is a better alternative. I thought about just doing a trace from the player's view, but it'd be hard to target things that are moving around a lot. Anyone got any better ideas?
How would I delete a whole folder inside /data with file.Delete? I was able to delete individual files within that folder but just having the name within a string did not work, thanks!
[QUOTE=NiandraLades;48176876]-snip-[/QUOTE] You could get all the files in said folder using file.Find then file.Delete them. This is untested: [code] local file_tbl ={}; local dir_tbl ={}; local function FindIn(dir) local files, dirs = file.Find(dir.."*", "DATA"); for _, f in next, files do -- Do something to files here file_tbl[#file_tbl+1] = f; end for _, d in next, dirs do dir_tbl[#dir_tbl+1] = d; // Search this directory_here FindIn(dir.."/".. d.."/"); end end FindIn("directory_here"); [/code]
[QUOTE=CosmicSeagull;48168327]Is there a collision type that will trigger an ENT:Touch() or ENT:PhysicsCollide() without actually colliding with a player? (If that makes sense, I haven't been to sleep in 2 days now.)[/QUOTE] [url]http://facepunch.com/showthread.php?t=1411111&p=46375270#post46375270[/url]
[QUOTE=CosmicSeagull;48168327]Is there a collision type that will trigger an ENT:Touch() or ENT:PhysicsCollide() without actually colliding with a player? (If that makes sense, I haven't been to sleep in 2 days now.)[/QUOTE] I don't think that exists, but you can do Entity:SetTrigger to make it a trigger which calls those touch functions but go straight through players. Don't know if this makes [I]all[/I] entities not collide with it or only players, mess around with it.
Hi, i have another problem, i re wrote the whole code, so my code is to let the player slide on the floor by pressing Crouch and Moving forwards. I currently have two issues that i cant seem to fix First is that, if i enable a feature in my code that makes whatever i hit into take damage, such as an NPC or breakable prop, i end up triggering that feature CONSTANTLY. like it triggers multiple times even though i am still sliding halfway, the screen is meant to shake but it shakes like crazy, this could be because i am using a Tick hook for my initialization, but im not sure what else to use? Second issue is that if i Slide off a ledge, i end up flying, thats because i copied the code to set velocity, because honestly i have no idea how to let the sliding work. but now i dont even understand it and i dont know how to write it myself, i have tried but i want that "decay" effect so it goes like Fast (sprinting) Still fast (Sliding) getting slower (sliding for awhile already) crouch walking (the slide is over) but i cant do that by myself, i dont actually know what to use. Code is below: [CODE] function SlideInit() for k, players in pairs(player.GetAll()) do if ( players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) ) then StartSlide() end end end hook.Add( "Think", "SlideInit", SlideInit ) function StartSlide() for k, players in pairs(player.GetAll()) do if players:GetVelocity():Length() < 150 then end local cvel = players:GetVelocity() local vell = players:GetVelocity():Length() SlideTime = CurTime() + math.Clamp(vell / 800, 0, 2) players.SlideLastDir = players:GetForward() if SlideTime and SlideTime < CurTime() then vell = vell - FrameTime() * 600 end players:SetLocalVelocity(players.SlideLastDir * vell * 1.11) if ( SERVER ) then local trF = util.QuickTrace(players:GetPos() + Vector(0,0,50) , (players.SlideLastDir * 50), v); if trF and trF.Hit and vell > 0 then players:SetVelocity(players:GetAimVector(), 0) if SERVER then players:EmitSound("physics/body/body_medium_impact_hard" .. math.random(1, 6) .. ".wav", math.Rand(80, 100), math.Rand(90, 120)) end if trF.Entity:IsValid() then trF.Entity:TakeDamage( vell/20, players) end local shake = ents.Create( "env_shake" ) shake:SetOwner(players) shake:SetPos( trF.HitPos ) shake:SetKeyValue( "amplitude", "2500" ) shake:SetKeyValue( "radius", "100" ) shake:SetKeyValue( "duration", "0.5" ) shake:SetKeyValue( "frequency", "255" ) shake:SetKeyValue( "spawnflags", "4" ) shake:Spawn() shake:Activate() shake:Fire( "StartShake", "", 0 ) end end end end[/CODE]
[QUOTE=jellofacey;48177619]Hi, i have another problem, i re wrote the whole code, so my code is to let the player slide on the floor by pressing Crouch and Moving forwards. I currently have two issues that i cant seem to fix First is that, if i enable a feature in my code that makes whatever i hit into take damage, such as an NPC or breakable prop, i end up triggering that feature CONSTANTLY. like it triggers multiple times even though i am still sliding halfway, the screen is meant to shake but it shakes like crazy, this could be because i am using a Tick hook for my initialization, but im not sure what else to use? Second issue is that if i Slide off a ledge, i end up flying, thats because i copied the code to set velocity, because honestly i have no idea how to let the sliding work. but now i dont even understand it and i dont know how to write it myself, i have tried but i want that "decay" effect so it goes like Fast (sprinting) Still fast (Sliding) getting slower (sliding for awhile already) crouch walking (the slide is over) but i cant do that by myself, i dont actually know what to use. Code is below: [CODE] function SlideInit() for k, players in pairs(player.GetAll()) do if ( players:WaterLevel() <= 1 and players:KeyDown( IN_FORWARD ) and players:KeyDown( IN_DUCK ) ) then StartSlide() end end end hook.Add( "Think", "SlideInit", SlideInit ) function StartSlide() for k, players in pairs(player.GetAll()) do if players:GetVelocity():Length() < 150 then end local cvel = players:GetVelocity() local vell = players:GetVelocity():Length() SlideTime = CurTime() + math.Clamp(vell / 800, 0, 2) players.SlideLastDir = players:GetForward() if SlideTime and SlideTime < CurTime() then vell = vell - FrameTime() * 600 end players:SetLocalVelocity(players.SlideLastDir * vell * 1.11) if ( SERVER ) then local trF = util.QuickTrace(players:GetPos() + Vector(0,0,50) , (players.SlideLastDir * 50), v); if trF and trF.Hit and vell > 0 then players:SetVelocity(players:GetAimVector(), 0) if SERVER then players:EmitSound("physics/body/body_medium_impact_hard" .. math.random(1, 6) .. ".wav", math.Rand(80, 100), math.Rand(90, 120)) end if trF.Entity:IsValid() then trF.Entity:TakeDamage( vell/20, players) end local shake = ents.Create( "env_shake" ) shake:SetOwner(players) shake:SetPos( trF.HitPos ) shake:SetKeyValue( "amplitude", "2500" ) shake:SetKeyValue( "radius", "100" ) shake:SetKeyValue( "duration", "0.5" ) shake:SetKeyValue( "frequency", "255" ) shake:SetKeyValue( "spawnflags", "4" ) shake:Spawn() shake:Activate() shake:Fire( "StartShake", "", 0 ) end end end end[/CODE][/QUOTE] For the sliding off the ledge fix, just use this: [code]players:SetVelocity( velocity ) timer.Create( "slidetimer"..players:EntIndex(), 1, 1, function() players:SetVelocity( 0 ) end) [/code]
Many of my players seem to be getting this in console: [code] [ERROR] gamemodes/sandbox/entities/effects/selection_ring.lua:12: Tried to use a NULL entity! 1. SetCollisionBounds - [C]:-1 2. unknown - gamemodes/sandbox/entities/effects/selection_ring.lua:12 3. Effect - [C]:-1 4. unknown - gamemodes/sandbox/entities/effects/selection_indicator.lua:18 [ERROR] gamemodes/sandbox/entities/effects/selection_indicator.lua:24: Tried to use a NULL entity! 1. SetRenderBounds - [C]:-1 2. unknown - gamemodes/sandbox/entities/effects/selection_indicator.lua:24 CBaseEntityList::AddNonNetworkableEntity: no free slots! [ERROR] gamemodes/base/entities/effects/tooltracer.lua:14: attempt to call method 'GetTracerShootPos' (a nil value) 1. unknown - gamemodes/base/entities/effects/tooltracer.lua:14 [/code] After being on the server for at least a couple of hours. It's spamming like hell. Anyone knows what could be causing this? Running DarkRP and I haven't modified any sandbox or base gamemode files. Rejoining fixes this. It doesn't seem to do anything really other than the massive spam.
[code]function ShowAttachmentMenu( meh, heh, args ) if args[1] == true then gui.EnableScreenClicker( true ) local attachmentmenu = vgui.Create( "DFrame" ) attachmentmenu:SetSize( 400, 400 ) attachmentmenu:Center() attachmentmenu:SetTitle( "Attachments" ) local weapon = vgui.Create( "DModelPanel", attachmentmenu ) weapon:SetPos( 60, 60 ) weapon:SetSize( 100, 100 ) weapon:SetModel( "models/weapons/w_rif_m4a1.mdl" ) weapon:SetLookAt( Vector( 0, 40, 80 ) ) elseif args[1] == false then gui.EnableScreenClicker( false ) attachmentmenu:Remove() end end concommand.Add( "ffs_attmenu", ShowAttachmentMenu( ply, cmd, args ) ) [/code] This isn't working.... I don't know why.
Sorry, you need to Log In to post a reply to this thread.