• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=MPan1;49569450]Sorry if this is another stupid question, but what am I meant to use for the start and end values? EDIT: Wait, so the number I'm multiplying RealFrameTime by is meant to be the amount of units it scrolls per second? That explains why it was so slow- but why do I need to use math.Approach then? Is that just meant to make it smoother or something?[/QUOTE] Lerp will make smooth curve-like transitions, as it returns a number in between start and end, while math.Approach will literally just add a number to the start value, meaning not as smooth transitions, but I imagine it would be something you want to use for a constant speed.
So, what am I meant to use for the start and end values? Anything specific? Sorry to nag but I literally have no idea
isn't the lines caused by noclamp? i think that happened to me when i made my slot machine [QUOTE=Willox;49569247]Material returns two arguments and your result is exactly how varargs are supposed to work. You can wrap each Material call in brackets to limit the expression to 1 value.[/QUOTE] when was this added? i don't recall ever seeing this
[QUOTE=Giraffen93;49569619]isn't the lines caused by noclamp? i think that happened to me when i made my slot machine[/QUOTE] Tried taking away noclamp, it still doesn't work :/
[QUOTE=MPan1;49569625]Tried taking away noclamp, it still doesn't work :/[/QUOTE] was it nocull then? or unlitgeneric? shit i know it's the one that makes the uv map not repeat the texture that's one thing you could try though; [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/DrawTexturedRectUV]surface.DrawTexturedRectUV[/url]
Still doesn't seem to work for me, maybe I'll try converting the image to a .vtf Also, Z0mb1n3, what should I use for the start and end arguments of the math.Approach function? You're probably testing stuff or something but I may as well nag you a bit more because I'm an annoying person
[QUOTE=MPan1;49568370]How can I stop GMod from screwing up my images? I have an image that looks like this, right? [IMG]http://i.imgur.com/Fs5MxU8.png[/IMG] It's the dinosaur (blinking) from Google Chrome's offline game thing. I then did [CODE] local dinoblink = Material( 'dinogame/blink.png', 'alphatest noclamp' ) [/CODE] To cache the material for later use, right? Then, I set the material using [URL="https://wiki.garrysmod.com/page/surface/SetMaterial"]surface.SetMaterial[/URL] and set the draw color to be fully white, then I used [URL="https://wiki.garrysmod.com/page/surface/DrawTexturedRect"]surface.DrawTexturedRect[/URL] to draw it, using the exact width and height dimensions of the original image to avoid distortion, and somehow GMod managed to make it look like this: [IMG]http://i.imgur.com/q6l6APO.png[/IMG] The edges have black bits on them and it looks really bad. How can I fix this?[/QUOTE] To avoid such problems, always have your .png textures with sizes of power of two. Otherwise the engine will convert it to power of two automatically when it loads the image the best it can, but there will almost always unwanted results this way. So for your image, i'd recommend making it 128x128.
Yeah, thought that was the problem- when trying to convert it to a .vtf it resized the image and it looked quite a lot like the result I was getting
How can I make the DermaMenu() open at the mouse position if it doesn't accepts SetPos? [editline]20th January 2016[/editline] nvm, just realized I wasn't calling Open() [editline]20th January 2016[/editline] Now its only opening at the Y of the mouse, not the X.... [editline]20th January 2016[/editline] Apparently changing [lua] function PANEL:OnMousePressed(keyCode) if keyCode == MOUSE_RIGHT then [/lua] to [lua] function PANEL:DoRightClick() [/lua] solved the problem...
i've been trying to make certain doors lock by default when my server starts, but everything i've tried to do comes up with nothing useful, as all i've found so far locks EVERY door. i don't know where to start.
[QUOTE=portalcrazy;49569969]i've been trying to make certain doors lock by default when my server starts, but everything i've tried to do comes up with nothing useful, as all i've found so far locks EVERY door. i don't know where to start.[/QUOTE] Try getting the door positions and making an array out of them and then when the server starts up search for entities on a (small) radius around those positions and use :Fire to lock them. (better options might be available but I can't think of anything else)
[QUOTE=GGG KILLER;49569978]Try getting the door positions and making an array out of them and then when the server starts up search for entities on a (small) radius around those positions and use :Fire to lock them. (better options might be available but I can't think of anything else)[/QUOTE] so like ents.FindInSphere? [editline]20th January 2016[/editline] looks like that did it. thanks much, friend!
Shouldn't this work? [URL="http://wiki.garrysmod.com/page/Entity/MapCreationID"]http://wiki.garrysmod.com/page/Entity/MapCreationID[/URL]
[QUOTE=SteppuFIN;49569993]Shouldn't this work? [URL="http://wiki.garrysmod.com/page/Entity/MapCreationID"]http://wiki.garrysmod.com/page/Entity/MapCreationID[/URL][/QUOTE] This sounds like a better solution... it would require looping through all entities using ents.FindAll I didn't even knew that this function existed
[QUOTE=GGG KILLER;49570055]it would require looping through all entities[/QUOTE] Doesn't FindInSphere already do this internally?
[QUOTE=guigui;49570245]Doesn't FindInSphere already do this internally?[/QUOTE] I meant for Entity:MapCreationID, if he stored the value of that function, looping through all entities would get all doors in a single loop, instead of running ents.FindInSphere for each Vector (of course that you could check for Entity:GetPos too in the loop)
I have another one trouble: Nextbot animation freezes when i try to call function with animations from ENT:Think(). How to force nextbot play animations correctly?
How do I find an entity's name if the entity is in the world in game?
[QUOTE=MPan1;49569596]So, what am I meant to use for the start and end values? Anything specific? Sorry to nag but I literally have no idea[/QUOTE] It depends on how you're drawing stuff. If you want for example just an x value for one of the sides then I guess you would use 0 for start and then ScrW() for end. (I don't remember which way the screen coordinates increase, so that could be backwards.)
[QUOTE=GGG KILLER;49570055]This sounds like a better solution... it would require looping through all entities using ents.FindAll I didn't even knew that this function existed[/QUOTE] no. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url]
Anybody know how to fix this? [img]http://images.akamai.steamusercontent.com/ugc/364031285136567371/CB38FFFC6A81B8FC1A343646DA06C352CBDEBD31/[/img] I'm trying to make a custom tooltip for my item icons, but they render in the back instead of the front. This only happens when the base panel that is holding them is draggable, which is what I need it to do. Any help is appreciated as always gentlemen
What can I do to improve on this? I spent lots of time trying to find a better explanation for GetClass() and still I don't understand this witchery.[lua]function weapsOnPlayer(ply) for k, v in pairs(ply:GetWeapons()) do local v = tostring(v) -- Change v into a string local v = string.sub(v, string.find(v, "[%]][%[].+")) -- Get rid of irrelevant data local v = string.sub(v,3,-2) if v == ply:GetActiveWeapon():GetClass() then print(v .. " (Currently equipped)") else print(v) end end end[/lua]
[QUOTE=jrj996;49571385]Anybody know how to fix this? [img]http://images.akamai.steamusercontent.com/ugc/364031285136567371/CB38FFFC6A81B8FC1A343646DA06C352CBDEBD31/[/img] I'm trying to make a custom tooltip for my item icons, but they render in the back instead of the front. This only happens when the base panel that is holding them is draggable, which is what I need it to do. Any help is appreciated as always gentlemen[/QUOTE] Have you tried SetZPos? [editline]20th January 2016[/editline] [QUOTE=Nipah;49571682]What can I do to improve on this? I spent lots of time trying to find a better explanation for GetClass() and still I don't understand this witchery.[lua]function weapsOnPlayer(ply) for k, v in pairs(ply:GetWeapons()) do local v = tostring(v) -- Change v into a string local v = string.sub(v, string.find(v, "[%]][%[].+")) -- Get rid of irrelevant data local v = string.sub(v,3,-2) if v == ply:GetActiveWeapon():GetClass() then print(v .. " (Currently equipped)") else print(v) end end end[/lua][/QUOTE] Dont use local for all the v's, just do it for the first one. GetClass returns the weapons "unique id" wich tells wich weapon is that and as you are trying to check if a subbed class (v as you are looping through all the weapon entities from the player) youre changing them to a string wich gives you the classes. Instead of doing all those subs and converting the entity to a string try to set the v variable to v:GetClass() and comparing it to the equipped weapons class.
Really confused right now, attempting to save data using sql for the first time and I'm running into some problems. [lua] function CheckIfHasLicense(ply) local id64 = ply:SteamID64() local dLicense = sql.QueryValue("SELECT dlicense FROM myplayerdata WHERE steamid64 = '" .. id64 .. "'") -- dlicense is equal to 1 in the db print(dLicense) -- prints 1 if dLicense == 1 then -- this is never called even though dLicense is 1 return true end return false -- gets called end concommand.Add("abchh", function(ply) -- for testing purposes local lolkek = CheckIfHasLicense(ply) print(lolkek) -- prints false end) [/lua] It always prints false, even when the variable prints out as 1. Edit: Fixed, it was returning as a string for some reason.
Im trying to make a darkrp server but i don't know how too i have watch tutorials but they never work so i asked someone to help me do it and they told me to download sublime 2 and type this exact code they said it will open a batch file and then all i need to do is run gmod. I done the code but nothing happened did i do something wrong? [IMG]https://i.gyazo.com/588b72bade530eff737fac225e2ffbf8.png[/IMG]
[QUOTE=ShaggySmalls;49572599]-snaz-[/QUOTE] Lmao that's a good troll. Put the gamemode into the gamemodes folder and add -gamemode darkrp To your game's start up.
[QUOTE=YourStalker;49572653]Lmao that's a good troll. Put the gamemode into the gamemodes folder and add -gamemode darkrp To your game's start up.[/QUOTE] How do i get the DarkRP gamemode?
Hi, On fretta based gamemodes you can do CLASS.TeammateNoCollide = true for people from the same team to be no colliding. However I'd like them to be no colliding with the enemies too, is there some simple way to do that ? EDIT : Found that I think it'll do [code] function PreventPlayerCollision(ply1, ply2) if ply1:IsPlayer() and ply2:IsPlayer() then return false end end hook.Add("ShouldCollide", "preventplayerscollision", PreventPlayerCollision) [/code] *Remider* : Search harder next time Re-EDIT : Tested Working, need to have pl:SetCustomCollisionCheck(true) on the spawn function of one of the player classes.
[QUOTE=roastchicken;49571069]It depends on how you're drawing stuff. If you want for example just an x value for one of the sides then I guess you would use 0 for start and then ScrW() for end. (I don't remember which way the screen coordinates increase, so that could be backwards.)[/QUOTE] If I use 0 and ScrW() and math.Approach works how I think it does, won't it just do nothing unless it reaches 0 or ScrW()? What's the point of it? I want the movement to be smooth, not just do some odd thing once it reaches 0 or ScrW()...
[code]value = math.Approach( value or initial_value, target_value, 1 / target_time * delta * speed )[/code] So, for example, to have your health bar animate, you'd do something like this: [code] percent = math.Approach( percent or 0, pl:Health( ) / pl:MaxHealth( ), RealFrameTime( ) ) surface.SetDrawColor( 255 * percent, 0, 0, 255 ) surface.DrawRect( x, y, w * percent, h ) [/code] This would cause percent to generally be between 0 and 1 ( although negative health and health over their max would cause it to leave that range, so clamping may be desired ), and it would linearly approach the target value by your defined delta. Since we're working on a scale of 0 to 1 and RealFrameTime is scaled to a second, it should never take more than a single second for your current value to reach your target value.
Sorry, you need to Log In to post a reply to this thread.