• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=ROFLBURGER;45574820]I don't know how to do this though. I tried the below but it seems like it doesn't work [code]hud stuffs [/code] I mean it shows up and everything but the shapes are all squares and it conflicts with another mod. Even without that silly for i=300 line it has the same result.[/QUOTE] [lua] local mat = Material"BurgerHUD/WhiteSquare.png" -- later in the code surface.SetMaterial( mat ) [/lua] And you don't need to set the same font every time
[QUOTE=Robotboy655;45575188][/QUOTE] Updated.
[QUOTE=Instant Mix;45575282]Updated.[/QUOTE] Remove the [code]self.FireMode = self.Firemode or 1[/code] in the if ( SERVER ) then end and replace the first one with [code]self.FireMode = 1[/code] Make sure your SWEP:Initialize is called on client. OR you can add it like this: [code] function SWEP:SecondaryAttack() if !SERVER then return end self.FireMode = self.FireMode or 1 if self.FireMode == 4 then ... [/code]
[QUOTE=Robotboy655;45575316]Remove the [code]self.FireMode = self.Firemode or 1[/code] in the if ( SERVER ) then end and replace the first one with [code]self.FireMode = 1[/code] Make sure your SWEP:Initialize is called on client. OR you can add it like this: [code] function SWEP:SecondaryAttack() if !SERVER then return end self.FireMode = self.FireMode or 1 if self.FireMode == 4 then ... [/code][/QUOTE] Still coughing up errors. No idea what's causing this. A portion of SWEP:Initialize is called on the client ( hence If CLIENT then ) - should I add it in there instead?
Anyone got a good tutorial on STOOLS? The source code is a bit weird, I can't work out how to set the name on the HUD etc, the source code just does some weird # shit. The tutorial on the old wiki is outdated, I can't figure out how to make variables change when a object is changed in the BuildCPanel function.
[QUOTE=AnonTakesOver;45576068]Anyone got a good tutorial on STOOLS? The source code is a bit weird, I can't work out how to set the name on the HUD etc, the source code just does some weird # shit. The tutorial on the old wiki is outdated, I can't figure out how to make variables change when a object is changed in the BuildCPanel function.[/QUOTE] Take a look at sources of my workshop Easy* tools. ( I recommend the bodygroup one. ) It shall give you an idea of what you gotta do.
withdrawn
Minor question: Does anyone here know if it's possible to use CS:GO viewmodels in Garry's Mod?
[QUOTE=sniperlover;45576449]Minor question: Does anyone here know if it's possible to use CS:GO viewmodels in Garry's Mod?[/QUOTE] The answer is yes
Hi There! I have been having some troubles adding this code to my server. Essentially want I want to do is make a ulx command that only admins can use to give a certain player a certain ammount of points. Also to prevent admin abuse, I added code to prevent the use of negative points. Thats how they cant remove all the points of a player thus making them mad. [LUA] function ulx.givepoints( calling_ply, target_plys, should_silent, points ) if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else for i=1, #target_plys do target_plys[ i ]:PS_GivePoints(points) end if points < 0 then ply:ChatPrint("You can't give a negative amount of points") return end ulx.fancyLogAdmin( calling_ply, true, "#A gave #T #i pointshop credits", target_plys, amount ) end end local givepoints = ulx.command( CATEGORY_NAME, "ulx givepoints", ulx.credits, "!givepoints") givepoints:addParam{ type=ULib.cmds.PlayersArg } givepoints:addParam{ type=ULib.cmds.NumArg, hint="Pointshop Points", ULib.cmds.round } givepoints:defaultAccess( ULib.ACCESS_SUPERADMIN ) givepoints:setOpposite( "ulx silent givepoints", {_, _, _, true}, "!sgivepoints", true ) givepoints:help( "Gives the <target(s)> Pointshop Points." ) [/LUA] [del]I have done other code edits regarding upgradeable pointshop items and that resulted in the destruction of the server with blank grey player models, all pointshop items reset, all items gone, and UTIME reset.[/del] No Worries! Go to the bottom for updates on this. I dont want to do that again because right now thats very risky. I am not making any changes to pointshop now. This isnt a change to pointshop, but does affect a pointshop variable called self.PS_GivePoints also dont worry as this is Undefined_'s pointshop so its not a coderhire plugin or what of the sort. Here is what the pointshop uses PS_Givepoints() for: [LUA] function Player:PS_GivePoints(points) self.PS_Points = self.PS_Points + points self:PS_SendPoints() end function Player:PS_TakePoints(points) self.PS_Points = self.PS_Points - points >= 0 and self.PS_Points - points or 0 self:PS_SendPoints() end function Player:PS_SetPoints(points) self.PS_Points = points self:PS_SendPoints() end function Player:PS_GetPoints() return self.PS_Points and self.PS_Points or 0 end function Player:PS_HasPoints(points) return self.PS_Points >= points end [/LUA] [del]If I do have any errors in my current code,[/del] Actually, I do have errors. Please if you find another, tell me where so I can fix it. [del]I might ask for a voluntary tester because it would be very bad to break the server again.[/del] (<------ Not needed anymore) Thanks for all the help in advanced! [B][I]EDIT: NEW RESULTS FROM TESTING[/I][/B] So far I see that now once adding this to my server. Somehow ulx is 100% disabled both from clientside and serverside. That includes rcon. Fortunately U-Time and pointshop are 100% preserved. XGUI is an unknown command just like every ulx command for some reason and, also rcon displays invalid command. So I can't do anything at all because ulx IS DEAD. DEAD TO THE POINT WHERE IT WONT MOUNT. Biggest thing that makes my mind think is that part with the [LUA] for i=1, #target_plys do target_plys[ i ]:PS_GivePoints(points) [/LUA] is the breaking point. I need help on syntax with this phrase of code to the rest.
Look at your logs. ULX has a really fucking obnoxious boot message filled with tons of slashes and stuff, you can't miss it. Your syntax looks fine.
This may be hard to explain, but what I am looking to do is check the results from a mysql query (a table) and check for a steam ID, which I have done with help from people here, but my next problem is that I want the player's Steam ID to be entered into the table if it can not be found, this is where my problem lies. My problem is that when it checks for Steam ID, it goes through every record in that column, which is good, I have made it so it stops checking when it has found the player's Steam ID, in my case I want it to insert the new player's Steam ID if it was not found in the table, which I have half done. But for each record in the table that isn't equal to the player Steam ID, it inserts the player's Steam ID, so this means if there are 10 records of other players, it will insert the players Steam ID 10 times before it stops, ending up with 10 records for one player etc. I hope you understand, here is some code that might explain it a little more in depth. [CODE] local findinfo = db:query("SELECT steam_id FROM player_data") local newdata = db:query("INSERT INTO player_data(steam_id, cash) VALUES('"..ply:SteamID().."', '1000')") function findinfo:onSuccess( data ) for k,v in pairs(data) do if(v.steam_id == ply:SteamID()) then print("Player data found for: ".. ply:SteamID()) break else print("Player data NOT found for: ".. ply:SteamID().. ", creating...") newdata:start() end end end findinfo:start()[/CODE] So at the moment, when a player first spawns, it checks for their steam ID starting at the top of the table working its way down, the only time it will stop is if it finds the players steam ID. I hope this makes some sense as I have been testing and trying for a while now and it's getting very annoying.
I'm quite new to Derma and have been making a few menus to learn/for practice. My text is supposed to say 'playtime:' but is getting cut off. I've noticed it's happened a few times and I want to know how to stop it so it shows all of the text [img]http://puu.sh/aCYLn/46d0556484.jpg[/img] [code] local playtime = vgui.Create("DLabel", playerinfopanel) playtime:SetText("Playtime:") playtime:SetFont("Tahoma") playtime:SetPos(170, 60) [/code]
[QUOTE=NiandraLades;45579604]I'm quite new to Derma and have been making a few menus to learn/for practice. My text is supposed to say 'playtime:' but is getting cut off. I've noticed it's happened a few times and I want to know how to stop it so it shows all of the text [img]http://puu.sh/aCYLn/46d0556484.jpg[/img] [code] local playtime = vgui.Create("DLabel", playerinfopanel) playtime:SetText("Playtime:") playtime:SetFont("Tahoma") playtime:SetPos(170, 60) [/code][/QUOTE]Try adding playtime:SizeToContents()
[QUOTE=ShadowRanger;45579632]Try adding playtime:SizeToContents()[/QUOTE] Oh, that worked, thank you very much!
[QUOTE=TheDoggy;45579519]This may be hard to explain, but what I am looking to do is check the results from a mysql query (a table) and check for a steam ID, which I have done with help from people here, but my next problem is that I want the player's Steam ID to be entered into the table if it can not be found, this is where my problem lies. My problem is that when it checks for Steam ID, it goes through every record in that column, which is good, I have made it so it stops checking when it has found the player's Steam ID, in my case I want it to insert the new player's Steam ID if it was not found in the table, which I have half done. But for each record in the table that isn't equal to the player Steam ID, it inserts the player's Steam ID, so this means if there are 10 records of other players, it will insert the players Steam ID 10 times before it stops, ending up with 10 records for one player etc. I hope you understand, here is some code that might explain it a little more in depth. [CODE] local findinfo = db:query("SELECT steam_id FROM player_data") local newdata = db:query("INSERT INTO player_data(steam_id, cash) VALUES('"..ply:SteamID().."', '1000')") function findinfo:onSuccess( data ) for k,v in pairs(data) do if(v.steam_id == ply:SteamID()) then print("Player data found for: ".. ply:SteamID()) break else print("Player data NOT found for: ".. ply:SteamID().. ", creating...") newdata:start() end end end findinfo:start()[/CODE] So at the moment, when a player first spawns, it checks for their steam ID starting at the top of the table working its way down, the only time it will stop is if it finds the players steam ID. I hope this makes some sense as I have been testing and trying for a while now and it's getting very annoying.[/QUOTE] Your query is fundamentally wrong, you're working with a database and you're not using it like a database. You should ask the database to return what you are actually looking for, for example: [lua] local findinfo = db:query("SELECT * FROM player_data WHERE steam_id ='"..ply:SteamID().."';") [/lua] Then you check the results and see if it gives you anything, if not, THEN insert a new record. [lua] if #data < 1 then --add player to database else --player exists end [/lua]
Thanks for confirming this, after I posted it I did more searching and thought it might have something to do with that, I'll try it out soon! Thank you :P EDIT: Works fine, amazing how the answer to some things can be so simple! Thanks again :P
Anyone know how to set the limit for guns that people can pick up on the gamemode jailbreak.
[QUOTE=ddog777;45580062]Anyone know how to set the limit for guns that people can pick up on the gamemode jailbreak.[/QUOTE] Which version are you using? [editline]3rd August 2014[/editline] [img]http://puu.sh/aD4sd/c67c68ad50.jpg[/img] I asked a few coders on my friendslist about this, and apparently it's a gmod bug, but does anyone know why this is occurring? [code] local playeravatar = vgui.Create("AvatarImage", playerinfopanel) playeravatar:SetSize( 128, 128 ) playeravatar:SetPos( 30, 30 ) playeravatar:SetPlayer( LocalPlayer(), 128) [/code] If I try 184 on just SetPlayer or both, the same thing happens, but bigger. If I change the SetPlayer to 64 or lower, it's fine without the glitchy border but looks blurry as fuck. What I'm essentially trying to do is have an avatar that it's 128x128 but also not blurry.
[QUOTE]Which version are you using?[/QUOTE] version 2.0 and by gmod bug do you mean it is unfixable or what exactly are you implying?
[QUOTE=NiandraLades;45580065] If I try 184 on just SetPlayer or both, the same thing happens, but bigger. If I change the SetPlayer to 64 or lower, it's fine without the glitchy border but looks blurry as fuck. What I'm essentially trying to do is have an avatar that it's 128x128 but also not blurry.[/QUOTE] [url]https://github.com/Facepunch/garrysmod-issues/issues/204[/url] :( [editline]4th August[/editline] here you go [LUA] local api = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=%s&steamids=%s" local key = "" local avatars = {} local embedHtml = [[ <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <img id="mat" src="%s" width="100%%" height="100%%" /> <style type="text/css"> html, body { width: 100%%; height: 100%%; margin: 0; padding: 0; overflow: hidden; } </style> <script type="text/javascript"> var mat = document.getElementById('mat'); mat.onload = function() { setTimeout(function() { gmod.imageLoaded(); }, 100); } </script> </body> </html>]] -- pixeltailgames local html = vgui.Create( "DHTML" ) html:Hide() local function GetLargeAvatar( id64 ) if avatars[id64] then return avatars[id64] end http.Fetch( api:format( key, id64 ), function( response ) local res = util.JSONToTable( response ) local avatarurl = res.response.players[1].avatarfull html:SetHTML( embedHtml:format( avatarurl ) ) html:AddFunction( "gmod", "imageLoaded", function() html:UpdateHTMLTexture() avatars[id64] = html:GetHTMLMaterial() end ) end ) end local function Avatar( ply ) if avatars[ply:SteamID64()] then return avatars[ply:SteamID64()] end end FindMetaTable"Player".GetLargeAvatar = Avatar concommand.Add( "av", function( ply ) GetLargeAvatar( ply:SteamID64() ) hook.Add( "HUDPaint", "hudpaint_test", function() if ply:GetLargeAvatar() then surface.SetDrawColor( color_white ) surface.SetMaterial( ply:GetLargeAvatar() ) surface.DrawTexturedRect( 250, 250, 128, 128 ) end end ) end ) [/LUA] i stole a few lines and the base html code from the pixeltailgames team's HTMLMaterial github thingo, sorry :v: should be fairly self-explanatory to adapt it to what you're doing, add your api key and such
Does anyone know a way to set the color of a player (SetColor) without defining the color of clientsidemodel that is linked to a bone of the player?
[QUOTE=Ott;45577758]Look at your logs. ULX has a really fucking obnoxious boot message filled with tons of slashes and stuff, you can't miss it. Your syntax looks fine.[/QUOTE] [del]Where can I find that? Once I boot the server can I see it in the RCON? I have double checked my joining of the server multiple times on my client-side console. Nothing much. ULX looks like it loaded everything perfectly. It proceeds to load all files. Loads them all, but then doesnt work at all.[/del] I checked the console.log There are no errors. However once I remove my script, ULX loads and works perfectly. The last error I see was from 7/22/14 in the Console.log [LUA] L 07/22/2014 - 00:32:53: Lua Error: [ERROR] addons/pointshop_ultimate/lua/sv_player_extension.lua:279: attempt to index field 'PS_Items' (a nil value) 1. PS_HasItem - addons/pointshop_ultimate/lua/sv_player_extension.lua:279 2. PS_HasItemEquipped - addons/pointshop_ultimate/lua/sv_player_extension.lua:283 3. fn - addons/pointshop_ultimate/lua/sh_pointshop.lua:131 4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/LUA] That above is exactly what caused the grey player models to appear a long time ago. However I did fix that by restoring the files prior to change. However for my new ulx command that I made I added the file in the [CODE]Garrysmod/addons/ulx/lua/ulx/modules/sh[/CODE] folder named [I]givepoints.lua[/I]
Asked this before but didn't get an answer and it's kinda bugging me. Is there a way to create a convar on the server and client, and set it so that the client knows what it's set to as soon as they join? I currently use CreateConVar( "settingname", "0", FCVAR_REPLICATED) in a shared file settingname is set to 1 in server.cfg The server sees settingname as 1 The client sees settingname as 0 until the server changes it.
Can i resize a render.Capture() somehow? So it fits inside a net message.
[QUOTE=Giraffen93;45582561]Can i resize a render.Capture() somehow? So it fits inside a net message.[/QUOTE] Send over multiple net messages or lower the quality.
[QUOTE=Robotboy655;45582676]Send over multiple net messages or lower the quality.[/QUOTE] probably gonna use tokens instead then and do it clientside
[QUOTE=Giraffen93;45582561]Can i resize a render.Capture() somehow? So it fits inside a net message.[/QUOTE] Or compress using [url=http://wiki.garrysmod.com/page/util/Compress]util.Compress[/url] and write as data. Then do the opposite on the receiving end.
[QUOTE=Internet1001;45582715]Or compress using [url=http://wiki.garrysmod.com/page/util/Compress]util.Compress[/url] and write as data. Then do the opposite on the receiving end.[/QUOTE] it's still too much data, it captures a square as wide and tall as monitor height it's going to be resized either way so anywhere is fine really
[QUOTE=Internet1001;45582715]Or compress using [url=http://wiki.garrysmod.com/page/util/Compress]util.Compress[/url] and write as data. Then do the opposite on the receiving end.[/QUOTE] This doesn't guarantee it'll fit in a single net message. It's simple enough to split in to chunks with string.sub and some maths and then when writing the data to each message use net.WriteData. Let me find my gist of this in action.
Sorry, you need to Log In to post a reply to this thread.