• Two little questions
    1 replies, posted
Hello, First question/problem: I have a client lua file into gamemode/modules/vgui and i want to include the database file who is into gamemode/modules. How to navigate in differents folder like that ? Last question/problem: In a derma panel/label, i want to write player data like level, money... So, how to receive data from server to client ? Thanks.
I'd recommend setting up a single inclusion file - I use cl_init.lua to include sh_init.lua and init.lua to AddCSLuaFile sh_init.lua and cl_init.lua and include sh_init.lua in sh_init.lua I have an autoloader which automatically includes ( based off of reading all files in a directory to load hooks which provide the autoloader with rules to follow for inclusion of files )... That may be a bit more than you're looking for - but I'd recommend you do something similar, up to the point of just before the autoloader and put your includes / AddCSLuaFile calls in it that way you have a perfect load-order that doesn't need to be repeated and you always know the exact load-order you're running... You will need to use if SERVER / CLIENT then ... end... for server vs client ( which I recommend to put underneath shared files depending how you have it all set up )... [url]https://www.dropbox.com/s/ja9yr507r8nb3hu/gm_name.rar?dl=0[/url] That's an example of using a helper-function to include files by giving a file-name and the realm where it will be included and it'll handle the appropriate calls so it is only 1 line and there is no need for if SERVER / CLIENT then lines... As for derma - it is likely you will already have the money, etc... data on the client-side - if not, here is a way to design a currency system properly which has everything integrated except load and save ( just add something like file.write( "money/" .. _p:UniqueID( ) .. ".txt", _p:Money( ), "DATA" ); for the saving and _p:SetMoney( ( tonumber( file.Read( "money/" .. _p:UniqueID( ) .. ".txt", "DATA" ) || "0" ) ) ); to load.. the || "0" will set the default currency to 0 on loading.. then _p:Money( ); where you want it to appear... [url]https://www.dropbox.com/s/7ccqk6c7dwji2ui/simple_currency_system.zip?dl=0[/url]
Sorry, you need to Log In to post a reply to this thread.