• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Trumple;38933791]Oh, if he wants the one the player is looking at then: [lua] hook.Add( "PlayerSpawn", "PickupTimeoutInit", function( ply ) ply.PickupTimeout = CurTime() + 0.5 end ) hook.Add( "PlayerCanPickupWeapon", "PreventPickup", function( ply, wep ) if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end end ) hook.Add( "KeyPress", "PressUse", function( ply, key ) if ( key == IN_USE ) then local tr = ply:GetEyeTrace() if ( IsValid( tr.Entity ) && tr.Entity:IsWeapon() && tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 96 ) then ply.PickupTimeout = CurTime() + 0.5 ply:Give( tr.Entity:GetClass() ) tr.Entity:Remove() end end end ) [/lua] Could probably handle the removing differently but, proof of concept[/QUOTE] Would still do it, if I had two weapons next to each other and I looked at one and press use, it would pick up both.
[QUOTE=Drakehawke;38933822]Would still do it, if I had two weapons next to each other and I looked at one and press use, it would pick up both.[/QUOTE] The guy didn't specify if he wanted that, I'm not about to write an elaborate bit of code for something he may not care about :v: If you like, when a weapon is picked up, set the pickup timeout to CurTime(), meaning the USE key has to be pressed again to enable another pickup The main idea of how to go about doing it is there, though
Can someone help me ? I'm having trouble using [CODE]include("core/sharedfiles/sh_bank.lua")[/CODE] It says its not found The file that holds the include is located @ [CODE]\gamemode\core\serverfiles[/CODE]
-snip misread-
Is there anyway to make a command that connects you to another server? I heard that gui.OpenURL doesn't work anymore.
[QUOTE=havejack;38934355]Can someone help me ? I'm having trouble using [CODE]include("core/sharedfiles/sh_bank.lua")[/CODE] It says its not found The file that holds the include is located @ [CODE]\gamemode\core\serverfiles[/CODE][/QUOTE] Is it not found on client or server?
[QUOTE=Chessnut;38934572]Is it not found on client or server?[/QUOTE] Its not
[QUOTE=Trumple;38928844]I think that method would prevent using ply:Give(blah) (though it is more elegant)[/QUOTE] [lua]SWEP.CanPickup = {} function SWEP:Initialize() hook.Add( "PlayerCanPickupWeapon", self, self.CanPickup ) hook.Add( "KeyPress", self, self.KeyPress ) self.SpawnPickup = CurTime()+0.5 end function SWEP:CanPickup( ply, wep ) if wep==self then return (CurTime()<self.SpawnPickup) or (self.CanPickup[ply] and (self.CanPickup[ply]>CurTime())) end end function SWEP:KeyPress( ply, key ) if key==IN_USE and ply and IsValid( ply ) then local tr = ply:GetEyeTrace() local ent, dist = tr.Entity, tr.StartPos:Distance( tr.HitPos ) if tr.Hit and ent==self and dist<100 then self.CanPickup[ply] = CurTime()+0.2 end end end[/lua]
[QUOTE=andre_bule;38932525]What's wrong? [CODE]function GM:InitPostEntity ( ) self.GatherInvalidNames(); local GPNP = function() GAMEMODE.PushNumPlayers end timer.Simple(1, GPNP); end[/CODE] Error: [CODE][ERROR] gamemodes/perp3/gamemode/sv_hoocks.lua:114: ´=´ expected near ´end´ 1.unknown - gamemodes/perp3/gamemode/sv_hooks.lua:0[/CODE] I seriouslly don't get it[/QUOTE] no one wants to help you with perp, and you don't get it because you don't know how to code
[QUOTE=P.Tigris;38926077]This is how LocalToWorld is calculated: [lua] function ENT:LocalToWorld(Vec) local Pos = self:GetPos() local EntityForward = self:GetForward() local EntityRight = self:GetRight() local EntityUp = self:GetUp() return Pos+(EntityForward*Vec.x)+(EntityRight*Vec.y)+(EntityUp*Vec.z) end [/lua] And This is how WorldToLocal is calculated: [lua] function ENT:WorldToLocal(Vec1) local Pos = self:GetPos() local EntityForward = self:GetForward() local EntityRight = self:GetRight() local EntityUp = self:GetUp() local Vec2 = Vec1-Pos -- F.x*R.y*U.z+F.y*U.x+F.z*R.x*U.y-F.z*R.y*U.x-F.y*R.x*U.z-F.x*R.z*U.y = Rule of Sarrus. local Forward = -(Vec2.x*EntityRight.y*EntityUp.z+Vec2.y*EntityRight.z*EntityUp.x+Vec2.z*EntityRight.x*EntityUp.y-Vec2.z*EntityRight.y*EntityUp.x-Vec2.y*EntityRight.x*EntityUp.z-Vec2.x*EntityRight.z*EntityUp.y) local Right = (EntityForward.x*Vec2.y*EntityUp.z+EntityForward.y*Vec2.z*EntityUp.x+EntityForward.z*Vec2.x*EntityUp.y-EntityForward.z*Vec2.y*EntityUp.x-EntityForward.y*Vec2.x*EntityUp.z-EntityForward.x*Vec2.z*EntityUp.y) local Up = -(EntityForward.x*EntityRight.y*Vec2.z+EntityForward.y*EntityRight.z*Vec2.x+EntityForward.z*EntityRight.x*Vec2.y-EntityForward.z*EntityRight.y*Vec2.x-EntityForward.y*EntityRight.x*Vec2.z-EntityForward.x*EntityRight.z*Vec2.y) return Vector(Forward,Right,Up) end [/lua][/QUOTE] Big thanks for your help, but I managed to solve it by looking at Source's sourcecode! [url]http://pastebin.com/Ni5Cs4LT[/url]
Does anyone know how I can create particles with TF2? I tried the ParticleEffectAttach function but it says the particle is unknown even though I used game.AddParticles for it.
How can I remove this view restriction the SkyBox gives me? [url]http://i.imgur.com/HD46y.jpg[/url] - The view distance [url]http://i.imgur.com/AmLvx.jpg[/url] - The wall I want to see [url]http://i.imgur.com/fHjst.jpg[/url] - Another good look at how it restricts me
DarkRP - How do I add printers? I make printers print 2500$, But they only print $250. I tried deleting the config print amount, it doesnt print anything then. How do I do fix this?
[QUOTE=Hyper Iguana;38936561]How can I remove this view restriction the SkyBox gives me? [url]http://i.imgur.com/HD46y.jpg[/url] - The view distance [url]http://i.imgur.com/AmLvx.jpg[/url] - The wall I want to see [url]http://i.imgur.com/fHjst.jpg[/url] - Another good look at how it restricts me[/QUOTE] Looks like improperly configured fog to me. I don't know much about the fog entity but removing it may be a rough fix. try this in console: [lua] lua_run for k,v in pairs(ents.FindByClass("env_fog_controller")) do v:Remove() end [/lua]
[QUOTE=Mitsudigi;38936621]Looks like improperly configured fog to me. I don't know much about the fog entity but removing it may be a rough fix. try this in console: [lua] lua_run for k,v in pairs(ents.FindByClass("env_fog_controller")) do v:Remove() end [/lua][/QUOTE] That gave me a little more view distance, but there is still something there. [url]http://i.imgur.com/wLhqI.jpg[/url] - Before [url]http://i.imgur.com/wE1Cv.jpg[/url] - After
I think there's too many faces too render.
[QUOTE=Hyper Iguana;38936741]That gave me a little more view distance, but there is still something there. [url]http://i.imgur.com/wLhqI.jpg[/url] - Before [url]http://i.imgur.com/wE1Cv.jpg[/url] - After[/QUOTE] Video Settings -> Advanced -> View Distance? -> 90.00
[QUOTE=Sharkie;38936596]DarkRP - How do I add printers? I make printers print 2500$, But they only print $250. I tried deleting the config print amount, it doesnt print anything then. How do I do fix this?[/QUOTE] This wiki entry will probably explain better me: [url]http://wiki.darkrp.com/index.php/LUA:Custom_Money_Printer[/url]
[QUOTE=reenesj;38937032]Video Settings -> Advanced -> View Distance? -> 90.00[/QUOTE] it looks like he's getting the "too many vertex changes" error there
[QUOTE=Banana Lord.;38937822]it looks like he's getting the "too many vertex changes" error there[/QUOTE] My console is spammed with the error, so I would guess you're right there. Is there any way to workaround this error through lua?
[CODE] local Flying local Swoop local AntiSpamSwoop function GM:SetupMove(ply, move) local ReboundPowerUp = 600 local ReboundPower = 1 local ForwardVelo = ply:GetForward():GetNormalized() local RightVelo = ply:GetRight():GetNormalized() local VecVelo = Vector(0,0,0) local CurrVelo = ply:GetVelocity() if ply:IsOnGround() then timer.Simple(0.01, function() if !ply:IsOnGround() then ply:EmitSound("dbz/jump.wav") end end) Flying = false end if !ply:IsOnGround() and ply:KeyPressed(IN_JUMP) and Flying != true then Flying = true elseif !ply:IsOnGround() and ply:KeyPressed(IN_JUMP) and Flying == true then Flying = false end if (Flying == true) then VecVelo = CurrVelo + (ForwardVelo * ReboundPower) VecVelo.z = CurrVelo.z + ReboundPowerUp ply:SetVelocity(VecVelo - CurrVelo) if ply:KeyDown(IN_FORWARD) then Power = 50 PowerUp = 600 VecVelo = CurrVelo + (ForwardVelo * Power) VecVelo.z = CurrVelo.z + PowerUp ply:SetVelocity(VecVelo - CurrVelo) Swoop = true end if ply:KeyDown(IN_MOVELEFT) then Power = 80 PowerUp = 600 VecVelo = CurrVelo + (RightVelo * -Power) VecVelo.z = CurrVelo.z + PowerUp ply:SetVelocity(VecVelo - CurrVelo) Swoop = true end if ply:KeyDown(IN_MOVERIGHT) then Power = 80 PowerUp = 600 VecVelo = CurrVelo + (RightVelo * Power) VecVelo.z = CurrVelo.z + PowerUp ply:SetVelocity(VecVelo - CurrVelo) Swoop = true end end end [/CODE] Not quite sure how I'd make it work for INDIVIDUAL players, rather than when 1 player tries to fly, every other player will fly too.. Oh and then there's the fact that if another player is on the ground, then nobody can fly.. Any ideas?
[QUOTE=Minteh Fresh;38939724]Not quite sure how I'd make it work for INDIVIDUAL players, rather than when 1 player tries to fly, every other player will fly too.. Oh and then there's the fact that if another player is on the ground, then nobody can fly.. Any ideas?[/QUOTE] You're not making a separate variable for Flying, Swoop or AntiSpamSwoop per player. At the moment, you're just using one variable for everyone - and it's being set every time SetupMove is called for each player, hence why one person controls things. Try defining those variables as ply.Flying, ply.Swoop, and ply.AntiSpamSwoop.
Is there a way to make a entity act like a ragdoll, if I set its model to the, lets say, of the zombie ragdoll, the entitie looks like the statue of the zombie, I needed it to fall to the ground like if a dead body after I spawn it...
[QUOTE=Stillnex;38941081]Is there a way to make a entity act like a ragdoll, if I set its model to the, lets say, of the zombie ragdoll, the entitie looks like the statue of the zombie, I needed it to fall to the ground like if a dead body after I spawn it...[/QUOTE] Create the entity under prop_ragdoll
[QUOTE=Hyper Iguana;38941097]Create the entity under prop_ragdoll[/QUOTE] The problem is that my entity had a bunch of derma stuff linked to it, can I still maintain all that functionality using prop_ragdoll?
[IMG]http://i.imgur.com/2uZUy.jpg[/IMG] How do I stop the Models from going out of the list? [lua] function LoadModels() ItemColumn = vgui.Create( "DPanelList", ITEMS ) ItemColumn:SetWide(ITEMS:GetWide()) ItemColumn:SetTall(ITEMS:GetTall()) ItemColumn:SetPos(0,0) ItemColumn:EnableHorizontal(true) ItemColumn:EnableVerticalScrollbar(true) ItemColumn:SetPadding(5) ItemColumn:SetSpacing(5); ItemColumn.Paint = function() draw.RoundedBox( 0, 0, 0, ITEMS:GetWide(), ITEMS:GetTall(), Color( 30, 30, 30, 255 )) end for k, v in SortedPairs(modellist) do iconb = vgui.Create("DPanel", ItemColumn) iconb:SetSize( 131, 131 ) iconb.Paint = function() draw.RoundedBox( 4, 0, 0, iconb:GetWide(), iconb:GetTall(), Color(255, 255, 255, 10)) end icon = vgui.Create( "DModelPanel", iconb ) icon:SetSize( iconb:GetWide(),iconb:GetTall() ) icon:SetModel(v[2]) icon:SetToolTip(v[1]) icon.DoRightClick = function() MenuButtonOptions = DermaMenu() -- Creates the menu MenuButtonOptions:AddOption("Equip Item", function() Msg("Equipped " .. v[1]) end ) -- Add options to the menu MenuButtonOptions:AddOption("Sell Item", function() Msg("Sold " .. v[1]) end ) MenuButtonOptions:Open() end icont = vgui.Create("DButton", icon) icont:SetSize( 131, 20 ) icont:SetPos(0, 111) icont:SetText("Buy " .. v[1]) icont.Paint = function() draw.RoundedBox( 0, 0, 0, icont:GetWide(), icont:GetTall(), Color(50, 50, 80, 150)) end ItemColumn:AddItem(iconb) end end [/lua]
Did garry ever fix SNPCS's?
I put up a new christmas script, although the models, materials, sounds don't work unless the client restarts gmod. Could anyone explain why, or what I have set up wrong? The clients download the files when they join and I have confirmed that they do have them all and in tact, although they don't work until gmod is restarted on their end.
[QUOTE=prang123;38941290][IMG]http://i.imgur.com/2uZUy.jpg[/IMG] How do I stop the Models from going out of the list? [lua] function LoadModels() ItemColumn = vgui.Create( "DPanelList", ITEMS ) ItemColumn:SetWide(ITEMS:GetWide()) ItemColumn:SetTall(ITEMS:GetTall()) ItemColumn:SetPos(0,0) ItemColumn:EnableHorizontal(true) ItemColumn:EnableVerticalScrollbar(true) ItemColumn:SetPadding(5) ItemColumn:SetSpacing(5); ItemColumn.Paint = function() draw.RoundedBox( 0, 0, 0, ITEMS:GetWide(), ITEMS:GetTall(), Color( 30, 30, 30, 255 )) end for k, v in SortedPairs(modellist) do iconb = vgui.Create("DPanel", ItemColumn) iconb:SetSize( 131, 131 ) iconb.Paint = function() draw.RoundedBox( 4, 0, 0, iconb:GetWide(), iconb:GetTall(), Color(255, 255, 255, 10)) end icon = vgui.Create( "DModelPanel", iconb ) icon:SetSize( iconb:GetWide(),iconb:GetTall() ) icon:SetModel(v[2]) icon:SetToolTip(v[1]) icon.DoRightClick = function() MenuButtonOptions = DermaMenu() -- Creates the menu MenuButtonOptions:AddOption("Equip Item", function() Msg("Equipped " .. v[1]) end ) -- Add options to the menu MenuButtonOptions:AddOption("Sell Item", function() Msg("Sold " .. v[1]) end ) MenuButtonOptions:Open() end icont = vgui.Create("DButton", icon) icont:SetSize( 131, 20 ) icont:SetPos(0, 111) icont:SetText("Buy " .. v[1]) icont.Paint = function() draw.RoundedBox( 0, 0, 0, icont:GetWide(), icont:GetTall(), Color(50, 50, 80, 150)) end ItemColumn:AddItem(iconb) end end [/lua][/QUOTE] [url]http://wiki.garrysmod.com/page/Libraries/render/SetScissorRect[/url]
[QUOTE=khuba;38942274][url]http://wiki.garrysmod.com/page/Libraries/render/SetScissorRect[/url][/QUOTE] How would I use that to stop the models from "overflowing"? Any chance of an example so I can understand, I really don't follow.
Sorry, you need to Log In to post a reply to this thread.