• New GLua YouTube tutor
    31 replies, posted
Hello guys, wanted to let you know about an new GLua tutor, who makes Up-To-Date tutorial videos, He does Gamemode scripting, but the tutorials can be applied to normal addons too. He did stuff like [B]EXP/Leveling system, Shop menu, Money, Ammo dispenser[/B] and more. Since I am bad with posting actually, I just say you check out the guy for yourself! He's already in the stickies, but since you're -probably- lazy, heres the GLua playlist of him: [url]https://www.youtube.com/playlist?list=PLCFyE3cH3BEF_1Dxh6UiTSS7TwpXavZZO[/url]
Looks great, one suggestion could you possibly cover creating a custom base gamemode? i.e Custom Player Class, VGUI, etc.
[QUOTE=SergeantJaffa;48832310]Looks great, one suggestion could you possibly cover creating a custom base gamemode? i.e Custom Player Class, VGUI, etc.[/QUOTE] I aint the person! x3 You should contact him instead.
Using NWInts. I'm done.
[QUOTE=Netheous;48832320]Using NWInts. I'm done.[/QUOTE] Better than nothing, right?
[QUOTE=whitestar;48832325]Better than nothing, right?[/QUOTE] Yeah - and that was my 5000th post :P
[QUOTE=Netheous;48832327]Yeah - and that was my 5000th post :P[/QUOTE] Gratz >w< I need 5K posts + 2 years(I think) to get gold member :c
[QUOTE=Netheous;48832320]Using NWInts. I'm done.[/QUOTE] Just curious, what is wrong with them? Is it because it goes to all clients from the server, compared to .net? Which is single client to server? Surely using one or two NW's for basic things that will not come up that often will be alright?
[QUOTE=Bittenfleax;48832378]Just curious, what is wrong with them? Is it because it goes to all clients from the server, compared to .net? Which is single client to server? Surely using one or two NW's for basic things that will not come up that often will be alright?[/QUOTE] Its exploitable, since it makes the money & exp system handled by client too.
[QUOTE=whitestar;48832387]Its exploitable, since it makes the money & exp system handled by client too.[/QUOTE] What?
[QUOTE=whitestar;48832387]Its exploitable, since it makes the money & exp system handled by client too.[/QUOTE] Really? Never really hear about that. Also, I have not watched the videos.
[QUOTE=whitestar;48832387]Its exploitable, since it makes the money & exp system handled by client too.[/QUOTE] SetNW<> is shared apparently, but the client can't make changes to it.
Well then, I am dumb, never really needed to use those.
NWInts are just a bad solution. Net library is well more organized, you can store all your variables in one table.. say "rpg". You can store it on player by doing [lua]ply.rpg = {} ply.rpg.level = 1 ply.rpg.exp = 300[/lua] Then you can send whole rpg table via: [lua]net.WriteTable( ply.rpg )[/lua] Or send values separately and it'll be way more efficient than NWInt
[QUOTE=Netheous;48832514]NWInts are just a bad solution. -snip-[/QUOTE] Ahh right, makes sense. - Cheers
[QUOTE=Netheous;48832514][code]net.WriteTable( ply.rpg )[/code][/QUOTE] Don't use WriteTable if you know table structure, goddammit.
[QUOTE=mijyuoon;48833074]Don't use WriteTable if you know table structure, goddammit.[/QUOTE] I am curious what would you use then?
[QUOTE=mijyuoon;48833074]Don't use WriteTable if you know table structure, goddammit.[/QUOTE] That's what I meant - you can send everything separately. It's pointless to send whole table if one variable changed.
[QUOTE=boxvader;48833102]I am curious what would you use then?[/QUOTE] Write each element separately depending on the type, like WriteString or WriteInt. If there's an unpredicted amount of elements, write an int for the table size. If there are unpredicted types, use WriteTable.
[QUOTE=boxvader;48833102]I am curious what would you use then?[/QUOTE] Manually write values from table. [code] ply.rpg = {} ply.rpg.level = 1 ply.rpg.exp = 300 ... net.WriteInt(ply.rpg.level, 32) net.WriteInt(ply.rpg.exp, 32) [/code] EDIT: Ninja'd.
If there are too many variables of same type, you can even help yourself by sending a string with variable name first. [lua]ply.rpg[ net.ReadString() ] = net.ReadInt( 32 )[/lua] There are so many ways to handle this - the point is not to send data that didn't change, like NWVars used to do/still do.
[QUOTE=Netheous;48833139]If there are too many variables of same type, you can even help yourself by sending a string with variable name first. [lua]ply.rpg[ net.ReadString() ] = net.ReadInt( 32 )[/lua] There are so many ways to handle this - the point is not to send data that didn't change, like NWVars used to do/still do.[/QUOTE] level and exp seem to be static members. The client can already know them when they join. [lua] -- server: for all rpg properties do net.WriteInt(level, ...) net.WriteInt(exp, ...) end [/lua] Of course this doesn't apply when there are dynamic properties etc.
I'm assuming you guys are so anti net.WriteTable because of optimization quirks?
[QUOTE=YourStalker;48836603]I'm assuming you guys are so anti net.WriteTable because of optimization quirks?[/QUOTE] It's because it sends a lot of stuff (type info for keys and values, sometimes keys themselves) that is redundant if you have known table structure. Which can lead to large network load if you're sending it very often/sending a lot of stuff and is bad practice in general. There are some legit uses for WriteTable though, like if you're sending dynamic data that has totally arbitrary and unpredictable structure.
[QUOTE=mijyuoon;48836719]It's because it sends a lot of stuff (type info for keys and values, sometimes keys themselves) that is redundant if you have known table structure. Which can lead to large network load if you're sending it very often/sending a lot of stuff and is bad practice in general. There are some legit uses for WriteTable though, like if you're sending dynamic data that has totally arbitrary and unpredictable structure.[/QUOTE] Or sending the table for the first time to inform the client of it's structure is also a valid reason to send the table - at times like PlayerInitialSpawn.
You really ought to read up more on GLua coding before creating a channel like this. Teaching bad habits to new coders is not a great idea. [editline]5th October 2015[/editline] I'm not talking about networking.
[url]https://facepunch.com/showthread.php?t=1253834[/url] [QUOTE=garry;39919712]Where possible always use a networked variable, as in [url]http://wiki.garrysmod.com/page/Networking_Entities[/url] Even if it means making a special entity to hold the new variables. You should only be using the net library to send messages - not to keep variables in sync.[/QUOTE]
When garry disreguards everything everyone just said XD
[url=https://facepunch.com/showthread.php?t=1253834]That entire thread[/url] contradicts everything people have said about net messaging so far lol.
Well he is making a good point why go remake a system that essentially already implemented into the game.
Sorry, you need to Log In to post a reply to this thread.