Setting hold type depending on a var the owner has.

For example: Setting weapons holdtype depending on the owners class. Since owner doesn’t yet exist on :Initialize() i cant get the class of the person who picked up the weapon and setting it on :Deploy() doesn’t work either. Any solutions?

If im not mistaken it has the owner a frame later, So just run a timer.simple( 0 , Your Function) and lemme know what comes up. At work so I dont have access to any of my scripts that Ive done this with for other reasons, (such as getting ammo, vars, etc)

Timer did the trick, thanks.

Don’t use a timer.Simple. Do a simple check in SWEP:Think like:

[lua]
function SWEP:Think()
if self.Owner and self.Owner.Variable and self.Owner.Variable = 1 then
self:SetHoldType(HOLDTYPE_ONE)
else
self:SetHoldType(HOLDTYPE_TWO)
end
end
[/lua]

Why? Its not like he needs to check this constantly. Just when the player pulls out the weapon.

If the gun is removed, the timer won’t be.

We’ll you can’t. If its on a swep i usually check if the player is valid and the player is the same one that started the timer… So not a big problem there.

if self.Owner == nil then return false end

in the timer simple, It works just like it would a think function, just without the spam repeats and errors of a timer.

Yeah, but if the person who started the timer dies and another player manages to pick it up before the timer runs out its gonna error out, so you also need to specify if its the same user. In any case, its not a problem.

They’d have to be fast if they where to do that in 1 frame.

:smiley: Yeah… I was sorta talking about timers with more delay.