I'm looking for a way to change the reaload delay of all the weapons from a player using an entity.
I've tried something like:
cl_init.lua:
net.Receive("SWEP_Change_Realoaddelay", function(len)
local swepID = net.ReadInt(16)
local SWEP = Entity(swepID)
if !IsValid(SWEP) or !SWEP.ReloadDelay then return end
SWEP.ReloadDelay = (SWEP.ReloadDelay/4)
end)
init.lua:
function ENT:Use(activator, caller)
if activator:Team() ~= TEAM_HUMAN or not activator:Alive() or GAMEMODE:GetWave() <= 0 then return end
if not self:GetObjectOwner():IsValid() then
self:SetObjectOwner(activator)
end
local owner = self:GetObjectOwner()
local owneruid = owner:IsValid() and owner:UniqueID() or "nobody"
local myuid = activator:UniqueID()
if CurTime() < (NextUse[myuid] or 0) then
activator:CenterNotify(COLOR_RED, "Vous avez déjà pris cet atout")
return
end
NextUse[myuid] = CurTime() + 99999999
local SWEP = activator:GetActiveWeapon()
net.Start("SWEP_Change_Reloaddelay")
net.WriteInt(SWEP:EntIndex(), 16)
net.Send(activator)
end
If anyone as a solution for me D:
I think you can get the players weapons and ammunition into a table, strip weapons, then give back all of his weapons and ammunition.
Player/GetWeapons returns a table of weapons, not an entity.
Maybe instead of :GetWeapons() use :GetActiveWeapon()
Sorry, you need to Log In to post a reply to this thread.