• How do you broadcast tables?
    7 replies, posted
Just like when you use: PS_GetPoints() it works on any addon anywere? How do you Broadcast a table and let every other plugin use it? Thanks if you help ~
[url]https://github.com/adamdburton/pointshop/blob/50afa56a4bb5efc53532cdcbabf32935cb23cd1c/lua/pointshop/sv_player_extension.lua#L155-L157[/url] and [url]https://github.com/adamdburton/pointshop/blob/f56c271c63caea13e9f1504909e6680a65518e83/lua/pointshop/cl_player_extension.lua#L55-L57[/url] Also, GetPoints doesn't have anything to do with tables [editline]14th August 2016[/editline] All you seem to need to do is this: [CODE] local Player = FindMetaTable('Player') function Player:WhateverFunction() -- blah end [/CODE]
[QUOTE=MPan1;50883170][url]https://github.com/adamdburton/pointshop/blob/50afa56a4bb5efc53532cdcbabf32935cb23cd1c/lua/pointshop/sv_player_extension.lua#L155-L157[/url] and [url]https://github.com/adamdburton/pointshop/blob/f56c271c63caea13e9f1504909e6680a65518e83/lua/pointshop/cl_player_extension.lua#L55-L57[/url] Also, GetPoints doesn't have anything to do with tables[/QUOTE] I know, but can't we broadcast tables?
Can you be more specific on what data you're trying to broadcast?
[QUOTE=code_gs;50883185]Can you be more specific on what data you're trying to broadcast?[/QUOTE] itemsArr = {} itemsArr[1] = { "models/player/kleiner.mdl", "kleiner", "Kleiner", "100" } itemsArr[2] = { "models/player/odessa.mdl", "odessa", "Odessa", "250" } itemsArr[3] = { "models/player/Police.mdl", "police", "Police", "500" } itemsArr[4] = { "models/player/alyx.mdl", "alyx", "Alyx", "500" } itemsArr[5] = { "models/player/barney.mdl", "barney", "Barney", "100" }
Make the table shared and network the table index.
[QUOTE=code_gs;50883200]Make the table shared and network the table index.[/QUOTE] How, this is the question?
[code]-- Shared local tbl = {{ "stuff" }, { "otherstuff" }, {"morestuff" }} -- Server local index = 5 util.AddNetworkString( "TableIndex" ) net.Start( "TableIndex" ) net.WriteInt( index ) net.Broadcast() -- Client net.Receive( "TableIndex", function() local clienttbl = tbl[net.ReadInt()] -- Stuff end )[/code]
Sorry, you need to Log In to post a reply to this thread.