Recently I’ve developed a very simple gamemode in which players are split into two teams, one player is a runner and the rest are hunters.
The runner objective is to hold the runner title for 120 seconds, and the hunters’ objective is to kill the runner so as to become the runner.
So far things have gone fairly well, but I’ve run into a snag in which the custom scoreboard doesn’t display anyone’s score but the local player’s, which sucks.
The points system is run with Network Integers which I know nothing about, and I believe that this is where the problem lies.
This is everything in my shared.lua file
team.SetUp(0, "Hunter", Color( 50, 50, 255 ) ) team.SetUp(1, "Runner", Color( 255, 50, 50 ) ) include("cl_scoreboard.lua") local meta = FindMetaTable("Player") function GM:Initialize() self.BaseClass:Initialize(self) end function meta:GetPoints() return self:GetNWInt( "ply_points" ) end function meta:SetPoints( amt ) self:SetNWInt( "ply_points", amt ) end function meta:AddPoints( amt ) self:SetNWInt( "ply_points", self:GetPoints() + amt ) end
I only have a vague idea of what this means.
When LocalPlayer() is defined as ply and ply:GetPoints() is called in the cl_init file, all is fine.
But when in init.lua, and used in a function like this:
for k, ply in pairs( player.GetAll() ) do print( ply:Nick().. " " ..ply:GetPoints().. " ".. ply:Frags ) end
The ply:GetPoints() outputs 0 without exception, whereas the player’s name and kills display correctly.
How can I redo this so that the player’s points can be called more-or-less anywhere?
Any help would be appreciated. ~KyleTheScientist