Attempting to do a pointshop for my community but I seem to be stuck.
So, I am loading the files here:
[code]--Need to load all the files and shit.
local filename1 = "sh_pointshop.lua"
local filename2 = "sh_player_extension.lua"
local filename3 = "cl_player_extension.lua"
local filename4 = "cl_pointshop.lua"
local filename5 = "sv_player_extension.lua"
local filename6 = "sv_pointshop.lua"
if SERVER then
print("Loading Server Pointshop Files.....")
AddCSLuaFile()
AddCSLuaFile(filename1)
PrintMessage(1, "(SERVERSIDE) AddingCSLuaFile '".. filename1 .. "'")
AddCSLuaFile(filename2)
PrintMessage(1, "(SERVERSIDE) AddingCSLuaFile '".. filename2 .. "'")
AddCSLuaFile(filename3)
PrintMessage(1, "(SERVERSIDE) AddingCSLuaFile '".. filename3 .. "'")
AddCSLuaFile(filename4)
PrintMessage(1, "(SERVERSIDE) AddingCSLuaFile '".. filename4 .. "'")
include(filename1)
PrintMessage(1, "(SERVERSIDE) Including '".. filename1 .. "'")
include(filename2)
PrintMessage(1, "(SERVERSIDE) Including '".. filename2 .. "'")
include(filename5)
PrintMessage(1, "(SERVERSIDE) Including '".. filename5 .. "'")
include(filename6)
PrintMessage(1, "(SERVERSIDE) Including '".. filename6 .. "'")
end
if CLIENT then
print("Loading Client Pointshop Files.....")
include(filename1)
print("(CLIENTSIDE) Including '".. filename1 .. "'")
include(filename2)
print("(CLIENTSIDE) Including '".. filename2 .. "'")
include(filename3)
print("(CLIENTSIDE) Including '".. filename3 .. "'")
include(filename4)
print("(CLIENTSIDE) Including '".. filename4 .. "'")
end
[/code]
Console reads them here:
[code]
Loading Server Pointshop Files.....
(SERVERSIDE) AddingCSLuaFile 'sh_pointshop.lua'
(SERVERSIDE) AddingCSLuaFile 'sh_player_extension.lua'
(SERVERSIDE) AddingCSLuaFile 'cl_player_extension.lua'
(SERVERSIDE) AddingCSLuaFile 'cl_pointshop.lua'
(SERVERSIDE) Including 'sh_pointshop.lua'
(SERVERSIDE) Including 'sh_player_extension.lua'
(SERVERSIDE) Including 'sv_player_extension.lua'
(SERVERSIDE) Including 'sv_pointshop.lua'
Loading Client Pointshop Files.....
(CLIENTSIDE) Including 'sh_pointshop.lua'
(CLIENTSIDE) Including 'sh_player_extension.lua'
(CLIENTSIDE) Including 'cl_player_extension.lua'
(CLIENTSIDE) Including 'cl_pointshop.lua'
[/code]
I do my functions here
[code]
local Player = FindMetaTable('Player')
-- points
function Player:GivePoints(points)
self:SetNWInt("points",self:GetNWInt("points") + points)
end
function Player:TakePoints(points)
self:SetNWInt("points", self:GetNWInt("points") - points)
self:SetPData("points", self:GetPData("points") - points)
end
function Player:SetPoints(points)
self:SetNWInt("points", points)
self:SetPData("points", points)
end
function Player:GetPoints()
return self:GetNWInt("points")
end
function Player:PS_HasPoints(points)
return self:GetPoints() >= points
end
[/code]
But in-game when testing the custom functions using "lua_run_cl print("Points: ".. LocalPlayer():GetPoints())", it returns
[code]
[ERROR] LuaCmd:1: attempt to call method 'GetPoints' (a nil value)
1. unknown - LuaCmd:1
[/code]
Help?
[editline]31st May 2014[/editline]
Nvm, I was loading them in a serverside file :V
Sorry, you need to Log In to post a reply to this thread.