TTT Level to the TTT Scoreboard

Hello guys,

I bought from Scriptfodder the LevelUP script.
I want to show the level from the players on the TTT scoreboard.
The guy who programmed the script gived me a code but i dont understand that and he dont add me.
here is my try:

sb_main:


self:AddColumn("Level") 

(working)

sb_row:


self.cols[6] = vgui.Create("DLabel", self)
   self.cols[6]:SetText(ply.levelup.level)

(Error)


“ply.levelup.level” is the current Level from the player.

Error in Console:


[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:35: attempt to index global 'ply' (a nil value)
  1. Init - gamemodes/terrortown/gamemode/vgui/sb_row.lua:35
   2. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:153
    3. AddPlayerRow - gamemodes/terrortown/gamemode/vgui/sb_team.lua:96
     4. UpdateScoreboard - gamemodes/terrortown/gamemode/vgui/sb_main.lua:282
      5. Init - gamemodes/terrortown/gamemode/vgui/sb_main.lua:138
       6. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:153
        7. ScoreboardCreate - gamemodes/terrortown/gamemode/cl_scoreboard.lua:27
         8. unknown - gamemodes/terrortown/gamemode/cl_scoreboard.lua:34


[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:329: attempt to index field 'nick' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/vgui/sb_row.lua:329


[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:329: attempt to index field 'nick' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/vgui/sb_row.lua:329


What is the Problem?
Sorry bad English :smiley:

I don’t recall you being able to use ply in vgui creation

[editline]16th May 2015[/editline]

Try LocalPlayer() or just create a function that returns the players level, then create a console command for it. Then, simply run the console command inside the vgui creation

serverside concommand and other thing for it:


function Player:GetLevel()
return ply.levelup.level
end



function GetDaLevel( ply, cmd, args)
ply:GetLevel()
end
concommand.Add( "getplylevel", GetDaLevel  )


running the console command(put this in sb_row)


self.cols[6] = vgui.Create("DLabel", self)
local level = RunConsoleCommand( "getplylevel" )
   self.cols[6]:SetText(level)


Untested, but I think it should work.

Ply is undefined, you will have to post more code if you want us to help you. Also, A Fightr Pilot, RunConsoleCommand doesn’t return any values, so level will be nil. It is also more than possible to make use of player entities in vgui creation, otherwise how would scoreboards work.