autorun\client\cl_carscript.lua:10: attempt to index field 'decoded' (a nil value)
Client
[lua]
require("datastream")
require("glon")
function SetVariable( handler, id, encoded, decoded )
print("1 = "..decoded[1])
print("2 = "..decoded[2])
PrintTable( decoded )
LocalPlayer().decoded[1] = decoded[2]
end
datastream.Hook( "SetVariable", SetVariable )
[/lua]
SERVER
[lua]
require("datastream")
function PlayerSpawn( pl )
pl:SetVariable("BigBoobs", 1)
end
hook.Add( "PlayerSpawn", "BLAAAAAAAAHLALALALALALAPlayerSpawn", PlayerSpawn )
local meta = FindMetaTable("Player")
function meta:SetVariable( ent, value )
self.ent = value
datastream.StreamToClients( self, "SetVariable", { ent, value } )
print("ent: "..ent)
print("value: "..value)
end
[/lua]
You have to define LocalPlayer().decoded before you define LocalPlayer().decoded[1]
[lua]
LocalPlayer().decoded = LocalPlayer().decoded or {}
LocalPlayer().decoded[1] = decoded[2]
[/lua]
Sorry, you need to Log In to post a reply to this thread.