im kinda new to the lua scripting and need a little help on a scoreboard
i got this addon
[url]http://www.garrysmod.org/downloads/?a=view&id=97699[/url]
and wanting make the points veiwable on the scoreboard
I tried my self but i failed at it with this code
[CODE]
function GM:AddScoreboardPoints( ScoreBoard )
local f = function( ply ) return PointMod.Points () end
ScoreBoard:AddColumn( "Points", 50, f, 0.5, nil, 6, 6 )
end[/CODE]
wtf?
local f = a function? and you didn't use that function anywhere?
why don't you do it without the local f and put somethin g in to fill in the points column?
got no idea what to change it to
i tried function GM:AddScoreboardPoints( ScoreBoard )
function( ply ) return ply.Points = ply:GetPData( "Points" ) end
ScoreBoard:AddColumn( "Points", 50, f, 0.5, nil, 6, 6 )
no good doesnt even show up on scoreboard
Copy-pasting things without trying to understand them and changing a few things is generally a bad idea.
Why would you write this:
[lua]return ply.Points = ply:GetPData( "Points" )[/lua]
I am not sure if Lua returns anything when referencing, but even if it did, it would return a bool.
If the mentioned point-shop actually stores the players points with ply:SetPData("Points", someNumber), the above code would still error, seeing as it is not meant for clientside. [URL="http://wiki.garrysmod.com/?title=Player.GetPData"]Read up on it.[/URL]
That said, you can either use usermessages to sync the data to the client, or networked vars. NWVars would be probably be easier in this case.
Sorry, you need to Log In to post a reply to this thread.