so all the files are inside the same folder and i dosen't get reported any other problems.
GetValue() is inside smartvar.lua
and then Getvalue() is used in those functions SkillGetLevel(), SkillGetXP and SkillRequired(). inside skill.lua
and when i call them from cl_init.lua it's a nil value :(
just ask if you need more information, i really hope someone can fix this..
ERROR:
[code]
[ERROR] gamemodes/xxx/gamemode/skills.lua:12: attempt to call method 'GetValue' (a nil value)
[/code]
init.lua
[lua]
include( 'smartvar.lua' )
include( 'skills.lua' )
include( 'shared.lua' )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "smartvar.lua" )
AddCSLuaFile( "skills.lua" )
[/lua]
cl_init.lua
[lua]
include( 'shared.lua' )
include( 'smartvar.lua' )
include( 'skills.lua' )
function DrawBox()
local struc = {}
struc.pos = {}
struc.pos[1] = 100
struc.pos[2] = 200
struc.color = Color(255,0,0,255)
struc.text = "Hello World"
struc.font = "DefaultFixed"
struc.xalign = TEXT_ALIGN_CENTER
struc.yalign = TEXT_ALIGN_CENTER
struc.text = "Shooting Lvl: "..SkillGetLevel(player, "Shooting").." XP: "..SkillGetXp(player, "Shooting")
draw.Text( struc )
end
local function PlayerAuthed( player )
hook.Add("HUDPaint", "DrawBox", DrawBox)
end
concommand.Add("PlayerAuthed", PlayerAuthed)
[/lua]
smartvar.lua
[lua]
local meta = FindMetaTable("Player")
local cl_table = { }
function meta:GetValue(name)
if(SERVER)then
return self.Var[name]
else
return cl_table[name]
end
end
[/lua]
skill.lua
[lua]
function SkillRequired(player, skill, level)
if player:GetValue(skill.."_LEVEL") >= level then return true end
return false
end
function SkillGetLevel(player, skill) return player:GetValue(skill.."_LEVEL") end
function SkillGetXp(player, skill) return player:GetValue(skill.."_XP") end
[/lua]
Is there any earlier messages that you can see? Can be hard when you're running it in HUD code so you may want to run "lua_log_cl 1" before going onto the server/creating a game and setting it back to 0 after spawning in. Then you can look in the garrysmod/garrysmod directory for something like lua_errors_client.txt or something like that.
[QUOTE=grunewald;44057858]
[lua]
struc.text = "Shooting Lvl: "..SkillGetLevel(player, "Shooting").." XP: "..SkillGetXp(player,
[/lua][/QUOTE]
you aren't defining player as anything besides the global table. replace with LocalPlayer()
[QUOTE=MeepDarknessM;44058594]you aren't defining player as anything besides the global table. replace with LocalPlayer()[/QUOTE]
HAHAHA yea holy shit i din't even notice that! :P
so i added
[lua]
local player = LocalPlayer()
struc.text = "Shooting Lvl: "..SkillGetLevel(player, "Shooting").." XP: "..SkillGetXp(player, "Shooting")
[/lua]
i most have been staring my self blind
Sorry, you need to Log In to post a reply to this thread.