Hi,
I seem to be facing quite a conundrum with my custom ammunition types I am creating. I am utilizing FAS:2 as my ammunition reference, and most of the ammo I have scripted in does work, but a select few do not.
I will post a few excerpts from my code -
This is a [I]working[/I] shared.lua file
[CODE]ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "7.62x51 NATO"
ENT.Author = "Luna"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.Category = "S.T.A.L.K.E.R. RP Ammo"
ENT.AmmoType = "7.62x51nato"
ENT.Amount = 30[/CODE]
This is also working, an init.lua file.
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/stalker/ammo/762x51.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetCollisionGroup(COLLISION_GROUP_NONE)
local phys = self:GetPhysicsObject()
if phys and phys:IsValid() then
phys:Wake()
end
end
function ENT:OnTakeDamage(dmginfo)
self:GetPhysicsObject():AddVelocity(dmginfo:GetDamageForce() * 0.1)
end
function ENT:Use(activator, caller)
if activator:IsPlayer() then
activator:GiveAmmo(self.Amount, self.AmmoType)
self:Remove()
end
end
function ENT:OnRemove()
return false
end [/CODE]
And the cl_init.lua for one of the working ammo types.
[CODE]include("shared.lua")
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
end
function ENT:Think()
end [/CODE]
And now, the non-working one(s).
[CODE]ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "7.62x54mmR"
ENT.Author = "Luna"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.Category = "S.T.A.L.K.E.R. Ammo"
ENT.AmmoType = "7.62x54"
ENT.Amount = 30[/CODE]
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/models/stalker/ammo/762x54.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetCollisionGroup(COLLISION_GROUP_NONE)
local phys = self:GetPhysicsObject()
if phys and phys:IsValid() then
phys:Wake()
end
end
function ENT:OnTakeDamage(dmginfo)
self:GetPhysicsObject():AddVelocity(dmginfo:GetDamageForce() * 0.1)
end
function ENT:Use(activator, caller)
if activator:IsPlayer() then
activator:GiveAmmo(self.Amount, self.AmmoType)
self:Remove()
end
end
function ENT:OnRemove()
return false
end [/CODE]
[CODE]include("shared.lua")
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
end
function ENT:Think()
end [/CODE]
Thanks to anyone who may be of assistance.
Sorry, you need to Log In to post a reply to this thread.