So i’ve been working on some nextbots an came across a thread wich showed how to give them a weapon entity. I used self.Weapon:GetMaxClip1() to get the weapons clip and make them reload, however there is no function to obtain other stats such as the Primary.Sound/Numshots/Damage/etc. I took a look at the weapon info system on the workshop wich displays the stats of any weapon, however this was done client side.
It used something similar to this
ent = weapon -- ent wich is the weapon the player is looking at
weaponinfo.dmg = weapon.Primary.Damage
weaponinfo.dly = weapon.Primary.Delay
and so on. However this doesn’t seem to work on server (I guess), as I tried to do
weaponinfo.dmg = wep.Primary.Damage -- wep is the weapon entity given to the bot
--or
weaponinfo.dmg = (self.Weapon).Primary.Damage -- Same thing
and only got
attempt to index field 'Primary' (a nil value)
So does anybody have any idea of how to get the stats of a wepon serverside???
Here is the snip of code…
function ENT:GiveWeapon(wep)
if SERVER then
local wep = ents.Create(wep)
local pos = self:GetAttachment(self:LookupAttachment("anim_attachment_RH")).Pos
wep:SetOwner(self)
wep:SetPos(pos)
wep:Spawn()
wep:SetSolid(SOLID_NONE)
wep:SetParent(self)
wep:Fire("setparentattachment", "anim_attachment_RH")
wep:AddEffects(EF_BONEMERGE)
self.Weapon = wep
self.magmaxammo = self.Weapon:GetMaxClip1() --where I got the clip size
print(self.Weapon) -- prints Weapon [185][weapon_smg1] it prints any weapon I give it tho
print(wep) -- prints Weapon [185][weapon_smg1] it prints any weapon I give it tho
end
end
I could get away with copying the stats on the shoot/firebullet function, but the point is that the bot can shoot any weapon I exchange with them…