I want to attempt to make a good car dealer, but I don't know how or where to start.
Pretty much, this is what I want to somewhat know how to do.
- Have the car dealer be spawnable (either spawnmenu or command)
- Have a config file
- GUI on use (pretty easy, I somewhat know how to do this)
config file is just filled with global variables.
A example snippet
[lua]function GM:PlayerInitialSpawn(ply)
ply:PrintMessage(GM_TEST_MESSAGE)
end[/lua]
config
[lua]
GM_TEST_MESSAGE = "Hello there!"
[/lua]
No please. I hate when configs are made like that. Your making tons of global variables, when you could just be making one global table, and having the values stored in it like so.
[code]
config = config or {}
config.Notification = "Test Notification"
print(config.Notification)
[/code]
How I always have done my configs.
[editline]16th September 2014[/editline]
As for your first thing, create a SENT and have it handle menu opening on the Use function, and then, add the proper shared settings;
[code]
ENT.Category = "Crazy's Entities"
ENT.Spawnable = true
ENT.AdminOnly = true
[/code]
and then you can have a separate file that handles saving on like a concommand or something, and read it on server start up, to load and create the car dealers. Gui is self explanatory.
[QUOTE=crazyscouter;45997558]No please. I hate when configs are made like that. Your making tons of global variables, when you could just be making one global table, and having the values stored in it like so.
[code]
config = config or {}
config.Notification = "Test Notification"
print(config.Notification)
[/code]
How I always have done my configs.
[/QUOTE]
Would it just be as simple as saving it to a file with TableToJSON to make it configurable to the person using it?
Yea. However, I would recommend using convars for that. [url]http://wiki.garrysmod.com/page/ConVars[/url]
[QUOTE=crazyscouter;45997994]Yea. However, I would recommend using convars for that. [url]http://wiki.garrysmod.com/page/ConVars[/url][/QUOTE]
Well, I was gonna use the config for which cars people wanted, but then again, just having set prices would be easier.
Bump for a question:
How can I stop ENT:Use function from being so spammy, I currently only have a sound emit in it just for testing before I make the UI. Anyway to stop the spamminess of it?
EDIT: Also, with Draw, can I use stuff like surface and draw libraries?
[url=http://wiki.garrysmod.com/page/Entity/SetUseType]ENT:SetUseType[/url] Always search the wiki first.
Sorry, you need to Log In to post a reply to this thread.