• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Nak;39576314]RunConsoleCommand("+attack2") should work. .. are you sure you did RunConsoleCommand("-attack2") to reset it after?[/QUOTE] You know, if +attack2 worked I would totaly do -attack2 afterwards -.- Can someone who actually knows the issue reply ? I do: [lua]LocalPlayer():ConCommand("+attack2") RunConsoleCommand("+attack2")[/lua] Neither of these work, but.... [lua]LocalPlayer():ConCommand( "use weapon_real_cs_knife")[/lua] works just fine [QUOTE=Monttumopo;39580831]So im i made a small map with hammer where i made an entity and renamed it to "test_repeonkana_spawn" ( insidejk) and then i created team.SetSpawnPoint( 1, "test_repeonkana_spawn" ) in my "gamemodes" shared.lua. I didnt have time to test it cuz i ran out of time and now its 2.45 at night here in Finland and i cant get sleep since im thinking it someone tell me does it work or em i even close [/QUOTE] I think that should work as long as team.SetSpawnPoint() is allowed to use any entity and I'd believe it does.
Is there a simple way to change the owner of an entity in DarkRP? I'm wanting to make it so that when someone activates a printer, they own it and if the original owner disconnects, it won't be removed. Current code: [CODE] if activator != self.dt.owning_ent then GAMEMODE:Notify(self.dt.owning_ent, 1, 4, "Someone now owns your money printer!") self:UnOwn(self.dt.owning_ent) self.dt.owning_ent = activator self:Own(self.dt.owning_ent) GAMEMODE:Notify(self.dt.owning_ent, 0, 4, "You now own this printer!") end[/CODE]
Did Garry decide to get creative with the wiki again... [thumb]http://puu.sh/22hwS[/thumb] ...and then get mad at the working themes? [IMG]http://puu.sh/22hxN[/IMG]
How can I add music at the start of every round? I've tried searching and I can't seem to find it.
-fixed-
[QUOTE=Science;39585064]Why do my entities not spawn... This gets printed in console: [code]Entity [918][atm] Entity [919][atm] Entity [920][atm] Entity [921][atm][/code] This is the code: [lua]hook.Add("InitPostEntity", "Do", function() local map = game.GetMap() if !bank.Maps[map] then return end for k,v in pairs(bank.Maps[map]) do local ent = ents.Create("ATM") ent:Spawn() ent:SetPos(v[1] or Vector(0,0,0)) ent:SetAngles(v[2] or Angle(0,0,0)) print(ent) end end)[/lua] And yet nothing apears on the map.[/QUOTE] Are you sure your entities are drawing in the cl_init file?
[QUOTE=soupface;39585032]How can I add music at the start of every round? I've tried searching and I can't seem to find it.[/QUOTE] [URL="http://wiki.garrysmod.com/page/Libraries/sound/Play"]Sound.Play()[/URL]
Does anybody else crash with "Engine error: GetTable - not a table!" sometimes or is it just me?
[QUOTE=Loures;39585468]Does anybody else crash with "Engine error: GetTable - not a table!" sometimes or is it just me?[/QUOTE] I had the same problem sometimes.
What is wrong with this script? My entity is creating errors because of the istrigger part. I get the following error: [ERROR] lua/entities/tf2_syringe/init.lua:65: attempt to call method 'IsTrigger' (a nil value) 1. unknown - lua/entities/tf2_syringe/init.lua:65 Here is my code: [code] function ENT:Touch( ent ) if not ent:IsTrigger() then if ent:IsNPC() or ent:IsPlayer() then ent:TakeDamage(math.random(8,12), self.Owner, self) ETC... [/code] thanks!
What would be the equivilent of DNumSlider in Gmod13? All i can seem to use is DSlider which to be honest, is plain awful.
I've been faffing about with DTVars a bit recently, and I decided to try making a simple script to make a DTVar with a boolean value alternate between it's false and true values every time I fire the SWEP it's embedded in, and I attached a print function to to return "yes" every time the value switches to true, and to return "no" every time it switches to false, mainly just to see if it's really working like it should. Problem is, it only ever prints yes. [code]function SWEP:SetupDataTables() self:DTVar("Bool",0,"Hols") end function SWEP:PrimaryAttack() if (self.dt.Hols==false) then self.dt.Hols=1 and print("yes") else self.dt.Hols=0 and print("no") end [/code] Any ideas what I'm doing wrong here?
How do I completely remove a value from a table? I'm having a problem removing keys/references from a table. I have a scrolling text panel that reads messages from a table , when a message pops off the end I remove it, recreate it on the right and then try to remove the popped element. I've tried [lua] self.messages[i] = nil [/lua] but the length of the table still increases. Now it 'works' but I'm obviously worried about what may happen over a period of time. snippet [lua] function PANEL:Think() print(table.Count(self.messages)) local i = 0 for k,v in ipairs(self.messages) do if IsValid(v) then local x,y = v:GetPos() if x <= 0 && not v.inserted then v:SetPos(x - self.scrollspeed,4) self:NewMsg(v:GetText()) v.inserted = true elseif x + v:GetWide() <= 0 then v:Remove() self.messages[i] = nil else v:SetPos(x - self.scrollspeed, 4) end end end end function PANEL:NewMsg(txt) local msg = vgui.Create("DLabel",self) msg:SetPos(ScrW(),4) msg:SetText(txt) msg:SizeToContents() for k,v in pairs(self.messages) do if IsValid(v) then local x,y = v:GetPos() if x + self.spacing > msg.x then msg.x = v.x + self.spacing end end end table.insert(self.messages, msg) end [/lua] [editline]14th February 2013[/editline] [QUOTE=elowin;39586515]Any ideas what I'm doing wrong here?[/QUOTE] You haven't closed the function, but I reckon that's just a problem with copy and paste... That's a weird way of doing an if statement though, what are you trying to do with; [lua]and[/lua] try this, [lua] function SWEP:SetupDataTables() self:DTVar("Bool",0,"Hols") end function SWEP:PrimaryAttack() if (self.dt.Hols == false) then self.dt.Hols = 1 print("yes") else self.dt.Hols=0 print("no") end end [/lua] [editline]14th February 2013[/editline] [QUOTE=Science;39586276]What would be the equivilent of DNumSlider in Gmod13? All i can seem to use is DSlider which to be honest, is plain awful.[/QUOTE] You [I]could[/I] make your own one.
[QUOTE=jaooe;39586602]You haven't closed the function, but I reckon that's just a problem with copy and paste... That's a weird way of doing an if statement though, what are you trying to do with; [lua]and[/lua] try this, [lua] function SWEP:SetupDataTables() self:DTVar("Bool",0,"Hols") end function SWEP:PrimaryAttack() if (self.dt.Hols == false) then self.dt.Hols = 1 print("yes") else self.dt.Hols=0 print("no") end end [/lua][/QUOTE] Not really sure what I was doing with those ands either, just felt right I guess, removed them. And yeah, the function is closed, just didn't copy paste the whole function since the problem is in this particular part. Anyway, it's still just printing "no" constantly, so there's still something else wrong with what i'm doing here. I find this a little perplexing to be honest, I just can't figure out what I'm doing wrong at all. [code]function SWEP:SetupDataTables() self:DTVar("Bool",0,"Hols") end function SWEP:PrimaryAttack() if (self.dt.Hols==false) then self.dt.Hols=1 print("yes") else self.dt.Hols=0 print("no") end [/code] Looks just fine to me :v:
I've never used data tables before so I don't have a clue either. If I were you I would try [lua] function SWEP:SetupDataTables() self.holstered = false end function SWEP:PrimaryAttack() if !self.holstered then print("yes") self.holstered = !self.holstered else print("no") self.holstered = !self.holstered end end [/lua] That will toggle the value of self.holstered between true and false, starting at false.
I am trying to make clothing for Clockwork, for the citizens. How do I make so different models leads to different models? I mean, if male_09 equips the clothing, how do I make it so he's still male_09, but with the clothing on? Right now I only have a small if female then one model, else it must be a guy, therefore the other model, but there are 18 different human models, so I can't go with that as far as I know. [editline]14th February 2013[/editline] Wait nevermind looked into the rebel clothing and copied the part from there.
[QUOTE=jaooe;39587821]I've never used data tables before so I don't have a clue either. If I were you I would try [lua] function SWEP:SetupDataTables() self.holstered = false end function SWEP:PrimaryAttack() if !self.holstered then print("yes") self.holstered = !self.holstered else print("no") self.holstered = !self.holstered end end [/lua] That will toggle the value of self.holstered between true and false, starting at false.[/QUOTE] I'm pretty sure that's not how datatables work, but I'll try doing it like that. Wow, that actually worked, thanks man!
[QUOTE=Science;39586276]What would be the equivilent of DNumSlider in Gmod13? All i can seem to use is DSlider which to be honest, is plain awful.[/QUOTE] DNumSlider is still valid
I'm getting this error when i press z to remove my entity: [CODE][ERROR] LuaCmd:1: ')' expected near 's' 1. unknown - LuaCmd:0 [/CODE] I have no clue what it means. Help would be appreciated :)
Client particle emitters don't seem to work for me. Here is cl_init.lua in castparticles [lua]EFFECT.Origin=vector_origin function EFFECT:Init(effectdata) self.Origin=effectdata:GetOrigin() self:SetPos(self.Origin) local em = ParticleEmitter(self.Origin) for i=1, 20 do local part = em:Add("sprites/light_glow02_add",centr) if part then part:SetColor(255,255,255,math.random(255)) part:SetVelocity(Vector(math.random(-1,1),math.random(-1,1),math.random(-1,1)):GetNormal() * 20) part:SetDieTime(0.5) part:SetLifeTime(0) part:SetStartSize(10) part:SetEndSize(0) end end em:Finish() end function EFFECT:Think() return true end function EFFECT:Render() end[/lua] Here is the code used to spawn it [lua] local plraimv=LocalPlayer():GetAimVector() local aimv=util.AimVector( plraimv:Angle(), LocalPlayer():GetFOV(), pos.x, pos.y, ScrW(), ScrH() ) local pos=LocalPlayer():EyePos() local effectdata=EffectData() effectdata:SetOrigin(pos+aimv*100) --util.Effect("HelicopterMegaBomb",effectdata) util.Effect("castparticles",effectdata) [/lua] For some reason it works with the helicoptermegabomb, but not with the particle effect. Can someone please tell me why? Thanks!
So I'm moving some bones around in a view model to make a different view model, but the issue is that ManipulateBonePosition doesnt seem to be working correctly or something. Depending on where I am on the map, this shit happens [img]http://puu.sh/22y7K[/img] I can still see the hand, even though it should be behind my head [lua] SWEP.ViewModel = Model( "models/weapons/v_knife_t.mdl" ) SWEP.BonesToHide = {"v_weapon.knife_Parent", "v_weapon.Knife_Handle", "v_weapon.Left_Arm"} function SWEP:ViewModelDrawn(vm) for k, v in ipairs( self.BonesToHide ) do local bone = vm:LookupBone( v ) if bone and bone >= 0 then vm:ManipulateBonePosition( bone, EyePos( ) - EyeAngles( ):Forward( ) * 300 ) vm:ManipulateBoneScale( bone, vector_origin ) end end [/lua] Any thoughts?
[QUOTE=Feihc;39589531]So I'm moving some bones around in a view model to make a different view model, but the issue is that ManipulateBonePosition doesnt seem to be working correctly or something. Depending on where I am on the map, this shit happens [img]http://puu.sh/22y7K[/img] I can still see the hand, even though it should be behind my head [lua] SWEP.ViewModel = Model( "models/weapons/v_knife_t.mdl" ) SWEP.BonesToHide = {"v_weapon.knife_Parent", "v_weapon.Knife_Handle", "v_weapon.Left_Arm"} function SWEP:ViewModelDrawn(vm) for k, v in ipairs( self.BonesToHide ) do local bone = vm:LookupBone( v ) if bone and bone >= 0 then vm:ManipulateBonePosition( bone, EyePos( ) - EyeAngles( ):Forward( ) * 300 ) vm:ManipulateBoneScale( bone, vector_origin ) end end [/lua] Any thoughts?[/QUOTE] Maybe the vector_origin has something to do with it? Here's an easier workaround: scale all the bones in the arm to 0 instead
[QUOTE=Ylsid;39589622]Maybe the vector_origin has something to do with it? Here's an easier workaround: scale all the bones in the arm to 0 instead[/QUOTE] :| vector_origin = Vector(0,0,0) And I don't really have to scale the bones anyway, if I move them then I shouldn't be able to see them either way, but at certain positions and angles I can. My first attempt was to scale ALL of the bones in the left hand to 0, but there were some floating ghost bones that I couldn't get rid of that left a bit of the glove just floating there.
[QUOTE=Feihc;39589660]:| vector_origin = Vector(0,0,0) And I don't really have to scale the bones anyway, if I move them then I shouldn't be able to see them either way, but at certain positions and angles I can. My first attempt was to scale ALL of the bones in the left hand to 0, but there were some floating ghost bones that I couldn't get rid of that left a bit of the glove just floating there.[/QUOTE] Maybe manipulateboneposition takes local coords instead of global ones, perhaps? Is it because you're doing * 300 instead of * -300?
[QUOTE=Ylsid;39589753]Maybe manipulateboneposition takes local coords instead of global ones, perhaps?[/QUOTE] Good idea, but it seems like even if I toworld the data, it just changes the position/angles at which the hand is visible.
Does anyone know if there's a certain way to stop entities and things like that from rendering if they're a certain distance away or they're not visible? Should significantly decrease lag on certain gamemodes if I'm not mistaken.
Did anyone read my question above? I seem to be getting ignored whenever i ask for help here :/
[QUOTE=Mr Cookieman;39590094]Did anyone read my question above? I seem to be getting ignored whenever i ask for help here :/[/QUOTE] Mostly because with what you gave us doesn't give us shit to go on, give us your code and which line of that the error appears on.
[QUOTE=Donkie;39590500]Mostly because with what you gave us doesn't give us shit to go on, give us your code and which line of that the error appears on.[/QUOTE] If you read the error you would understand that i dont know where the error is. I have no clue what it is about!
You could explain us if you added something, or what the last thing you did was before the error popped up..
Sorry, you need to Log In to post a reply to this thread.