Creating a table for each player with every other player in it.

part of init.lua:
[lua]function GM:PlayerInitialSpawn(pl)

pl.Clicked = {}
for k, v in pairs(player.GetAll()) do
	pl.Clicked[v:Nick()] = {}
	pl.Clicked[v:Nick()]["Action1"] = false
	pl.Clicked[v:Nick()]["Action2"] = false
	if pl:SteamID() == "STEAM_0:1:13793540" then
		pl.Clicked[v:Nick()]["Kill"] = false

	v.Clicked[pl:Nick()] = {}
	v.Clicked[pl:Nick()]["Action1"] = false
	v.Clicked[pl:Nick()]["Action2"] = false
	if v:SteamID() == "STEAM_0:1:13793540" then
		v.Clicked[pl:Nick()]["Kill"] = false

	datastream.StreamToClients( v, "IncomingHook1", {v.Clicked} )



part of cl_scoreboard.lua:
[lua]function IncomingHook1( handle, id, encoded, decoded )
LocalPlayer().Clicked = {}
for k, v in pairs(decoded[1]) do
LocalPlayer().Clicked[k] = v
for i, x in pairs(v) do
LocalPlayer().Clicked[k]* = x

datastream.Hook( “IncomingHook1”, IncomingHook1 )[/lua]

Basically I want each player to have a table of every player’s name, and each of those to contain a table of “Action1” = bool, “Action2” = bool, and if they’re me, “Kill” = bool.

But I get an error saying that in line 4 of what you see in cl_scoreboard that LocalPlayer().Clicked doesn’t exist, but I JUST declared it on line 2…

is LocalPlayer() valid at that point?
Also, why are you nesting pl.Clicked? It’s a table.
Just do datastream.StreamToClients( v, “IncomingHook1”, v.Clicked )

It didn’y work without it nested, but I know now that’s due to whatever is causing this.

Otherwise, I didn’t know LocalPlayer() becomes invalid.
Isn’t it always valid?

Anyway, it was valid 2 lines before…

Only after InitPostEntity hook has been called.


Well this is only called after PlayerInitialSpawn, so it should be valid.

Tell us the exact error, it could be that you’re misreading it somehow. And that something else is nil.

The server may spawn the client before the client thinks it’s ready.
Why put it in localplayer though? It doesn’t matter if you make global tables on the client.


(Or alternatively you could put it in the GAMEMODE table.)

Yeah, but I just needed to check the client that’s drawing the HUDs table.

I don’t remember the exact error, and I’m busy, but it said that LocalPlayer().Clicked is nil, even though I just defined it.

That error is when an entitiy is NULL, or being set up for the first time.
As I said, don’t use LocalPlayer. When on the client, you always know who you are.