--============================================================================
function IHellGunStatic:OnPrecache()
    Cache:PrecacheActor("HellGun.CWeapon")
end
--============================================================================
function IHellGunStatic:OnInitTemplate()
    self._Synchronize = self.Synchronize
    self.Synchronize = nil
end
--============================================================================
function IHellGunStatic:OnCreateEntity()
    ENTITY.EnableNetworkSynchronization(self._Entity,true,true)

    local param  = "h"
    if self.Ammo.Bolt > self.Ammo.Grenades then param = "k" end
    ENTITY.SetSynchroString(self._Entity,"IHellGunStatic.CItem"..":"..param)            
    
end
--============================================================================
function IHellGunStatic:Client_OnCreateEntity(entity,param)
    local e = ENTITY.Create(ETypes.Billboard,"Script","IHellGunStatic")    
    
    BILLBOARD.SetupCorona(e,1,0,0,0,0,0.25,0,0,0,tex,Color:New(255,255,255,0):Compose(),4,true)    
    ENTITY.SetPosition(e,-0.6,0.8,0)
    ENTITY.RegisterChild(entity,e,true,0) 
    WORLD.AddEntity(e)
end
--============================================================================
function IHellGunStatic:OnTake(player)     
    if Game.GMode == GModes.SingleGame or not (Cfg.WeaponsStay and player.EnabledWeapons[self.SlotIndex]) then 
        self.TakeFX(player._Entity,self.Ammo.Bolt,self.Ammo.Grenades)
    end
    if Game.GMode ~= GModes.SingleGame and Cfg.WeaponsStay then return true end
end
--============================================================================
function IHellGunStatic:TakeFX(pe,aBolt,aGrenades)
    local player = EntityToObject[pe]    
    local t = Templates["IHellGunStatic.CItem"]
    if player then        
        player.EnabledWeapons[t.SlotIndex] = "HellGun"
        player.Ammo.Bolt = player.Ammo.Bolt + aBolt
        player.Ammo.Grenades = player.Ammo.Grenades + aGrenades
        player:CheckMaxAmmo()
        if player == Player then 
            player:Client_OnTakeWeapon(t.SlotIndex)
            player:PickupFX() 
        end
    end
    
    t:SndEnt("pickup",pe)
end
Network:RegisterMethod("IHellGunStatic.TakeFX", NCallOn.ServerAndAllClients, NMode.Reliable, "euu")
--============================================================================
