• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Author.;47640582][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/SortByMember]table.SortByMember[/url] ?[/QUOTE] Thanks, convinient function :dance:
for some reason sound doesn't work in entity for me when spawned on InitPostEntity, it works if I later on respawn it(call same function that spawns it in InitPostEntity), I tried precache sound not sure why it would do anything but it didn't anyway, I do with CreateSound( self, "soundfile", self:EntIndex() ) it seems like it has to be spawned after the player joined for him to hear it, what can I do about that?
i've an small issue with my HUD. Code: [url]https://github.com/Tomelyr/bHUD/blob/master/lua/darkrp_modules/bhud/cl_bhud.lua#L87[/url] Basicly it breaks, because Player:Nick() is a nil value. I didn't realised this until now, since i worked the whole time with autorefresh. After loading and refreshing, it works. Dunno why it says nil tbh. found the issue. LocalPlayer() is nil, when i call it the first time.
Hello, I tried to create entity without model but with gravity(falling to ground), like minecraft items, but I didn't know how do this... [IMG]http://screenshot.su/img/8f/dd/ec/8fddecb9371b30d6b2b789ca16a82641.jpg[/IMG]
[QUOTE=UnkN;47649338]Hello, I tried to create entity without model but with gravity(falling to ground), like minecraft items, but I didn't know how do this... [IMG]http://screenshot.su/img/8f/dd/ec/8fddecb9371b30d6b2b789ca16a82641.jpg[/IMG][/QUOTE] As far as I know, you need a model for physics stuff. Otherwise, how would the physics engine know when it is on the ground? A solution could be to have a really small model (or even a normal model scaled down through lua), and not draw it.
[QUOTE=UnkN;47649338]Hello, I tried to create entity without model but with gravity(falling to ground), like minecraft items, but I didn't know how do this... [IMG]http://screenshot.su/img/8f/dd/ec/8fddecb9371b30d6b2b789ca16a82641.jpg[/IMG][/QUOTE] Perhaps use ENTITY:PhysicsInit* functions? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/PhysicsInitBox]Entity:PhysicsInitBox[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/PhysicsInitSphere]Entity:PhysicsInitSphere[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/PhysicsInitConvex]Entity:PhysicsInitConvex[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/PhysicsInitMultiConvex]Entity:PhysicsInitMultiConvex[/url]
this is the code I used for my minecraft gamemode, I used the skull gib as the model because it had a nice size shadow [lua]AddCSLuaFile() ENT.Type = "anim" ENT.Base = "base_anim" if SERVER then function ENT:Initialize() self:SetModel("models/Gibs/HGIBS.mdl") self:PhysicsInit( SOLID_VPHYSICS ) --self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetMoveType( MOVETYPE_CUSTOM ) self:SetSolid( SOLID_NONE ) --self:PhysWake() end function ENT:Think() if not(self.ply) then for k,v in pairs(player.GetAll()) do if(v:GetPos():DistToSqr(self:GetPos()) < 64 ^ 2 and v:Alive()) then self.ply = v end end else if(self:GetPos():DistToSqr(self.ply:GetPos() + Vector(0, 0, 32)) < 8 ^ 2) then --self.ply:giveItem(self.item) self:Remove() else local pos = self:GetPos() local norm = ((self.ply:GetPos() + Vector(0, 0, 32)) - pos):GetNormalized() self:SetPos(pos + norm*16) self:NextThink(CurTime()) return true end end end else function ENT:Initialize() self.createtime = CurTime() end function ENT:Draw() self:DrawModel() local norm = (LocalPlayer():GetPos() - self:GetPos()):GetNormalized() norm.z = 0 render.SetMaterial(whatever) render.DrawQuadEasy(self:GetPos() + Vector(0, 0, 16 + math.cos(self.createtime + CurTime()*2)*4), norm, 16, 16, Color(255, 255, 255), 180) end end [/lua]
[URL="http://facepunch.com/member.php?u=235325"]PortalGod[/URL], thanks. It really helpfull for me code. UPD: New problem, rendering without Z pos. Render code from [URL="http://facepunch.com/member.php?u=235325"]PortalGod's[/URL] code, because I do draw function without render. [IMG]http://screenshot.su/img/b5/9b/91/b59b91f590c762b99a54a9b69370b3be.jpg[/IMG]
Hello, i have a small problem with gui.EnableScreenClicker. I'm trying to make cursor to appear when i hold C and dissapear when i release it and it's working fine but it messes up pointshop gui.EnableScreenClicker so yeah... I'm out of ideas. [CODE]hook.Add( "Think", "BM_Clients_Key", function() gui.EnableScreenClicker( input.IsKeyDown( KEY_C ) ) end )[/CODE] I've also tried to use true and false instead of input.IsKeyDown like this: [CODE]if input.IsKeyDown(KEY_C) then gui.EnableScreenClicker(true) elseif not input.IsKeyDown(KEY_C) and gui.EnableScreenClicker() == true then gui.EnableScreenClicker(false) end[/CODE] But that did the same thing as the one above. Pointshop's cursor appears and then immediately disappears.
This is what I use, hope it works for you. [CODE] canshow=1 hook.Add("Tick", "KeyDown_Test", function() if input.IsKeyDown(KEY_C) then if canshow==1 then canshow=0 gui.EnableScreenClicker(true) end elseif canshow==0 then canshow=1 gui.EnableScreenClicker(false) end end) [/CODE] If I remember well, [I]canshow[/I] simply tries to prevent the mouse pointer to be enable/disabled every tick. You could remove it and leave it like this [CODE]hook.Add("Tick", "KeyDown_Test", function() if input.IsKeyDown(KEY_C) then gui.EnableScreenClicker(true) else gui.EnableScreenClicker(false) end end)[/CODE] But this version would probably prevent any other functions to enable/disable the mouse pointer.
[QUOTE=Eddlm;47652028]This is what I use, hope it works for you. [CODE] canshow=1 hook.Add("Tick", "KeyDown_Test", function() if input.IsKeyDown(KEY_C) then if canshow==1 then canshow=0 gui.EnableScreenClicker(true) end elseif canshow==0 then canshow=1 gui.EnableScreenClicker(false) end end) [/CODE] If I remember well, [I]canshow[/I] simply tries to prevent the mouse pointer to be enable/disabled every tick. You could remove it and leave it like this [CODE]hook.Add("Tick", "KeyDown_Test", function() if input.IsKeyDown(KEY_C) then gui.EnableScreenClicker(true) else gui.EnableScreenClicker(false) end end)[/CODE] But this version would probably prevent any other functions to enable/disable the mouse pointer.[/QUOTE] Okay, i'll try that tomorrow. Thanks! And by the way, are you using pointshop? And if so, does cursor work properly for you?
[QUOTE=Busan1;47642033]for some reason sound doesn't work in entity for me when spawned on InitPostEntity, it works if I later on respawn it(call same function that spawns it in InitPostEntity), I tried precache sound not sure why it would do anything but it didn't anyway, I do with CreateSound( self, "soundfile", self:EntIndex() ) it seems like it has to be spawned after the player joined for him to hear it, what can I do about that?[/QUOTE] I tried with hooking PlayerInitialSpawn and respawning them, and that works, but doesn't feel like a viable method. I tried overwriting the entity.Sound = CreateSound() aswell in PlayerInitialSpawn, but that didn't work. Any suggestions? :/
How would i change money on a DarkRp hud so it has commas in? For example $500,000,241 instead of $500000241 thanks!
How, if possible, can I use variables in a sendlua command? For example: [CODE]attacker:SendLua( "chat.AddText( Color( 200, 0, 0 ), 'Total: ', Color( 150, 0, 150 )," .. attacker.finalEXP .. " ' EXP')" )[/CODE] The above does not work. Any way to work around it so I can get it working?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/Comma]string.Comma[/url] but I got halfway through writing this before I remembered that so this too [lua]tostring(money):reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse()[/lua] [editline]3rd May 2015[/editline] [QUOTE=Combineguy5;47653616]How, if possible, can I use variables in a sendlua command? For example: [CODE]attacker:SendLua( "chat.AddText( Color( 200, 0, 0 ), 'Total: ', Color( 150, 0, 150 )," .. attacker.finalEXP .. " ' EXP')" )[/CODE] The above does not work. Any way to work around it so I can get it working?[/QUOTE] the problem is that the syntax of what you're sending is wrong, but the bigger problem is sendlua sendlua is never a good option, in your case the best way to do it is with a net message [lua] --serverside util.AddNetworkString("EXPPrint") local function sendEXP(attacker) net.Start("EXPPrint") net.WriteUInt(attacker.finalEXP, 16) --this goes up to 65535 net.Send(attacker) end --clientside net.Receive("EXPPrint") chat.AddText(Color(200, 0, 0), "Total: ", Color(150, 0, 150), net.ReadUInt(16), " EXP") end [/lua]
Alright, thanks! I'll give that a try when I get a chance.
Hello, is anyone able to help me fix a problem that isn't as easy to solve as it seems? lol. Here's a section of my shipments code. Everything else in my shipments file is in the same exact format. [CODE]AddCustomShipment("Colt 1911", "models/weapons/s_dmgf_co1911.mdl", "m9k_colt1911", 3000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("Colt 1911", "models/weapons/s_dmgf_co1911.mdl", "m9k_colt1911", 300, 1, true, 300, true, {TEAM_GUN}) AddCustomShipment("HK 45C", "models/weapons/w_hk45c.mdl", "m9k_hk45", 7000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("HK 45C", "models/weapons/w_hk45c.mdl", "m9k_hk45", 700, 1, true, 700, true, {TEAM_GUN}) AddCustomShipment("Baretta", "models/weapons/w_beretta_m92.mdl", "m9k_m92beretta", 6000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("Baretta", "models/weapons/w_beretta_m92.mdl", "m9k_m92beretta", 600, 1, true, 600, true, {TEAM_GUN}) AddCustomShipment("HK45C", "models/weapons/w_hk45c.mdl", "m9k_hk45", 5000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("HK45C", "models/weapons/w_hk45c.mdl", "m9k_hk45", 500, 1, true, 500, true, {TEAM_GUN}) AddCustomShipment("Sig Sauer", "models/weapons/w_sig_229r.mdl", "m9k_sig_p229r", 6000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("Sig Sauer", "models/weapons/w_sig_229r.mdl", "m9k_sig_p229r", 600, 1, true, 600, true, {TEAM_GUN}) AddCustomShipment("Raging Bull Scoped", "models/weapons/w_raging_bull_scoped.mdl", "m9k_scoped_taurus", 5000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("Raging Bull Scoped", "models/weapons/w_raging_bull_scoped.mdl", "m9k_scoped_taurus", 500, 1, true, 500, true, {TEAM_GUN}) AddCustomShipment("TEC 9", "models/weapons/w_intratec_tec9.mdl", "m9k_tec9", 12000, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("TEC 9", "models/weapons/w_intratec_tec9.mdl", "m9k_tec9", 1200, 1, true, 1200, true, {TEAM_GUN}) AddCustomShipment("Magpul PDR", "models/weapons/w_magpul_pdr.mdl", "m9k_magpulpdr", 8600, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("Magpul PDR", "models/weapons/w_magpul_pdr.mdl", "m9k_magpulpdr", 860, 1, true, 860, true, {TEAM_GUN}) AddCustomShipment("KAC PDW", "models/weapons/w_kac_pdw.mdl", "m9k_kac_pdw", 9500, 10, false, 0, false, {TEAM_GUN}) AddCustomShipment("KAC PDW", "models/weapons/w_kac_pdw.mdl", "m9k_kac_pdw", 950, 1, true, 950, true, {TEAM_GUN})[/CODE] The problem is, everytime I attempt to purchase a shipment as TEAM_GUN, it says "This shipment is unavailable." Thank you for your time.
This is probably really easy, but I just cant seem to find out how, and plus Im super over tired, sorry. im trying to figure out how to change the button color when hovering is detected. I know how to change the color I just need to get the detection part, heres what i got [CODE]if closebutton:IsHovered() == true then closebutton.Paint = function() draw.RoundedBox( 0, 0, 0, 40, 40, Color( 255, 70, 60, 255) ) draw.DrawText("X", "x", 8, -6, Color(255,255,255,255)) end end[/CODE]
[QUOTE=funnygamemake;47654537]This is probably really easy, but I just cant seem to find out how, and plus Im super over tired, sorry. im trying to figure out how to change the button color when hovering is detected. I know how to change the color I just need to get the detection part, heres what i got [CODE]if closebutton:IsHovered() == true then closebutton.Paint = function() draw.RoundedBox( 0, 0, 0, 40, 40, Color( 255, 70, 60, 255) ) draw.DrawText("X", "x", 8, -6, Color(255,255,255,255)) end end[/CODE][/QUOTE] do something like this: [code] local but = vgui.Create("DButton", Panel) but:Dock(TOP) but:SetSize(0, 30) but.In = false but.OnCursorEntered = function() but.In = true end but.OnCursorExited = function() but.In = false end function but:Paint(w,h) draw.RoundedBox(0, 0, 0, w, h, Color(0,0,0)) if but.In then draw.RoundedBox(0, 0, 0, w, h, Color(255, 255, 255)) draw.SimpleText("You hoverd inside me!", "TargetID", 0, 0, Color(255, 255, 255)) end end [/code]
[QUOTE=Pawsative;47654700]do something like this: [code] local but = vgui.Create("DButton", Panel) but:Dock(TOP) but:SetSize(0, 30) but.In = false but.OnCursorEntered = function() but.In = true end but.OnCursorExited = function() but.In = false end function but:Paint(w,h) draw.RoundedBox(0, 0, 0, w, h, Color(0,0,0)) if but.In then draw.RoundedBox(0, 0, 0, w, h, Color(255, 255, 255)) draw.SimpleText("You hoverd inside me!", "TargetID", 0, 0, Color(255, 255, 255)) end end [/code][/QUOTE] Use self not but inside the draw function
How would I overwrite the code that Gmod's bots(the ones added through the console command "bot") have that makes them stop moving when they are shot? I want them to keep moving around even after they're shot. Anyone have a code for this? Note: Probably the best method would be to make a code that makes an individual bot move around randomly, and call it upon the bot being hurt. Or, where is the code for bots in the gmod files? I could simply edit that, if I knew where the .lua file was. However, if they're coded in C++(which is a possibility), I'm out of luck with that strategy.
ip = 123.456.789:27005 how can i remove everything after ':' so it becomes like this: 123.456.789 ive tried string... but i can't seem to get this working :(
[code] ip = "123.456.789:27005" newip = ip:gsub("(.+):%d+", "%1") [/code] There you go.
[QUOTE=Invule;47657704]ip = 123.456.789:27005 how can i remove everything after ':' so it becomes like this: 123.456.789 ive tried string... but i can't seem to get this working :([/QUOTE] [code]str:match( "[^:]*" )[/code] [^:] is a character set that only matches characters that are not a colon. The * means to match that set 0 or more times.
Not exactly a problem, but I got a glua implementation of websockets and I'm not sure what the preferred way to package this up is. Do I use module() and have people require() it, or just have a plain .lua people have to include?
[QUOTE=Willox;47657777][code]str:match( "[^:]*" )[/code] [^:] is a character set that only matches characters that are not a colon. The * means to match that set 0 or more times.[/QUOTE] [QUOTE=Loures;47657776][code] ip = "123.456.789:27005" newip = ip:gsub("(.+):%d+", "%1") [/code] There you go.[/QUOTE] Thanks guys.
[QUOTE=PortalGod;47653630][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/Comma]string.Comma[/url] but I got halfway through writing this before I remembered that so this too [lua]tostring(money):reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse()[/lua][/QUOTE] Well now [url=https://github.com/MattJeanes/AbyssRP/blob/master/gamemodes/abyssrp/gamemode/rp_modules/sh_cash.lua#L15-L38]my solution[/url] looks stupid [lua] function RP:CC(value) -- Cash convert value=tonumber(value) if not value then value=0 end local str,k=string.format("%.2f", tostring(value)) while true do str,k = string.gsub(str, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end if value > 0 and value < 1 then -- Pennies/cent etc if value >= 0.1 then return string.sub(str,-2).."p" else return string.sub(str,-1).."p" end elseif string.find(str,"%.00") then return "£"..string.sub(str,1,-4) else return "£"..str end end [/lua] :v:
What's the best way to add a rotation/zooming feature using mouse input to a DModelPanel? By this, I mean using your mouse wheel to zoom in and out and dragging your mouse while holding down left mouse button to rotate the model.
[url]http://wiki.garrysmod.com/page/Category:DAdjustableModelPanel[/url]
[QUOTE=AK to Spray;47658640]What's the best way to add a rotation/zooming feature using mouse input to a DModelPanel? By this, I mean using your mouse wheel to zoom in and out and dragging your mouse while holding down left mouse button to rotate the model.[/QUOTE] [url]http://wiki.garrysmod.com/page/Category:DAdjustableModelPanel[/url]
Sorry, you need to Log In to post a reply to this thread.