• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Donkie;38327791]net.WriteInt(100, 7) would work I think, the 7 denotes that it uses 7 bits, because 100 in binary is 1100100 (7 numbers)[/QUOTE] net.WriteInt might take the nr of bytes, not bits. I've not used the net library myself so I don't know for sure, and the wiki is down atm. If it does take the nr of bytes, it'll be net.WriteInt(100,1)
for some reason this codes giving SetHealth a nil Value. [lua]timer.Create("GivePlyHealth_"..self.Owner:UniqueID(),0.5,8,function() self.Owner:SetHealth(self.Owner:GetHealth()+25) end)[/lua] is there a easier way to add 25 hp to the person no matter how much hp they have?
Bleh, I'm getting pissed at this. I want to replace the players name if it get's over 15 characters. Example: QWERTYUIOPASDFGHJKLZ (20 characters) would go to QWERTYUIOPASDFG... Latest code I tried with was: [lua] if #pl:Name() > 15 then local name = string.gsub(pl:Name(), string.Right(pl:Name(), 15), "...") end [/lua]
[QUOTE=Ownage96;38325547] Ok so the thing is, you're trying to create a hat and attach it to a players head, and if i'm correct, parenting doesn't really work that way. When i've used parenting in the past, parenting to a player simply moves an entity with a players torso, and not their head. The best thing i can recommend is setting the position and angles to their head bone ([url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1685.html[/url] - This will help you in doing so), you can then parent it to the player and call hat:AddEffects( EF_BONEMERGE ) (on the client side), which causes the entity to merge with the nearest bones or something like that. Alternatively, you can saved a networked variable for each of the hats position/angle and then have the client constantly refresh the position from that position/angle. If you don't understand what i'm saying, you should probably get a bit more experience before you go ahead and try something that difficult [/QUOTE] First off, if you actually researched anything before trying to help me, the deerstalker hat in TTT has: [lua] function ENT:Initialize() self:SetBeingWorn(true) self:SetModel(self.Model) self:DrawShadow(false) -- don't physicsinit the ent here, because physicsing and then setting -- movetype none is 1) a waste of memory, 2) broken self:SetMoveType(MOVETYPE_NONE) self:SetSolid(SOLID_NONE) self:SetCollisionGroup(COLLISION_GROUP_DEBRIS) if SERVER then self.Wearer = self:GetParent() self:AddEffects(bit.bor(EF_BONEMERGE, EF_BONEMERGE_FASTCULL, EF_PARENT_ANIMATES))--<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end end [/lua] [QUOTE]If you don't understand what i'm saying, you should probably get a bit more experience before you go ahead and try something [B]that difficult[/B][/QUOTE] How is this difficult? All i'm asking is why does it show up in the player's crotch. If I run the command on TTT for ttt_debug_testhat the hat perfectly merges with the players head. I have the same effects on my own entities aswell.
[QUOTE=Persious;38328884]Bleh, I'm getting pissed at this. I want to replace the players name if it get's over 15 characters. Example: QWERTYUIOPASDFGHJKLZ (20 characters) would go to QWERTYUIOPASDFG... Latest code I tried with was: [lua] if #pl:Name() > 15 then local name = string.gsub(pl:Name(), string.Right(pl:Name(), 15), "...") end [/lua][/QUOTE] [lua] local name = pl:Name() if #name > 15 then name = name:sub(1, 15).."..." end [/lua]
Can someone help me out with my DNumSlider local Slider= vgui.Create( "DNumSlider", TestTab ) Slider:SetPos( 5, 5 ) Slider:SetSize( 150, 100 ) Slider:SetText( "Slider Test" ) Slider:SetMin( 0 ) Slider:SetMax( 256 ) Slider:SetDecimals( 0 ) Slider:SetConVar( "sbox_maxprops" ) The slider doesn't actually show up it just says "Slider Test" and thats it. Apparently DNumSlider is broken right now.
how can i use custom fonts in my hud like this one: [url]http://www.dafont.com/velocity.font[/url] ?
[QUOTE=ralle105;38329217][lua] local name = pl:Name() if #name > 15 then name = name:sub(1, 15).."..." end [/lua][/QUOTE] You always have such nice methods :[
How to rotate entity around a point? Like a door. [lua] local CenterX = Vector(0,50,0) local Pos = ent:LocalToWorld(ent:OBBCenter(), Angle(0,0,0), Vector(0,0,0), Angle(0,0,0)) -- center local Position = Pos - (ent:GetRight() * Center.Y) + (ent:GetUp() * Center.Z) local AddAngle = Angle(50,0,0) local RealPos, RealAngle = LocalToWorld(ent:OBBCenter(), AddAngle, Vector(0,0,0), ent:GetAngles()) ent:SetAngles( RealAngle ) Position = Position + RealPos ent:SetPos(Position) [/lua] Does not do it.
How would you go about creating a function to check if a player has moved for a certain period of time, Like if a player moved in the last 3 seconds? Is there any function to check if a player has moved?
-snip- Timers and the Think hook are pretty much the same. But Timers are more efficient by barely anything.
I'm need help on this > timer.Simple( 0, function() (CustomTeam, maximum_amount_of_this_class) AddTeamCommands(CustomTeam, maximum_amount_of_this_class) end, CustomTeam, maximum_amount_of_this_class) end ) ')' expected near ',' I'm new to lua so i have no clue where to put the ")" exactly This is one of the most obvious fixes that i have no clue how to do xD. -thanks to any help in advanced.
[QUOTE=Archemyde;38318095][vid]www.riotservers.net/slow.webm[/vid] Walkspeed in my gamemode is inexplicably slow - Only for that team. Tried manually setting the walkspeed/runspeed/crouchspeed of the player through console, No change whatsoever. Checking it afterwards returns what i apparently set it to, so the gamemode isnt manually changing it. It's perfectly fine for other teams though. What the hell? any ideas on whats going on?[/QUOTE] After much pain, i found it was due to how teams were set up. Strange how the team affects walkspeed, especially when it's not coded to.... Whatever, fixed now. one of those weird lua things. [editline]5th November 2012[/editline] [QUOTE=Persious;38328884]Bleh, I'm getting pissed at this. I want to replace the players name if it get's over 15 characters. Example: QWERTYUIOPASDFGHJKLZ (20 characters) would go to QWERTYUIOPASDFG... Latest code I tried with was: [lua] if #pl:Name() > 15 then local name = string.gsub(pl:Name(), string.Right(pl:Name(), 15), "...") end [/lua][/QUOTE] #pl:Name() doesnt sound like it will return the number of characters in the name. Try string.len For instance: [lua] if string.len(pl:Name()) > 15 then local name = string.gsub(pl:Name(), string.Right(pl:Name(), 15), "...") end [/lua]
How would I go about removing a particle effect after 10 seconds? I looked at the wiki and it said to use Finish() so I tired using that with a timer but I keep getting this error: attempt to call method 'Finish' (a nil value) [LUA] function ENT:Draw() self:DrawModel() local vOffset = self:GetPos() + Vector(0, 0, 5) local vNormal = (vOffset - self:GetPos()):GetNormalized() local particle = ParticleEmitter(self:GetPos(), false):Add("particles/smokey", vOffset) particle:SetVelocity(vNormal * math.Rand(10, 30)) particle:SetStartAlpha(math.Rand(50, 150)) particle:SetDieTime(1) particle:SetEndAlpha(0) particle:SetStartSize(3) particle:SetEndSize(1) particle:SetRoll(.05) particle:SetColor( Color( 200, 200, 210, 255 ) ) --timer.Create("Particle" .. self:EntIndex(), 2, 1, function () -- particle:Finish() --end) end [/LUA]
Little Help? : [QUOTE=Blackfire76;38320437]Hello. I've done a lua brush and put it into hammer. This is the error I get when loading the map: [code]Attempted to create unknown entity type brush_hpres! Can't init brush_hpres[/code] This is the code for my brush: [lua] /* Life-Giving entity by Blackfire */ ENT.StorTable = {} function ENT:Initialize() end function ENT:StartTouch(ent) if ent:IsPlayer() then for k, v in pairs(player.GetAll()) do v:ChatPrint(ent:GetName().." touched the magical entity!") end end end function ENT:EndTouch(ent) if ent:IsPlayer() then for k, v in pairs(player.GetAll()) do v:ChatPrint(ent:GetName().." stopped touching the magical entity!") end end end [/lua] No, nothing happens when I spawn, stop touching it, start touching it, ect. The map: [url]https://dl.dropbox.com/u/42016379/test_ctf.bsp[/url] The VMF: [url]https://dl.dropbox.com/u/42016379/test_ctf.vmf[/url] (don't go EWW OMG SO BAD, it's just a test map.)[/QUOTE]
[QUOTE=I Fail At Lua;38333284]How would I go about removing a particle effect after 10 seconds? I looked at the wiki and it said to use Finish() so I tired using that with a timer but I keep getting this error: attempt to call method 'Finish' (a nil value) [LUA] function ENT:Draw() self:DrawModel() local vOffset = self:GetPos() + Vector(0, 0, 5) local vNormal = (vOffset - self:GetPos()):GetNormalized() local particle = ParticleEmitter(self:GetPos(), false):Add("particles/smokey", vOffset) particle:SetVelocity(vNormal * math.Rand(10, 30)) particle:SetStartAlpha(math.Rand(50, 150)) particle:SetDieTime(1) particle:SetEndAlpha(0) particle:SetStartSize(3) particle:SetEndSize(1) particle:SetRoll(.05) particle:SetColor( Color( 200, 200, 210, 255 ) ) --timer.Create("Particle" .. self:EntIndex(), 2, 1, function () -- particle:Finish() --end) end [/LUA][/QUOTE] That's because particle is local to the draw function and not in the scope of the anonymous function you have added to timer.Create. Maybe.
[QUOTE=jmazouri;38334676]That's because particle is local to the draw function and not in the scope of the anonymous function you have added to timer.Create. Maybe.[/QUOTE] Oh wow I should have noticed that, thanks for the help.
Does anyone know of a gm13 replacement for file.FindDir?
[QUOTE=amkoc;38337132]Does anyone know of a gm13 replacement for file.FindDir?[/QUOTE] local files, directories = file.Find( "*", "GAME" )
[QUOTE=brandonj4;38329203]First off, if you actually researched anything before trying to help me, the deerstalker hat in TTT has: [lua] function ENT:Initialize() self:SetBeingWorn(true) self:SetModel(self.Model) self:DrawShadow(false) -- don't physicsinit the ent here, because physicsing and then setting -- movetype none is 1) a waste of memory, 2) broken self:SetMoveType(MOVETYPE_NONE) self:SetSolid(SOLID_NONE) self:SetCollisionGroup(COLLISION_GROUP_DEBRIS) if SERVER then self.Wearer = self:GetParent() self:AddEffects(bit.bor(EF_BONEMERGE, EF_BONEMERGE_FASTCULL, EF_PARENT_ANIMATES))--<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end end [/lua] How is this difficult? All i'm asking is why does it show up in the player's crotch. If I run the command on TTT for ttt_debug_testhat the hat perfectly merges with the players head. I have the same effects on my own entities aswell.[/QUOTE] If you're not going to read what i said then fuck off. [code]hat:SetPos(self:GetPos() + Vector(0,0,70))[/code] Will just put it somewhere between your feet and your head, and when you parent to player it parents straight to your body(torso) which is why you need to bonemerge.
[QUOTE=Ownage96;38337163]If you're not going to read what i said then fuck off. [code]hat:SetPos(self:GetPos() + Vector(0,0,70))[/code] Will just put it somewhere between your feet and your head, and when you parent to player it parents straight to your body(torso) which is why you need to bonemerge.[/QUOTE] I did read what you said and once again the entity already has bonemerge: self:AddEffects(bit.bor(EF_BONEMERGE, EF_BONEMERGE_FASTCULL, EF_PARENT_ANIMATES))
[QUOTE=Ownage96;38325547]render.MaterialOverride( Material( "yourshittyfolder/yourshittymaterial" ) ) It's usually a good idea to call it before you render, then call it after you render with render.MaterialOverride( 0 ) (Not sure if that still works, in Gm12 it cleared the current overriden material) [/quote] I know it takes a material >.> I was asking for an EXAMPLE of how its used. Could have easily (and I did) look up the arguments for it. I just don't know how it works inline
[QUOTE=Feihc;38337662]I know it takes a material >.> I was asking for an EXAMPLE of how its used. Could have easily (and I did) look up the arguments for it. I just don't know how it works inline[/QUOTE] You just wrap any rendering function inbetween it, and make sure it's inside a rendering camera or draw function of some sort. If you don't know how to use rendering functions such as cam.Start3D() then this function is fairly useless. However i will humour you. [code] for k,v in pairs( ents.FindByClass( "prop_physics" ) ) do if( IsValid( v ) ) then cam.Start3D( EyePos(), EyeAngles() ) render.SetMaterialOverride( Material( "myshittymaterial" ) ) render.SetBlend( 0.8 ) v:DrawModel() render.SetBlend( 1 ) render.SetMaterialOverride( 0 ) cam.End3D() end end [/code] This will draw all props with your material slightly transparently (that's the blend function) [editline]6th November 2012[/editline] [QUOTE=brandonj4;38337596]I did read what you said and once again the entity already has bonemerge: self:AddEffects(bit.bor(EF_BONEMERGE, EF_BONEMERGE_FASTCULL, EF_PARENT_ANIMATES))[/QUOTE] [QUOTE=Ownage96;38325547]and call hat:AddEffects( EF_BONEMERGE ) [b](on the client side)[/b][/QUOTE] Again... please read
[QUOTE=CherryJim;38318144]How do I simply disable the creations menu in my server?[/QUOTE] [lua] function GM:SpawnMenuEnabled() return false end function GM:SpawnMenuOpen() return false end [/lua] Add those in cl_init and the Spawn menu and Context menu will be disabled ( Still functional if you want to bind derma to +menu or +menu_context )
[QUOTE=brandonj4;38316420]I'm having an issue with [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html"]Parenting[/URL].[/QUOTE] [lua] hook.Add("PostPlayerDraw", "PointShop_PostPlayerDraw", function(ply) if not ply:Alive() then return end --print(ply._Hats) --print('hats') if not POINTSHOP.Config.AlwaysDrawHats and not hook.Call("ShouldDrawHats", GAMEMODE) and ply == LocalPlayer() and GetViewEntity():GetClass() == "player" then return end if ply._Hats and #ply._Hats then for id, hat in pairs(ply._Hats) do local pos = Vector() local ang = Angle() if not hat.Attachment and not hat.Bone then return end if hat.Attachment then local attach = ply:GetAttachment(ply:LookupAttachment(hat.Attachment)) pos = attach.Pos ang = attach.Ang elseif hat.Bone then pos, ang = ply:GetBonePosition(ply:LookupBone(hat.Bone)) end hat.Model, pos, ang = hat.Modify(hat.Model, pos, ang) hat.Model:SetPos(pos) hat.Model:SetAngles(ang) hat.Model:SetRenderOrigin(pos) hat.Model:SetRenderAngles(ang) hat.Model:SetupBones() hat.Model:DrawModel() hat.Model:SetRenderOrigin() hat.Model:SetRenderAngles() end end end) [/lua] Taken from the [url=http://facepunch.com/showthread.php?t=1126155]PointShop by DrJenkins[/url]
I hope I'm at the right place. I have a problem with the workshop addon "No Collide - Multi" [url]http://steamcommunity.com/sharedfiles/filedetails/?id=106320101[/url] Yes, I've already contacted the uploader, but he doesn't know what's wrong. He doesn't have this error. [CODE][No Collide - Multi] lua/includes/util.lua:33: bad argument #1 to 'min' (number expected, got nil) 1. min - [C]:-1 2. Color - lua/includes/util.lua:33 3. ClearSelection - lua/weapons/gmod_tool/stools/no_collide_multi.lua:110 4. RightClick - lua/weapons/gmod_tool/stools/no_collide_multi.lua:169 5. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua[/CODE] The tool is pretty straight forward, you select multiple props with left click (they get colored) and confirm with right click. The error happens when I try to confirm the selection. The props are no-collided as they should though, but they are still colorized. I tried disabling all my addons, but same result.
ply:SetWalkSpeed(250) When I set sv_accelerate to 5 (standard for most other source games), the player starts walking at 155 walkspeed is there some way to stop this from happening? I need the standard acceleration for my speed run based mod (if i set walkspeed to around 350 so that it cancels the problem, the walking sound is way fast)
[QUOTE=andreasf11;38330741]how can i use custom fonts in my hud like this one: [URL]http://www.dafont.com/velocity.font[/URL] ?[/QUOTE] Put it into the resource/fonts folder and use surface.CreateFont. Don't forget to resource.AddFile the font as well.
Im trying to get rid of my server crashes.. Im going cray with that shit ;( [CODE]Not creating entity 'instanced_scripted_scene' - too many edicts! (8064 current, 8192 max)[/CODE] I dont creat this entity (about 2000 times..) :( and im not sure where they come from and how to debug it.. some ideas?
Is there a way to initialize physics as a cylinder? Apart from using Entity:PhysicsFromMesh() ?
Sorry, you need to Log In to post a reply to this thread.