Hello guys i create a custom swep whit you can get weapons thanks to shipments that you buy to a npc.
But a get this error when i clic the button of a derma:
[CODE][ERROR] addons/darkrpmodification/lua/weapons/shipment/init.lua:8 : attempt to call method 'getDarkRPVar' (a nil value)[/CODE]
Thanks for the help :D
Can you paste the line?
[CODE]
AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
concommand.Add("spawnship", function(self, cmd, args)
local ship = self:GetOwner():getDarkRPVar("shipement") or 0
if self:GetOwner():getDarkRPVar("money") > 100 and ship < 10 then
self:GetOwner():addMoney(-1000)
self:GetOwner():setDarkRPVar("shipement", ship + 1)
DarkRP.notify(self:GetOwner(), 0, 4, "You have buy a shipment")
elseif ship >= 10 then
DarkRP.notify(self:GetOwner(), 1, 4, "You have too mush of shipment")
else
DarkRP.notify(self:GetOwner(), 1, 4, "You don't have money")
end
end)[/CODE]
[QUOTE=DovaSummer;50610481][CODE]
AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
concommand.Add("spawnship", function(self, cmd, args)
local ship = self:GetOwner():getDarkRPVar("shipement") or 0
if self:GetOwner():getDarkRPVar("money") > 100 and ship < 10 then
self:GetOwner():addMoney(-1000)
self:GetOwner():setDarkRPVar("shipement", ship + 1)
DarkRP.notify(self:GetOwner(), 0, 4, "You have buy a shipment")
elseif ship >= 10 then
DarkRP.notify(self:GetOwner(), 1, 4, "You have too mush of shipment")
else
DarkRP.notify(self:GetOwner(), 1, 4, "You don't have money")
end
end)[/CODE][/QUOTE]
shipement is not an actual DarkRP var. Unless you created that manually.
[QUOTE=DovaSummer;50610481][CODE]
AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
concommand.Add("spawnship", function(self, cmd, args)
local ship = self:GetOwner():getDarkRPVar("shipement") or 0
if self:GetOwner():getDarkRPVar("money") > 100 and ship < 10 then
self:GetOwner():addMoney(-1000)
self:GetOwner():setDarkRPVar("shipement", ship + 1)
DarkRP.notify(self:GetOwner(), 0, 4, "You have buy a shipment")
elseif ship >= 10 then
DarkRP.notify(self:GetOwner(), 1, 4, "You have too mush of shipment")
else
DarkRP.notify(self:GetOwner(), 1, 4, "You don't have money")
end
end)[/CODE][/QUOTE]
The first arg of concommand.Add's callback is the player that ran the command.
yes i created it and how can i fix that ?
Change all instances of self:GetOwner() to self
thank you very mush :DDD
Sorry, you need to Log In to post a reply to this thread.