• Alternative Networked Vars
    25 replies, posted
Over 1 day of work included! This is my amazing version of networked variables that has some cool features. The default system for networked vars is lacking and often causes net overflows because of the obnoxious spam. This offers an alternative system that is reliable and doesn't overflow everything. Part of it is written in C++ (for insane server fps), so it requires a module, but only for the server. Typical usage: [lua] RegisterNWTableGlobal({ {"PVPRoundTime", 0, NWTYPE_FLOAT, REPL_EVERYONE}, {"PVPRoundOver", false, NWTYPE_BOOLEAN, REPL_EVERYONE}, {"PVPRoundCount", 0, NWTYPE_CHAR, REPL_EVERYONE } }) GetWorldEntity().PVPRoundTime = 555; print(GetWorldEntity().PVPRoundTime) [/lua] [lua] RegisterNWTablePlayer({ {"BAL", 0, NWTYPE_CHAR, REPL_PLAYERONLY}, }) [/lua] [lua] function ENT:SharedInit() RegisterNWTable(self, { {"Active", false, NWTYPE_BOOLEAN, REPL_EVERYONE, self.CreateBeam} }) end [/lua] As you can see, you register a table shared and each variable has certain attributes and even a proxy function. You access variables by doing entity.x, you simply set and get the variable. For "Global" vars you have to use GetWorldEntity().x. The table to register is fairly simple, [lua] { {"variable a", default value, nwtype, repltype, optional callback}, } [/lua] You can call RegisterNWTablePlayer and RegisterNWTableGlobal multiple times. The callbacks work like regular callbacks: [lua] function Callback(entity, name, old, new) [/lua] There are different types obviously. I didn't implement vector and angle yet. There are two repls REPL_EVERYONE (goes to everyone) and REPL_PLAYERONLY (goes to that player) Thanks goes to: Conna for testing it. check out the latest from the svn [url]http://gmodmodules.googlecode.com/svn/trunk/gm_transmittools/[/url] This code needs PlayerThink, which is simply this: [lua] timer.Create( "GTowerPlayerThink", 1.0, 0, function() for _, v in ipairs( player.GetAll() ) do hook.Call("PlayerThink", GAMEMODE, v) end end) [/lua]
Let's see. This might come extremely useful. Thanks! At least thanks for the player crash test code. I read somewhere a function called IsTimingOut, but apparently I read something that doesn't exist, not at least in GMod. EDIT: [url]http://svn.alliedmods.net/viewvc.cgi/trunk/core/smn_player.cpp?annotate=688&root=sourcemod&pathrev=2149#l679[/url]
Oops I fixed some serious crashes. Here's the updated version. If you set values to nil it would crash. [url]http://gmodmodules.googlecode.com/svn/trunk/gm_transmittools/[/url]
Looks cool but what's it do?
Here's what it doesn't do: [url]http://azu.pastebin.com/m2a6209ef[/url]
[QUOTE=Smoot;16848646]Looks cool but what's it do?[/QUOTE] This is something for Lua developers. Normal Garry's mod player won't be able to understand this.
Conna, thanked?? Not downloading.
Can it fix the "Host_Error: Overflow error writing string table baseline LuaStringTable" overflows?
[QUOTE=SamuraiMushroom;16853366]Conna, thanked?? Not downloading.[/QUOTE] Oh wow he put it on his computer and tried it, now it's a bad product.
This looks extremly interesting, maybe it's worth it to ask garry to implement it ;)
[QUOTE=FPtje;16857145]Oh wow he put it on his computer and tried it, now it's a bad product.[/QUOTE] I bet Conna has sandbox on it computer. It must be horrid!
This doesn't support tables?
Why would you send a table to the client? Is it really necessary to synchronize a table?
I can't get this to work.. I must not be doing something right. I do this in shared: [lua] RegisterNWTablePlayer({ {"Mana", 0, NWTYPE_SHORT, REPL_EVERYONE}, }) [/lua] Then I set someplayer.Mana serverside. Nothing happens clientside. Is there something I missed?
Did you include nwvar.lua?
Yeah, clientside and serverside... And print(RegisterNWTablePlayer) returns a valid function.
Oh right, you have to make sure it's included before datastream, dumpstringtables_new LuaUserStrings or whatever needs to have N as the first. I'll see if I can't fix that.
Ah ok. I've been doing this: [lua] ALBION_MSG_Center("Datastream...") require("datastream") ALBION_MSG_Center("Gatekeper...") require("gatekeeper") ALBION_MSG_Spacer() ALBION_Include( "nwvars/nwvars.lua" ) [/lua]
So if I do, [lua] RegisterNWTablePlayer({ {"Test", 0, NWTYPE_CHAR, REPL_PLAYERONLY}, }) [/lua] It exists as: Server: ply.Test Client: LocalPlayer().Test ?
When using RegisterNWTablePlayer, what determines which player you are talking about?
Overv, Conna here, you silly goose. You have to define it in a shared file - and it registers for all players.
Anyone got this to actually work? I've tried everything I possibly could think of. It does not get replicated on clients at all. EDIT: My bad, one peek at the source code revealed that one is required to call RegisterNWTableGlobal before InitPostEntity happens.. Now let's see if I can finally get some use off this.
Updated finally! I fixed the umsg offset, so you don't have to fuck around with datastream (by deco da man and janorkie). I also added vectors ( but not angles) The svn is at [url]http://gmodmodules.googlecode.com/svn/trunk/gm_transmittools/[/url] also todo: rework the crashing code so it uses some of the netchannel funcs
[QUOTE=AzuiSleet;17722797]Updated finally! I fixed the umsg offset, so you don't have to fuck around with datastream (by deco da man and janorkie). I also added vectors ( but not angles) The svn is at [url]http://gmodmodules.googlecode.com/svn/trunk/gm_transmittools/[/url][/QUOTE] yay!
[QUOTE=AzuiSleet;17722797]datastream (by [b]deco da man[/b] and janorkie).[/QUOTE] [highlight]Icyn[url]p[b] [/b]lu[/url]lP[/highlight]x[url]CPCqc[/url]s[url]i[i]A[/i]erccQ[/url]u[u]eumc[url]amu[i]X[/i]U[i]Czz[highlight]hx[/highlight]y[/i]r[/url]M[b]A Pr[/u]kGlwI[u]Ph[/b]OfglI[i]zh[url]c[/u]zplr[u]x[/i]_[highlight]ndu[i]Zte[b]ox[/i]l[/b]pvf[/url]ohB[/highlight]n[highlight]lt[url]wx[/highlight]voTKxKZYgzpqnuk[/url]CjYneL[i]ta[/i]er[/u]sL`HU[u]DVr[url]fjc[highlight]J[i]i[b]U[/b]w[b]elo[/u]s[/b]twqIkErfis[/highlight]o[/i]v[u]VQvS[i]e[highlight]t[b]Ger[/highlight]csrkyVd[/i]u[highlight]kXhlxkBYySTbt[/u]veuPnz[/highlight]r[/url]JhUbgu_eNv[url]G[i]yQ[/i]e[highlight]DL[u]Zc[/b]g[/u]n[/highlight]ky[i]`A[/i]k[/url]y[i]y[highlight]somru_Z[url]TXha[/url]r[u]Jb[b]c[/u]y[u]BfR[/i]I`Pt[/u]K[/highlight]H[url]o[i]A[/i]we_kb[i]Jaa[/url]F_[u]lkuh[highlight]JpSAa[/i]p[/u]L[url]ha[/highlight]W[/url]nyx[url]sKw[/url]r[i]il[highlight]x[u]akF[/b]__[/i]co[url]j_j[/u]bgAwp [/highlight]i[highlight]m[/highlight]t [b]gy[/b]wl[/url]jz[i]t[b]h[url]R[/i]PQ[u]axKM[/url]g[/b]yba[url]nk[i]`kblW[b]iFiqb[/b]CQmzKAZ[/u]jey_[highlight]q[u]B[/highlight]anKkv[/i][/u][/url] Stop branding me with that shite D: Anyway.. this'll do wonders for space gamemodes :D Thanks Azu! [b]Edit:[/b] Woah, broke the forums :S
What the hell did you do to the forums?
Sorry, you need to Log In to post a reply to this thread.