• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=BFG9000;45891890]Not to mention that it's not even supposed to be a table Correct way to write that would be [code] local someVguiElement = vgui.Create("SomeVGUIElement") someVguiElement.Paint = function(self, w, h) print("Width is " .. w .. " pixels") end [/code][/QUOTE] Something surprisingly uncommon is [code] local someVguiElement = vgui.Create("SomeVGUIElement") function someVguiElement:Paint(w, h) print("Width is " .. w .. " pixels") end [/code]
[QUOTE=BFG9000;45891890]Not to mention that it's not even supposed to be a table Correct way to write that would be [code] local someVguiElement = vgui.Create("SomeVGUIElement") someVguiElement.Paint = function(self, w, h) print("Width is " .. w .. " pixels") end [/code][/QUOTE] Yes, excuse the use of the local. That was an accident.
[QUOTE=Willox;45892154]Something surprisingly uncommon is [code] local someVguiElement = vgui.Create("SomeVGUIElement") function someVguiElement:Paint(w, h) print("Width is " .. w .. " pixels") end [/code][/QUOTE] I actually do this once in a while if I feel like I need the formatting to be a bit more eye-friendly
How do I change a gamemode without changing the Command Line manager? (Using TCAdmin panel.) Like, I want to be able to do a voting system where people can vote on a gamemode then the server restarts with the chosen gamemode.
Calling the Self function with a colon worked, thanks. New question: Can I override a prop_physics health to make it higher some how? I used SetHealth to set the bench's health to 50 but it breaks normally instead of using my break method. [code] if ent:Health() <= 0 then net.Start("Destroyed") net.Send(ent.TiedPly) -- Tell the client to draw our fancy messages ent.TiedPly:Kill() -- Kill the player local effectdata = EffectData() -- EFFECTS! effectdata:SetOrigin( ent:GetPos() + ent:OBBCenter() ) effectdata:SetMagnitude( 5 ) effectdata:SetScale( 2 ) effectdata:SetRadius( 5 ) util.Effect( "Sparks", effectdata ) ent:Remove() end [/code] This function hooked to EntityTakeDamage doesnt get called because the Prop breaks way before that after taking only 20 damage and having 30 health left. I figure its hardcoded into the Model itself but I was wanting to know if I could override it
[QUOTE=docdo1;45892947]How do I change a gamemode without changing the Command Line manager? (Using TCAdmin panel.) Like, I want to be able to do a voting system where people can vote on a gamemode then the server restarts with the chosen gamemode.[/QUOTE] [lua] local NextGamemode = "terrortown" local NextMap == "cs_assault" game.ConsoleCommand( "gamemode " .. NextGamemode) game.ConsoleCommand( "changelevel " .. NextMap ) [/lua]
[QUOTE=docdo1;45892947]How do I change a gamemode without changing the Command Line manager? (Using TCAdmin panel.) Like, I want to be able to do a voting system where people can vote on a gamemode then the server restarts with the chosen gamemode.[/QUOTE] RunConsoleCommand("gamemode", "sandbox") RunConsoleCommand("map", "gm_flatgrass") ? I don't remember if that works, you could always change the parameters and use _restart edit: too slow :D
I'm not much of a coder, but I'm doing project management for a gamemode, and I need a SWep Base for some bolt action rifles and pistols. I'm currently using Siminovs SWep base, but it's kind of excessive for my gamemode. What are some simple SWep bases I can use with my weapon models that are easy to work with and have seperate loaded/empty reload animations?
What would be the best method to send large tables to the client. I tired using usermessages and doing util.TableToJSON( temptbl ) but it gave me this error: [code] Warning: Usermessage was larger than 256 bytes. This will cause problems. Error sending usermessage - too large (updateMisc) [/code]
when i try opening a map with my addon, game crashes.
[QUOTE=bran92don;45894234]What would be the best method to send large tables to the client. I tired using usermessages and doing util.TableToJSON( temptbl ) but it gave me this error: [code] Warning: Usermessage was larger than 256 bytes. This will cause problems. Error sending usermessage - too large (updateMisc) [/code][/QUOTE] [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url] You have 64kb aka 65536b instead. OR if you MUST use usermessages, you could break the table into parts, but it's a shitty work around.
[QUOTE=Pandaman09;45894254][url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url] You have 64kb aka 65536b instead. OR if you MUST use usermessages, you could break the table into parts, but it's a shitty work around.[/QUOTE] is there anything I can do that doesn't have a limit I am trying to code a marketplace system where players can put items up for sale and I need to be ale to retrieve a large table of who knows what amount from the sql database and then send it to the client so they know what they are buying.
[QUOTE=bran92don;45894284]is there anything I can do that doesn't have a limit I am trying to code a marketplace system where players can put items up for sale and I need to be ale to retrieve a large table of who knows what amount from the sql database and then send it to the client so they know what they are buying.[/QUOTE] Have you considered [URL="http://wiki.garrysmod.com/page/http/Fetch"]http.Fetch[/URL]? It would only be limited by their internet speed but you would need a server or somewhere to get the data from EDIT: this might require some great knowledge of PHP in order to be able to use it. EDIT2: you could also only send part of the table, a 'page' of items. It would solve your problem and be easy to do.
[QUOTE=sacred1337;45893049][lua] local NextGamemode = "terrortown" local NextMap == "cs_assault" game.ConsoleCommand( "gamemode " .. NextGamemode) game.ConsoleCommand( "changelevel " .. NextMap ) [/lua][/QUOTE] I could be wrong, but I think you need to append \n in a game.ConsoleCommand string otherwise it doesn't actually send through the command.
[QUOTE=Pandaman09;45894311]Have you considered [URL="http://wiki.garrysmod.com/page/http/Fetch"]http.Fetch[/URL]? It would only be limited by their internet speed but you would need a server or somewhere to get the data from EDIT: this might require some great knowledge of PHP in order to be able to use it. EDIT2: you could also only send part of the table, a 'page' of items. It would solve your problem and be easy to do.[/QUOTE] Wouldn't that require me to switch it over to mysql instead of sql. I own a dedicated server box so i can do whatever I want with it. I sorta was trying to prevent using mysql , because the last time I did I had to use a bunch of callback functions and it didn't seem to be timed perfectly. This honestly sorta makes me mad because I just typed this whole thing up and finished it and encountered an error like that. I guess I will look into changing it to only get a select amount of the sql tables and sending them page by page.
[QUOTE=bran92don;45894284]is there anything I can do that doesn't have a limit I am trying to code a marketplace system where players can put items up for sale and I need to be ale to retrieve a large table of who knows what amount from the sql database and then send it to the client so they know what they are buying.[/QUOTE] format your tables so that you don't have to send them as tables [editline]a[/editline] networking of any kind should always been done with size in mind, you should want to send the least amount of data possible, and sending tables as tables is a lot of data, split them up [lua] net.WriteUInt(#itemstosend, 16) --if you need to send more than 65536 items you may want to consider having fewer items for k, v in pairs(itemstosend) do net.WriteString(v.name) net.WriteUInt(v.price, 24) --price up to 16.7 million etc end [/lua]
Is Entity:EntIndex() unique? In other words is the value ever reused.
It is eventually re-used. The number can shift based on max-players. If you want to use EntIndex to id map objects in SHARED realm instead of relying on Map Creation ID ( which is serverside only, meaning EVERYTHING needs to be networked ), take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/entities/entity_getid_mapping_system.lua.html[/url] If it is for maps, just remember to never spawn any entity before InitPostEntity. InitPostEntity should be where you spawn any map objects ( otherwise map ent-index will shift too; if you use my GetID and spawn items in or after InitPostEntity, then the id will always be the same )
Does anyone know how to publish saves as privately as possible( makes sense don't you think)? I want to clear up my Gmod but I have one unfinished (and when I mean unfinished, I mean barely started) scene I don't want to be either public for everyone or erased.
[QUOTE=Tinbe;45898133]Does anyone know how to publish saves as privately as possible( makes sense don't you think)? I want to clear up my Gmod but I have one unfinished (and when I mean unfinished, I mean barely started) scene I don't want to be either public for everyone or erased.[/QUOTE] GarrysMod\garrysmod\saves. That's where Gmod stores your saves, so just drag the file out of there and do what you wish. Also I have another question that I can't seem to fix. [B]Error:[/B] [CODE][ERROR] addons/gamemodevoter/lua/autorun/shared.lua:1: attempt to call global 'ChangeGamemode' (a nil value) 1. unknown - addons/gamemodevoter/lua/autorun/shared.lua:1 [/CODE] [B]cl_init.lua file:[/B] [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) function ChangeGamemode(nextgamemode) local chosengamemode = "nextgamemode" game.ConsoleCommand("gamemode " .. chosengamemode .. "\n") end elseif CLIENT then end[/CODE] [B]shared.lua file:[/B] [CODE]concommand.add("changegamemode", ChangeGamemode(args))[/CODE] Trying to get it so when you type 'changegamemode [gamemode]' in console, the gamemode typed will be the one it changes to however that dang error keeps popping up. Any tips?
Why do you have a Server function in your Client file?
[QUOTE=Exho;45898582]Why do you have a Server function in your Client file?[/QUOTE] Re-named file to init.lua, still same issue.
[QUOTE=docdo1;45898459]GarrysMod\garrysmod\saves. That's where Gmod stores your saves, so just drag the file out of there and do what you wish. Also I have another question that I can't seem to fix. [B]Error:[/B] [CODE][ERROR] addons/gamemodevoter/lua/autorun/shared.lua:1: attempt to call global 'ChangeGamemode' (a nil value) 1. unknown - addons/gamemodevoter/lua/autorun/shared.lua:1 [/CODE] [B]cl_init.lua file:[/B] [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) function ChangeGamemode(nextgamemode) local chosengamemode = "nextgamemode" game.ConsoleCommand("gamemode " .. chosengamemode .. "\n") end elseif CLIENT then end[/CODE] [B]shared.lua file:[/B] [CODE]concommand.add("changegamemode", ChangeGamemode(args))[/CODE] Trying to get it so when you type 'changegamemode [gamemode]' in console, the gamemode typed will be the one it changes to however that dang error keeps popping up. Any tips?[/QUOTE] you're including shared before you're declaring ChangeGamemode, and that's not how you pass a function as an argument
Really sorry to clog up the thread, fixed it by; [B]Init:[/B] [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) function changegamemode(nextgamemode) local chosengamemode = "nextgamemode" game.ConsoleCommand("gamemode " .. chosengamemode .. "\n") end usermessage.Hook("changegamemode", changegamemode) include( "shared.lua" ) elseif CLIENT then end[/CODE] [B]Shared:[/B] [CODE]concommand.Add("changegamemode", changegamemode)[/CODE] Going to find out how to add arguments to it myself, thanks for trying though!
[QUOTE=docdo1;45899204]Really sorry to clog up the thread, fixed it by; [B]Init:[/B] [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) function changegamemode(nextgamemode) local chosengamemode = "nextgamemode" game.ConsoleCommand("gamemode " .. chosengamemode .. "\n") end usermessage.Hook("changegamemode", changegamemode) include( "shared.lua" ) elseif CLIENT then end[/CODE] [B]Shared:[/B] [CODE]concommand.Add("changegamemode", changegamemode)[/CODE] Going to find out how to add arguments to it myself, thanks for trying though![/QUOTE] Just a note, the way you're doing it now, you're running console command 'gamemode nextgamemode'
Just a general question here, and I know how to work around it (and have done for years) but it's a tad annoying really so I figured I'd ask. Why is it that InitialPlayerSpawn always seems to almost fail every time at applying properties to a player (eg Lock, player movement and so on) just after they load, whereas PlayerSpawn will be successful no matter what (again, talking just after they've loaded). Is InitialPlayerSpawn more like a 'PrePlayerSpawn'?
I need dynamic music for a map. I'm thinking of using [B]ENTITY:Touch( entity )[/B] and a [B]for loop[/B] to detect when a [B]player touches [/B]a specific [B]map entity.[/B] Does [url]http://wiki.garrysmod.com/page/ENTITY/Touch[/url] work this way or do I need to find another function?
You're probably better off with [url]http://wiki.garrysmod.com/page/ENTITY/StartTouch[/url] as it's only called once, and use that to then start any actions on the player. Touch is called every frame so in the above example you'd be creating a new sound for as long as the player is touching it. [editline]6th September 2014[/editline] There's also [url]http://wiki.garrysmod.com/page/ENTITY/EndTouch[/url] once they leave the trigger area.
[QUOTE=Teddi Orange;45906507]You're probably better off with [url]http://wiki.garrysmod.com/page/ENTITY/StartTouch[/url] as it's only called once, and use that to then start any actions on the player. Touch is called every frame so in the above example you'd be creating a new sound for as long as the player is touching it. [editline]6th September 2014[/editline] There's also [url]http://wiki.garrysmod.com/page/ENTITY/EndTouch[/url] once they leave the trigger area.[/QUOTE] Actually I found this functions which should work nicely [url]http://wiki.garrysmod.com/page/ents/FindInBox[/url]
Is it possible to create/remove Cubemaps and then save the map with them?
Sorry, you need to Log In to post a reply to this thread.