• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=DarthTealc;48201473]Is it possible to use a png file as the $basetexture value in a material, instead of using a vtf? I've got an existing material in Lua, I want to replace the $basetexture value, but it doesn't seem to work when I set that to a png.[/QUOTE] LuaMaterial:SetTexture( "$basetexture", Material("png"):GetTexture("$basetexture"))?
[QUOTE=NiandraLades;48193597]I'm displaying text from a table onto a derma menu, every 45 characters into a string I want to insert a \n, so it looks nice and doesn't get cut off - how do I do this automatically without having to have \n in my table of strings? I swear there's a string.function for inserting characters at a specific place but the name escapes me[/QUOTE] use string.left, string.right, string.len
I'm trying to read a config file saved as a json table, however when I use this: (after checking that the file exists) [CODE]local configfile = file.Read("zeus/config.txt", "DATA") print("config-file: " .. configfile) local configtable = util.JSONToTable(configfile) PrintTable(configtable)[/CODE] The first print of the configfile reveals the file's contents. However, PrintTable returns that it expects a table but got nil. Anyone know if this is a common issue? It should return a table properly.
Creating entity crashes srcds, prior to crash it tries to initialize itself over and over [code] function ENT:Initialize() self:SetModel("models/XQM/Rails/gumball_1.mdl") local a = math.random(1,2) if a == 1 then self:SetMaterial("models/stuff1") else self:SetMaterial("models/stuff2") end a = nil self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phy = self:GetPhysicsObject() if phy:IsValid() then phy:Wake() end self:Spawn() self:Activate() end [/code]
[QUOTE=FireArrow133;48203439]Creating entity crashes srcds, prior to crash it tries to initialize itself over and over [code] function ENT:Initialize() self:SetModel("models/XQM/Rails/gumball_1.mdl") local a = math.random(1,2) if a == 1 then self:SetMaterial("models/stuff1") else self:SetMaterial("models/stuff2") end a = nil self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phy = self:GetPhysicsObject() if phy:IsValid() then phy:Wake() end self:Spawn() self:Activate() end [/code][/QUOTE] Entity:Spawn() initializes the entity afaik, so it's crashing due to an infinite loop.
Does anyone know how I can make a line with a gradient effect? I've tried messing around with surface.GetTextureID( "gui/gradient.vtf" ) and then using surface.DrawTexturedRect() but its only drawing to the right, the effect i want is where the middle has 255(Alpha) and then it goes left & right with less and less transparency.
[QUOTE=James xX;48203582]Entity:Spawn() initializes the entity afaik, so it's crashing due to an infinite loop.[/QUOTE] Jesus Christ, I'm stupid. Thanks.
[DEL]Okay, another question, what entity hook fires when collision between the entity and the world? ENT:Touch() only works for actual entities. [/DEL] [DEL]Nevermind, ENT:PhysicsCollide(CollisionData,PhysObj) is a thing. I need to utilize Google more.[/DEL] Fucking hell, what hook runs when it collides with anything, including the world?
I just started with the net library, but I'm gaining an error. I don't know how to fix it, so mabe you could help me. Here's the error: [QUOTE][ERROR] addons/simple_betting_by_p4sca1/lua/autorun/server/sv_bettingsystem.lua:181: bad argument #2 to 'WriteInt' (number expected, got no value) 1. WriteInt - [C]:-1 2. fn - addons/simple_betting_by_p4sca1/lua/autorun/server/sv_bettingsystem.lua:181 3. Call - addons/ulib/lua/ulib/shared/hook.lua:179 4. old_BeginRound - gamemodes/terrortown/gamemode/init.lua:693 5. unknown - addons/specdm/lua/sv_specdm_overrides.lua:205[/QUOTE] And here's the function: [QUOTE] local currentPool = GetPool() net.Start( "BSCN_NotEnoughBets" ) net.WriteInt( currentPool ) net.Send( v )[/QUOTE] The net is pooled with util.AddNetworkString serverside. The function is called serverside. The function GetPool() is working and is returning a number. Here's the GetPool function: [QUOTE]local function GetPool() local data = sql.Query( "SELECT pool FROM simple_betting" ) local pool = data[1].pool return tonumber( pool ) end[/QUOTE] Can anybody help me? [editline]14th July 2015[/editline] Oh the function is called serverside and in the same file.
Your [URL="http://wiki.garrysmod.com/page/net/WriteInt"]net.WriteInt[/URL] has an additional required variable you haven't accounted for.
I think I'm a little fag, I need to add the bitCount right? Sorry for spamming :/
Yeah, it's the bitcount. And no, you're not spamming.
Why can't I set every bitCount to 32?
[QUOTE=P4sca1;48206275]Why can't I set every bitCount to 32?[/QUOTE] Purely because of how srcds was coded. I think it's 32-bit only IIRC.
I dont understand, what would happen if I just set every bitCount to 32? And what would happen if the integer is higher then the bitcount allow?
Well, 31-bit is actually the maximum, with the highest value being 2,147,483,647, because this number is the biggest a 32-bit OS can reach. So 32-bit I'm not sure what would happen if you set it to that, and I don't know what would happen if I set it higher than the bitcount allows.
Hmm okay, thanks for your help! :) I think if you set the bitCount to 32 it is using 31bits right? I remember that I've read something like that on the wiki
Actually, set it to 32bit, my bad.
Should I do it like that:? [QUOTE]net.ReadInt( 2 )[/QUOTE] Because in the wiki ([url]http://wiki.garrysmod.com/page/net/ReadInt[/url]) it says "should be a power of 2". Or should this be the same number like net.WriteInt? When I try with 32 this error occurs: [QUOTE][ERROR] addons/simple_betting_by_p4sca1/lua/autorun/client/cl_net.lua:109: bad argument #1 to 'ReadInt' (number expected, got no value) 1. ReadInt - [C]:-1 2. func - addons/simple_betting_by_p4sca1/lua/autorun/client/cl_net.lua:109 3. unknown - lua/includes/extensions/net.lua:32 [/QUOTE] I want to ask here, before trying again with a value of 2. [editline]14th July 2015[/editline] I dont understand it, the same error occurs with bitcount set to 2. It seems like he gets no value from the net.ReadInt( 2 ). But why, can anybody help me? Serverside: [QUOTE] local BetAmount = tonumber( args[2] ) local BetAmount = tonumber( args[2] ) --just some validity checks, they work fine, so BetAmount need to have a value I guess... if BetAmount > BS_MaxBetAmount or BetAmount < BS_MinBetAmount then return end if BetAmount > ply.PS2_Wallet.points then return end net.Start( "BSCN_BetPlaced" ) net.WriteInt( BetAmount, 32 ) net.WriteInt( BetTeam, 2 ) net.Send( ply )[/QUOTE] Clientside: [QUOTE]net.Receive( "BSCN_BetPlaced", function( len ) local BetAmount = net.ReadInt( 2 ) local BetTeam = net.ReadInt( 2 ) end )[/QUOTE]
[QUOTE=P4sca1;48206531]-snip-[/QUOTE] The first argument to net.ReadInt should be the same as the second argument you put for net.WriteInt Use this to determine what you should use: [url]http://www.tsm-resources.com/alists/pow2.html[/url]
Yeah got it to work now! Really sorry for spamming :/
This prints fine [code] hook.Add("PlayerFootstep", "SK_PF", function(ply) if ply.HasSilentKiller then ply:ChatPrint("a") end end) [/code] However, this does not seem to mute my footsteps, any idea why? [code] hook.Add("PlayerFootstep", "SK_PF", function(ply) if ply.HasSilentKiller then return false end end) [/code]
[QUOTE=NiandraLades;48220206]This prints fine [code] hook.Add("PlayerFootstep", "SK_PF", function(ply) if ply.HasSilentKiller then ply:ChatPrint("a") end end) [/code] However, this does not seem to mute my footsteps, any idea why? [code] hook.Add("PlayerFootstep", "SK_PF", function(ply) if ply.HasSilentKiller then return false end end) [/code][/QUOTE] return true not false to mute. (GMod API logic)
[QUOTE=NiandraLades;48220206]This prints fine [/QUOTE] boolean: Mute step sound You need to return true :P Edit Damn ninja-ed
oh my fucking christ [editline]16th July 2015[/editline] Okay, it works if I remove the ply.HasSilentKiller check, but that prints true within the hook so I'm kind of confused as to what the issue is
[QUOTE=NiandraLades;48220374]oh my fucking christ [editline]16th July 2015[/editline] Wait no, I can still hear it with return true, although it works fine if I remove the check so the problem may be something else I've done actually, ty[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerFootstep]GM/PlayerFootstep[/url] [QUOTE]Called whenever a player steps. Return true to mute the normal sound.[/QUOTE] Maybe call 1-800-FIX-VINH?
Oh my god, what have I done [code] hook.Add("PlayerFootstep", "SK_PF", function(ply) if ply.HasSilentKiller then ply:ChatPrint("A") else ply:ChatPrint("b") end end) [/code] [img]http://i.imgur.com/oeCMajO.png[/img]
-holy snip-
I'm a fucking idiot and was setting it serverside only, sorry!!
*snip* Sorry, this post was horrible to read, I had to redo it entirely.
Sorry, you need to Log In to post a reply to this thread.