Hey, so i have armor shipments,but i want the armor entiety to when picked up give the maximum armor that my caracter starts with,and not a setup amount like (example 100).
my player spawns with 150 armor because he is vip,i cant make 150 armor shipments for everyone,so how do i make armor entiety go get me full armor instead of a value?
You can override SetArmor and create a SetMaxArmor function to check if the player's armor will exceed the desired amount.
[QUOTE=code_gs;48534109]You can override SetArmor and create a SetMaxArmor function to check if the player's armor will exceed the desired amount.[/QUOTE]
was like this:function ENT:Use(plyUse)
self:Remove()
plyUse:SetArmor(100)
end
now like this:
function ENT:Use(plyUse)
self:Remove()
plyUse:SetMaxArmor
end
Now i just cant pick it,it dont work
No, I meant to remake the SetArmor function to have a cap. It will require you to override it.
[QUOTE=code_gs;48534359]No, I meant to remake the SetArmor function to have a cap. It will require you to override it.[/QUOTE]
can you reply with the fix please,if this is it i think
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function ENT:Initialize()
self.Entity:SetModel("models/combine_vests/bogvest.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
self.nodupe = true
self.ShareGravgun = true
if phys and phys:IsValid() then phys:Wake() end
self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
end
function ENT:SpawnFunction(ply, tr)
if (!tr.Hit) then
return end
local SpawnPos = tr.HitPos + tr.HitNormal
local ent = ents.Create("Heavy Kevlar Armor")
ent:SetPos(SpawnPos)
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Use(plyUse)
self:Remove()
plyUse:SetArmor(100)
end
function ENT:OnRemove()
self:Remove()
end
[code]local _R = debug.getregistry()
local _SetArmor = _R.Player.SetArmor
local _R.Player.m_iMaxArmor = 150
AccessorFunc( _R.Player, "m_iMaxArmor", "MaxArmor", FORCE_NUMBER )
function _R.Player:SetArmor( iArmor )
_SetArmor( math.min( self:GetMaxArmor(), self:GetArmor + iArmor ) )
end[/code]
Run that serverside.
[QUOTE=code_gs;48534549][code]local _R = debug.getregistry()
local _SetArmor = _R.Player.SetArmor
local _R.Player.m_iMaxArmor = 150
AccessorFunc( _R.Player, "m_iMaxArmor", "MaxArmor", FORCE_NUMBER )
function _R.Player:SetArmor( iArmor )
_SetArmor( math.min( self:GetMaxArmor(), self:GetArmor + iArmor ) )
end[/code]
Run that serverside.[/QUOTE]
If you mean like this:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function ENT:Initialize()
self.Entity:SetModel("models/combine_vests/bogvest.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
self.nodupe = true
self.ShareGravgun = true
if phys and phys:IsValid() then phys:Wake() end
self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
end
function ENT:SpawnFunction(ply, tr)
if (!tr.Hit) then
return end
local SpawnPos = tr.HitPos + tr.HitNormal
local _R = debug.getregistry()
local _SetArmor = _R.Player.SetArmor
local _R.Player.m_iMaxArmor = 150
AccessorFunc( _R.Player, "m_iMaxArmor", "MaxArmor", FORCE_NUMBER )
function _R.Player:SetArmor( iArmor )
_SetArmor( math.min( self:GetMaxArmor(), self:GetArmor + iArmor ) )
end
still cant pick it up
No, in a separate serverside file, not in the ent file.
Sorry, you need to Log In to post a reply to this thread.