I’m fairly new to tables and was wanting to know how you could make it so that each player has their own table. Sorry if i missed it some where on the wiki.
Important thing to know about Lua: pretty much everything is just a fancy table. Players are tables. SENTs are tables. Weapons are tables. You’re a table. I’m a table.
That being said, you can set a variable on an entity to anything you want as easy as
[lua]LocalPlayer().MyVariable = “Hello, World!”[/lua]
However, bear in mind variables set on players like that are not networked, so if you do that on the client, and on the server you do
it will print nil.
ok thanks for the reply, i’m making a meta table of Player and am having some trouble. here’s my code.
local meta = FindMetaTable(“Player”)
if ply:getPoints() == nil then
So what’s your trouble? Nothing seems blatantly wrong to me.
OH. Issue. All of your meta functions are shared, but you’re not going to be able to set player data from the client, so you’ll get some errors there.
well my problem is that when i try to use something like print(LocalPlayer():getPoints()) it outputs nil.
Also i don’t get the First Debug message in the console.
Mmmmk. But you’re sure you’ve included this shared file or AddCSLua’d it so it would work on the client? This is a gamemode, I presume?
Ya this is a gamemode and yes everything is included and what not.
GetPData will always return something in my experience.
getPoints on client will not work since you’re setting it serverside, network it with ([**Entity.SetNetworkedInt
You could also use **[Usermessages
Well i tried using a NWInt but it just returned 0 even though i set it to 3.
I’m thinking that the PlayerInitialSpawn hook isn’t working because im not getting that Msg and nothing is being set.
Why do you need SetPData and GetPData anyway? Those are for permanent data which is stored on the server and stays even if you disconnect and then come back.
I’m using it to make a skill system and a load out system for my gamemode. Kind of like the classes in CoD and skills that effect speed/health/Max weight of all your equipment.
Thanks for all your help you guys i managed to get it working on my dedi so all is good.