• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=sharknado;52148734]This may be stupid, but what's the situation on custom shaders? I have an already compiled shader, but am unsure if Garry's Mod will register it.[/QUOTE] This, please, make custom shaders easier to implement! Every person who spent the time to figure it out has never told anyone how they did it. Quite annoying.
[QUOTE=Ryanrc;52148304]This should work [CODE]function CanPlayerSpawnWith(ply) if not ply:IsValid() then return end if ply:GetDonationAmount() >= 10 or ply:IsAdmin() then return true else return false end end[/CODE][/QUOTE] Didn't work, thank you though. Honestly it might be hard coded into another part of the code: I just don't know what I'm looking for, which is annoying. I really appreciate your responses though!
[QUOTE=dx9er;52151817]Are you sure that you're using this somewhere in the code? Functions just don't work alone, they need to be used in an event such as when a hook is ran.[/QUOTE] I'm fairly certain, I've recently changed it to allow admins to spawn with weapons as you can see in the code, so I'm really not sure what the issue is. I even tried setting a 'User' and 'Member' group in garrysmod/settings/users.txt So stumped here.
[QUOTE=NeatNit;52139980]I'm guessing that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/CreateRagdoll]Player:CreateRagdoll[/url] is a great starting point.[/QUOTE] I feel dumb... :P Thanks Nit!
[QUOTE=sharknado;52148734]This may be stupid, but what's the situation on custom shaders? I have an already compiled shader, but am unsure if Garry's Mod will register it.[/QUOTE] Not possible, not sure why, it would be really nice to implement new shaders in the game
How would one go about making the player spectate (freeroam)? I've tried both [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawnAsSpectator]GM:PlayerSpawnAsSpectator[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Spectate]Player:Spectate[/url], but none seem to do the trick. Is there something I'm missing?
[QUOTE=Fillipuster;52153778]How would one go about making the player spectate (freeroam)? I've tried both [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/GM/PlayerSpawnAsSpectator"]GM:PlayerSpawnAsSpectator[/URL] and [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Player/Spectate"]Player:Spectate[/URL], but none seem to do the trick. Is there something I'm missing?[/QUOTE] Just a guess. How about this method [URL="http://wiki.garrysmod.com/page/Player/SetObserverMode"]Player:SetObserverMode[/URL] ?
[QUOTE=victi;52153875]Just a guess. How about this method [URL="http://wiki.garrysmod.com/page/Player/SetObserverMode"]Player:SetObserverMode[/URL] ?[/QUOTE] Tested. No luck :/ [editline]26th April 2017[/editline] Okay, it seems that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Spectate]Player:Spectate[/url] does work. However, it doesn't work when I try to use it in the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url] or the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM:PlayerInitialSpawn[/url] hooks. Any ideas?
[QUOTE=Fillipuster;52153911]Tested. No luck :/ [editline]26th April 2017[/editline] Okay, it seems that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Spectate]Player:Spectate[/url] does work. However, it doesn't work when I try to use it in the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url] or the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM:PlayerInitialSpawn[/url] hooks. Any ideas?[/QUOTE] Likely because the gamemode you're running unspectates the player when they spawn. Try to delay the action after they spawn with a timer.
[QUOTE=Derek_SM;52155336]Likely because the gamemode you're running unspectates the player when they spawn. Try to delay the action after they spawn with a timer.[/QUOTE] That did the trick. Thanks Derek! :D [B]Another thing:[/B] How would one go about animating a surface element (in may case; some text) from one location to another on the screen? I've tried doing a cosine lerp of the X and Y locations, but for reason, that doesn't seem to work... Here's what I have: [lua] local amt = net.ReadFloat() local startX, startY = ScrW() / 2, ScrH() / 2 local endX, endY = 100, ScrH() - 100 local startTime = CurTime() hook.Add( "HUDPaint", "MoneyAnim:HUDPaint", function() local sw, sh = ScrW(), ScrH() local relX = Lerp( (CurTime() - startTime) / 5, startX, -math.cos( math.pi * endX ) / 2 + 0.5 ) local relY = Lerp( (CurTime() - startTime) / 5, startY, -math.cos( math.pi * endY ) / 2 + 0.5 ) draw.SimpleTextOutlined( "$" .. amt, "fp_header3", relX, relY, col, 1, 1, 1, Color( 0, 0, 0, 100 ) ) end ) timer.Simple( 3, function() hook.Remove( "HUDPaint", "MoneyAnim:HUDPaint") end ) [/lua] However, the code above simply animates the text from the center of the screen to the top left. I'm not a math expert, so I cannot seem to diagnose the problem myself :/ Any help would be much appreciated :D
I am having an issue with my hitman job and demotion on death. I have not changed their code at all but in the past week they have stopped working. The demote on death is a function, and I already have tried a hook. Also, the hitmans bug is when he kills the target or the target dies it won't complete/abort the hit. The only was for it to be aborted is if the target leaves.
[QUOTE=Fillipuster;52157701]That did the trick. Thanks Derek! :D [B]Another thing:[/B] How would one go about animating a surface element (in may case; some text) from one location to another on the screen? I've tried doing a cosine lerp of the X and Y locations, but for reason, that doesn't seem to work... Here's what I have: [lua] local amt = net.ReadFloat() local startX, startY = ScrW() / 2, ScrH() / 2 local endX, endY = 100, ScrH() - 100 local startTime = CurTime() hook.Add( "HUDPaint", "MoneyAnim:HUDPaint", function() local sw, sh = ScrW(), ScrH() local relX = Lerp( (CurTime() - startTime) / 5, startX, -math.cos( math.pi * endX ) / 2 + 0.5 ) local relY = Lerp( (CurTime() - startTime) / 5, startY, -math.cos( math.pi * endY ) / 2 + 0.5 ) draw.SimpleTextOutlined( "$" .. amt, "fp_header3", relX, relY, col, 1, 1, 1, Color( 0, 0, 0, 100 ) ) end ) timer.Simple( 3, function() hook.Remove( "HUDPaint", "MoneyAnim:HUDPaint") end ) [/lua] However, the code above simply animates the text from the center of the screen to the top left. I'm not a math expert, so I cannot seem to diagnose the problem myself :/ Any help would be much appreciated :D[/QUOTE] You'll want to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]. Make sure it's called [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=https://wiki.garrysmod.com/page/Category:3D_Rendering_Hooks]in a 3D hook.[/url] [editline]27th April 2017[/editline] [QUOTE=FastRP_BOB;52157956]I am having an issue with my hitman job and demotion on death. I have not changed their code at all but in the past week they have stopped working. The demote on death is a function, and I already have tried a hook. Also, the hitmans bug is when he kills the target or the target dies it won't complete/abort the hit. The only was for it to be aborted is if the target leaves.[/QUOTE] Would you care to share some code?
[QUOTE=Derek_SM;52158351]You'll want to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]. Make sure it's called [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=https://wiki.garrysmod.com/page/Category:3D_Rendering_Hooks]in a 3D hook.[/url] [editline]27th April 2017[/editline] Would you care to share some code?[/QUOTE] This is not to be drawn on an entity as a screen or alike. This is part of a HUD.
I wanna get Derma into 2D3D render context. Is there an easy way?
[QUOTE=SirRanjid;52160766]I wanna get Derma into 2D3D render context. Is there an easy way?[/QUOTE] [url]https://github.com/HandsomeMatt/3d2d-vgui[/url]
I'm having a problem getting data form a nested function which isn't a conventional function, I put together an example of my problem [CODE]local loadTableQuery = db:prepare("SELECT * FROM exampleTable") -- Gets the data from the table function loadTable() function loadTableQuery:onSuccess() local logs = loadTableQuery:getData() return logs -- where does it return it to? end loadTableQuery:start() return ??? -- how do I return what's inside the nested function when I can't call it after its got the data? *to my knowledge I can't call it after its got the data end function mainFunction(_, ply) local sqlTable = loadTable() -- gets the table net.Start("examplenetmessage") net.WriteTable(sqlTable) net.Send(ply) end[/CODE] The reason for the loadTable function is because if I want SQL is enabled it will do the SQL function, if it wasn't enabled it would do another function which contains a SQLITE query. Really ran a dead end here - any tips would be appreciated Thanks in advance
[QUOTE=Bings;52164439]I'm having a problem getting data form a nested function which isn't a conventional function, I put together an example of my problem :snip: The reason for the loadTable function is because if I want SQL is enabled it will do the SQL function, if it wasn't enabled it would do another function which contains a SQLITE query. Really ran a dead end here - any tips would be appreciated Thanks in advance[/QUOTE] You can't directly return like that, you'll have to use a callback function. E.g. network that table in the `onSuccess` function.
[code]local Menu = {} Menu.Hold = 0 Menu.Open = function() local main = vgui.Create("DFrame") Menu.Frame = main end Menu.Toggle = function() if (input.IsButtonDown(Keys["Menu"])) then if !(Menu.KeyDown) then if (Menu.Frame) then Menu.Frame:SetVisible(!Menu.Frame:IsVisible()) else Menu.Open() end end if (Menu.Hold > 30) then Menu.Frame:ShowCloseButton(false) else Menu.Frame:ShowCloseButton(true) end Menu.Hold = Menu.Hold + 1 else if (Menu.Hold > 30) then Menu.Frame:SetVisible(false) end Menu.Hold = 0 end Menu.KeyDown = input.IsButtonDown(Keys["Menu"]) end hook.Add("Think", "Menu Toggle", Menu.Toggle) [/code] I feel as though there's a better way of doing this but everytime I try to think about it my mind goes blank. Can anybody suggest improvements?
[QUOTE=txike;52165190][code]local Menu = {} Menu.Hold = 0 Menu.Open = function() local main = vgui.Create("DFrame") Menu.Frame = main end Menu.Toggle = function() if (input.IsButtonDown(Keys["Menu"])) then if !(Menu.KeyDown) then if (Menu.Frame) then Menu.Frame:SetVisible(!Menu.Frame:IsVisible()) else Menu.Open() end end if (Menu.Hold > 30) then Menu.Frame:ShowCloseButton(false) else Menu.Frame:ShowCloseButton(true) end Menu.Hold = Menu.Hold + 1 else if (Menu.Hold > 30) then Menu.Frame:SetVisible(false) end Menu.Hold = 0 end Menu.KeyDown = input.IsButtonDown(Keys["Menu"]) end hook.Add("Think", "Menu Toggle", Menu.Toggle) [/code] I feel as though there's a better way of doing this but everytime I try to think about it my mind goes blank. Can anybody suggest improvements?[/QUOTE] Unsure if there's a better way, but in your example you're running [B]input.IsButtonDown[/B] twice for no particular reason
[QUOTE=JasonMan34;52165375]Unsure if there's a better way, but in your example you're running [B]input.IsButtonDown[/B] twice for no particular reason[/QUOTE] There is actually a rather big reason for doing that. If I wasn't doing it then it wouldn't toggle at all.
[QUOTE=txike;52165488]There is actually a rather big reason for doing that. If I wasn't doing it then it wouldn't toggle at all.[/QUOTE] [lua]local Menu = {} Menu.Hold = 0 Menu.Open = function() local main = vgui.Create("DFrame") Menu.Frame = main end Menu.Toggle = function() if (input.IsButtonDown(Keys["Menu"])) then if !(Menu.KeyDown) then if (Menu.Frame) then Menu.Frame:SetVisible(!Menu.Frame:IsVisible()) else Menu.Open() end end if (Menu.Hold > 30) then Menu.Frame:ShowCloseButton(false) else Menu.Frame:ShowCloseButton(true) end Menu.Hold = Menu.Hold + 1 Menu.KeyDown = true --Add this else if (Menu.Hold > 30) then Menu.Frame:SetVisible(false) end Menu.Hold = 0 Menu.KeyDown = false --And this end --And get rid of this: Menu.KeyDown = input.IsButtonDown(Keys["Menu"]) end hook.Add("Think", "Menu Toggle", Menu.Toggle)[/lua]
[QUOTE=JasonMan34;52165510]snip[/QUOTE] I didn't think of it like that, cheers.
[QUOTE=bigdogmat;52164473]You can't directly return like that, you'll have to use a callback function. E.g. network that table in the `onSuccess` function.[/QUOTE] I've gained a good understand of callbacks now (and thanks for that as its a new trick for me!) but i'm still not sure no how it will help me solve the issue i'm having as i'm still left with the problem of returning the data after the query has finished, not before - I also don't quite get what you mean by networking the table in the onSuccess function? Any extra tips on that would be great :) Thanks in advance and also thanks for the original response
[QUOTE=Bings;52165945]I've gained a good understand of callbacks now (and thanks for that as its a new trick for me!) but i'm still not sure no how it will help me solve the issue i'm having as i'm still left with the problem of returning the data after the query has finished, not before - I also don't quite get what you mean by networking the table in the onSuccess function? Any extra tips on that would be great :) Thanks in advance and also thanks for the original response[/QUOTE] You can't directly return the data from that function, that is because MySQLOO functions are asynchronous. They don't run inline with your code. To fix this problem, you can use loadTableQuery:wait(), which will halt the entire server waiting for a response from the MySQL server. Another option is putting the code that networks the table, inside of the `onSuccess` function you have. I meant that literally, i.e. [code] function loadTableQuery:onSuccess(data) net.Start("examplenetmessage") net.WriteTable(data) net.Send(ply) end [/code] [editline]29th April 2017[/editline] Of course in some cases what I did above may not work out as well, or in many cases will result in uglier code. In those cases you have a few options. You can use callbacks of your own when passing to the `loadTable` function. Another option is using a coroutine system, though currently they don't work when used with MySQLOO.
[QUOTE=bigdogmat;52166048] To fix this problem, you can use loadTableQuery:wait(), which will halt the entire server waiting for a response from the MySQL server.[/QUOTE] You shouldn't use wait under just about any circumstances. Locking up the server in this way will prevent any logic from running, and will be an extremely bad experience for your players.
[QUOTE=EdwardRich;52166361]You shouldn't use wait under just about any circumstances. Locking up the server in this way will prevent any logic from running, and will be an extremely bad experience for your players.[/QUOTE] As for why I said [quote] which will halt the entire server waiting for a response from the MySQL server. [/quote] And gave 2 other solutions. Only time I'd be okay with wait being used is if you're loading essential data on server start up.
Is there any good way to animate a ragdoll with a player animation without setting their physbone position every frame or doing some other dodgy laggy thing?
Is there a global table where fonts created with surface.CreateFont are stored? Similar to how require adds the module name to _MODULES.
[QUOTE=txike;52168805]Is there a global table where fonts created with surface.CreateFont are stored? Similar to how require adds the module name to _MODULES.[/QUOTE] No, but you can override it early and make your own.
[QUOTE=code_gs;52168963]No, but you can override it early and make your own.[/QUOTE] I was hoping I wouldn't need to detour it.
Sorry, you need to Log In to post a reply to this thread.