• SWEP:OnDrop() is not triggered :/
    4 replies, posted
My OnDrop is not triggered when i drop my weapon, i really don't know why... If someone has an idea it would be great ! SWEP.HoldType = "pistol" SWEP.ViewModelFOV = 70 SWEP.ViewModelFlip = false SWEP.UseHands = false SWEP.ViewModel = "models/weapons/v_toolgun.mdl" SWEP.WorldModel = "models/weapons/w_toolgun.mdl" SWEP.ShowViewModel = true SWEP.ShowWorldModel = true SWEP.ViewModelBoneMods = {} SWEP.Category = "Ricky's weapons" SWEP.Spawnable = true SWEP.AdminOnly = true function SWEP:PrimaryAttack()   if not IsFirstTimePredicted() then return end end function SWEP:SecondaryAttack()   if not IsFirstTimePredicted() then return end end function SWEP:Reload() end function SWEP:OnDrop() Msg("I like to drop stuff!")   print("dropped") end function ResetMaterial( ply )   ply:GetViewModel():SetSubMaterial(1, nil) end function ApplyBlackScreen( ply )   ply:GetViewModel():SetSubMaterial(1, "models/rendertarget")   timer.Simple(0.1, function()  ply:GetActiveWeapon():SetSubMaterial(1, "models/rendertarget") end) end hook.Add("PlayerSwitchWeapon", "PlayerSwitchWeapon", function(ply,old,new)   if old:GetClass() == "weapon_cmdgun" then     ResetMaterial( ply )   end   if new:GetClass() == "weapon_cmdgun" then     ApplyBlackScreen( ply )   end end) function SWEP:Initialize()   ApplyBlackScreen( self.Owner ) self:SetHoldType(self.HoldType) end
Yeah as mentioned on the official wiki, SWEP:OnDrop is serverside only, where as LocalPlayer() is a clientside only function. http://wiki.garrysmod.com/page/WEAPON/OnDrop http://wiki.garrysmod.com/page/Global/LocalPlayer
I don't see any "this function is called serverside" where should i look for it ? (OnDrop) Anyway thanks Rubbat for the answer
The colored circles and squares next to function names denote their realm. Green = menu state only, blue = serverside, orange = clientside, blue/orange = shared. It's also at the breadcrumb at the bottom of each page, you'll see "Server/Client/Shared/Menu Hooks/Functions"
Oh fck, thanks a lot i'm pretty new into the wiki, i never noticed that! I started lua about 1 month ago ^^'
Sorry, you need to Log In to post a reply to this thread.