• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=Klaes4Zaugen;51675203]I'm trying to remove something from a database upon removal of a specific entity. This is what I have, but the problem is the server shuts down it also gets removed from database, which I dont want. [code] function ENT:Remove() local query = "DELETE FROM spawnpoints WHERE id = '" .. id .. "'"; sql.Query(query); end [/code][/QUOTE] Not sure how reliable it is, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/ShutDown]GM:ShutDown[/url] might be helpful.
Tried doing a workaround with a variable, but was pretty inconsistent from my experience.
How do I set the color of an imesh without setting the color per-vertex and rebuilding every time?
[img]https://feen.us/d3sbri1xu6.png[/img] How do I get rid of that weird artifacting around my pngs? The original images look much, MUCH better.
[QUOTE=TFA;51677168][img]https://feen.us/d3sbri1xu6.png[/img] How do I get rid of that weird artifacting around my pngs? The original images look much, MUCH better.[/QUOTE] Are their dimensions powers of 2 (32x32, 64x64, etc)? That's what they should be for the best effect.
How would I make a trace that is parallel to the HitPos of another trace? [code]local tr2 = util.QuickTrace(tr.HitPos, tr.HitNormal)[/code] doesn't seem to be working as intended, as [code]print(tostring(tr2.Hit))[/code] prints "false." tr is a valid TraceResult that has Hit and a HitPos in this scenario. EDIT: By looking into the lua file for the Slider STool, I found a way to do this. [code]function TOOL:ParallelTrace(trace) local tr = {} tr.start = trace.HitPos tr.endpos = tr.start + ( trace.HitNormal * 16384 ) tr.filter = {} if ( IsValid( trace.Entity ) ) then if not trace.Entity:IsWorld() then tr.filter[ 1 ] = trace.Entity end end local tr = util.TraceLine( tr ) return tr end [/code] Here is what I'm using, if anyone needs it. If you have a better way of accomplishing this, please tell me. [editline]16th January 2017[/editline] [QUOTE=FrozenH;51644398] Edit: Fixed.[/QUOTE] Please don't be that guy. If you fixed it, tell how. Someone might need it later. Don't let them end up like [url=https://xkcd.com/979/]xkcd 979[/url].
[QUOTE=roastchicken;51675414]Not sure how reliable it is, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/ShutDown]GM:ShutDown[/url] might be helpful.[/QUOTE] is your id a integer? if so remove the '' around it
[QUOTE=Mista_Epic;51678166][code]print(tostring(tr2.Hit))[/code][/QUOTE] (psst: print automatically tostring()s all passed in parameters :science101:)
[QUOTE=swadicalrag;51678228](psst: print automatically tostring()s all passed in parameters :science101:)[/QUOTE] Are you sure? When I was doing it before, it would throw an error telling me it failed trying to concatenate userdata
[QUOTE=Mista_Epic;51678241]Are you sure? When I was doing it before, it would throw an error telling me it failed trying to concatenate userdata[/QUOTE] Yes. That error was because you tried to use the concatenation operator with userdata.
[QUOTE=bigdogmat;51678266]Yes. That error was because you tried to use the concatenation operator with userdata.[/QUOTE] Doesn't that mean it DOESN'T automatically tostring all passed parameters? Because when I'd tostring said userdata, it wouldn't throw that error.
[QUOTE=Mista_Epic;51678267]Doesn't that mean it DOESN'T automatically tostring all passed parameters? Because when I'd tostring said userdata, it wouldn't throw that error.[/QUOTE] I don't think you understand what it does when you do that in a function call, [code] print("something" .. "somethingelse") [/code] Will first concatenate the 2 strings, their return value is what is used as the argument. In your situation, you're attempting to concatenate a userdata and a string, which is not valid. So [code] print(Userdata .. "yes") [/code] will error [code] print(Userdata, "yes") [/code] will not.
[QUOTE=bigdogmat;51678276]I don't think you understand what it does when you do that in a function call, [code] print("something" .. "somethingelse") [/code] Will first concatenate the 2 strings, their return value is what is used as the argument. In your situation, you're attempting to concatenate a userdata and a string, which is not valid. So [code] print(Userdata .. "yes") [/code] will error [code] print(Userdata, "yes") [/code] will not.[/QUOTE] Ah. That makes sense, then! Thanks!
I have a Table within a Table within an Entity (like ENT.Tab1.Tab2). How many different entries can be in the last table? Is there a limit, or can there be infinite different values stored?
There shouldn't be a limit, we don't know the context behind it, so we wouldn't be able to tell you if you're thinking it correctly
Could anyone tell me why this script would be crashing my TTT server during the end round phase? - snip big code block - Any help would be greatly appreciated! :) The crashes don't have any kind of error associated with it. The console sort of just stops printing anything, and all players on the server lose connection. Sort of bums me out since I made this from scratch and it's a pretty cool feature to have. :/
Thats a big code, first at all, try to refactor your code using tables and indexes, dont do that awful conditionals, you will clean to many lines and make your code much better, and then you can worry about why is crashing
[QUOTE=gonzalolog;51678644]Thats a big code, first at all, try to refactor your code using tables and indexes, dont do that awful conditionals, you will clean to many lines and make your code much better, and then you can worry about why is crashing[/QUOTE] You mean the weapons and weapon ids and such, correct? I had thought of using arrays, but I feel as though it's a little too much for me right now. I'll look into it though. Could all these conditionals be the reason for the crashes...? I suppose I'll try to edit out these parts regardless and see if it still crashes. EDIT: Reading up on it a little bit, it's actually a lot easier than I thought! Thanks for the tip, this'll reduce the size immensely! ANOTHA ONE: My updated code: [url]http://pastebin.com/tbFtVSGe[/url] I really don't like bothering people with my problems, but I am really dumbfounded at why this code would be making my server die. :/
[QUOTE=gonzalolog;51678625]There shouldn't be a limit, we don't know the context behind it, so we wouldn't be able to tell you if you're thinking it correctly[/QUOTE] Oh it's really nothing but pure curiosity at the moment. Let's see... Table 1 is currently split into 8 additional Tables. Table 3 also has 8 Tables within it. All of them are tied together elsewhere. Here's an example: [code]OBJECT.TAB1.TAB2 = { [0]= 0, [1]= 40, [2]= 80, [3]= 120, [4]= 160, [5]= 200 } OBJECT.TAB1.TAB3 = { [0]=false, [1]=false, [2]=false, [3]=false, [4]=false, [5]= true }[/code] So how many values can I have between one set of {}'s, assuming I filled it via function instead? [editline]16th January 2017[/editline] I worded that wrong but I think I drew the concept well?
[QUOTE=WalkingZombie;51678749]Oh it's really nothing but pure curiosity at the moment. Let's see... Table 1 is currently split into 8 additional Tables. Table 3 also has 8 Tables within it. All of them are tied together elsewhere. Here's an example: [code]OBJECT.TAB1.TAB2 = { [0]= 0, [1]= 40, [2]= 80, [3]= 120, [4]= 160, [5]= 200 } OBJECT.TAB1.TAB3 = { [0]=false, [1]=false, [2]=false, [3]=false, [4]=false, [5]= true }[/code] So how many values can I have between one set of {}'s, assuming I filled it via function instead? [editline]16th January 2017[/editline] I worded that wrong but I think I drew the concept well?[/QUOTE] I don't think there's any limit except how much memory is available to the Lua interpreter (Well, there may be limit like 2³¹-1 entries but if you're planning to have that many, you're doing something horribly wrong anyway).
[QUOTE=mijyuoon;51679092]I don't think there's any limit except how much memory is available to the Lua interpreter (Well, there may be limit like 2³¹-1 entries but if you're planning to have that many, you're doing something horribly wrong anyway).[/QUOTE] So 2³¹-1 = 2,147,483,647 right? Well if I did use functions I could create something the grows indefinitely and that's only ~2.15 Billion. I use the word 'only' to lead to my next question. What is the absolute highest Float and Integer values that could be stored [U][B]and [/B]networked[/U]?
[QUOTE=WalkingZombie;51681164]What is the absolute highest Float and Integer values that could be stored [U][B]and [/B]networked[/U]?[/QUOTE] Lua numbers are doubles, and you can send values as doubles using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/WriteDouble]net.WriteDouble[/url]. Answering the question of what's the highest is a little misleading however. For integers the highest value is (1.8 × 10 ^ 308), however that doesn't include [i]all[/i] digits below it, for such that it and all digits below said number can be represented it's (2 ^ 53). I may be remembering things wrong but I believe it's around those numbers. For floating point numbers it entirely depends on the amount of precision you need and the magnitude of your number, because of that it's hard to give a straight answer.
[code]util.IsValidModel(string modelName)[/code] seems to only return true if an entity with the model has already been spawned. Is there any simple, fast, and non resource-intensive way around this?
[QUOTE=Rocket;51681912]Try precaching the model first, that might work.[/QUOTE] Doesn't seem to work.
[QUOTE=Klaes4Zaugen;51675493]Tried doing a workaround with a variable, but was pretty inconsistent from my experience.[/QUOTE] hmm, have you tried putting that in ENT:OnRemove instead of ENT:Remove?
Small question about running a gmod server on Linux. I don't know much about Linux, but I know enough. When I looked at the wiki page for setting up a gmod server on Linux it recommend Ubuntu 14.04 32 bit. However, that page is a little old and I was wondering if I should stick with Ubuntu 14.04 32 bit, or switch to 16.04 32/64 bit.
[QUOTE=FrozenH;51684183]Small question about running a gmod server on Linux. I don't know much about Linux, but I know enough. When I looked at the wiki page for setting up a gmod server on Linux it recommend Ubuntu 14.04 32 bit. However, that page is a little old and I was wondering if I should stick with Ubuntu 14.04 32 bit, or switch to 16.04 32/64 bit.[/QUOTE] If you have to ask, Linux is not for you. Having said that, it should be fine as far as dependencies go.
[QUOTE=Revenge282;51684460]If you have to ask, Linux is not for you. Having said that, it should be fine as far as dependencies go.[/QUOTE] Rude. Thanks though, just wondered what version of Ubuntu Server would work best with srcds.
I have some code here to emulate ducktapping from the goldsrc engine which appears to mostly work, except that the player's origin isn't being set as expected. [code] function GM:FinishMove(pl, move) if pl:OnGround() then if move:KeyDown( IN_DUCK ) and not pl:Crouching() then if DUCKTIME < CurTime() then DUCKTIME = CurTime() + (pl:GetDuckSpeed()) end elseif DUCKTIME > CurTime() then print("did trace") local trace = util.TraceHull({ start = move:GetOrigin(), endpos = move:GetOrigin() + Vector(0,0,36), maxs = Vector(16,16,72), mins = Vector(-16,-16,0), filter = pl }) if SERVER then debugoverlay.Box( move:GetOrigin(), Vector(16,16,72), Vector(-16,-16,0), 3, Color( 255, 255, 255, 1 ) ) debugoverlay.Box( trace.HitPos, Vector(16,16,72), Vector(-16,-16,0), 3, Color( 255, 255, 255, 1 ) ) end pl:SetGroundEntity( nil ) pl:RemoveFlags( FL_ONGROUND ) vel = move:GetVelocity() move:SetVelocity(Vector(vel.x, vel.y, 0)) print("set origin to " .. tostring(trace.HitPos)) move:SetOrigin(trace.HitPos) DUCKTIME = CurTime() end end end [/code] Here's what it looks like in a listen server. If I press and release crouch very quickly, my position isn't actually set. It appears to work very briefly on the client, before the server catches up and tells you that you didn't actually move. But if I do it repeatedly by binding duck to mwheeldown, it SOMETIMES works. Why?! [vid]http://puu.sh/tpE3x/3c7793a518.webm[/vid] Any advice?
[QUOTE=Darkomni;51684876]Any advice?[/QUOTE] You should not be changing any move data in FinishMove. Use Move.
Sorry, you need to Log In to post a reply to this thread.