i cant get it to keep supplying ammo on the timer line 48 it says that self is a nil value
Code:
[lua]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local amount = 0
function ENT:Initialize()
self:SetModel("models/items/ammocrate_rockets.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self.Entity:SetUseType( SIMPLE_USE )
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
timer.Simple(120, self.SupplyStart, self)
local owner = self:GetDTEntity(0)
amount = math.random(3,30)
Notify(owner, 0, 10, "You will get an initial 2mins of " .. amount .." reloads, after that it ranges from 30-180s, 3-30 reloads")
end
local supply = 0
local function SupplyMore(ent)
if ValidEntity(ent) then
ent.SupplyStart(self)
supply = 0
end
end
function ENT:Use(activator, caller)
if(activator.IsPlayer() and amount != 0) then
if supply == amount then
Notify(activator, 0, 4, "The supply demand has been met")
else
local wep = activator:GetActiveWeapon()
if(wep:IsWeapon()) then
supply = supply + 1
activator:GiveAmmo(20, wep:GetPrimaryAmmoType() )
else
Notify(activator,0,4,"You must be holding the weapon you want to get ammo for")
end
end
end
end
function ENT:SupplyStart(self)
amount = math.random(3,30)
local timertime = math.random(30,360)
timer.Create("MainTimer",timertime,0, SupplyMore, self)
Notify(self:GetDTEntity(0), 0,10, "You can now supply " ..amount .." reloads, for the next " ..timertime .."s")
end
[/lua]
Thanks in advance :D
also want it to be phys gun blocked and grav only :D
Quick suggestion: would it be self.Entity, rather than simply self?
It would be self.Entity, i tried self myself and it didn't work, then i tried self.Entity and it worked a charm
Sorry, you need to Log In to post a reply to this thread.