• My weapon is floating??
    12 replies, posted
Where ever the cross hair is, that's where it is, it won't fall... I already changed [code] local phys = self:GetPhysicsObject() if IsValid(phys) then phys:Mass(200) end[/code] To [code] local phys = self:GetPhysicsObject() if IsValid(phys) then phys:wake() end[/code] It didn't work Entity File [lua]---- Health dispenser if SERVER then AddCSLuaFile("shared.lua") end if CLIENT then -- this entity can be DNA-sampled so we need some display info ENT.Icon = "VGUI/ttt/icon_health" ENT.PrintName = "hstation_name" local GetPTranslation = LANG.GetParamTranslation ENT.TargetIDHint = { name = "hstation_name", hint = "hstation_hint", fmt = function(ent, txt) return GetPTranslation(txt, { usekey = Key("+use", "USE"), num = ent:GetStoredHealth() or 0 } ) end }; end ENT.Type = "anim" ENT.Model = Model("models/props/cs_office/microwave.mdl") --ENT.CanUseKey = true ENT.CanHavePrints = true ENT.MaxHeal = 25 ENT.MaxStored = 200 ENT.RechargeRate = 1 ENT.RechargeFreq = 2 -- in seconds ENT.NextHeal = 0 ENT.HealRate = 1 ENT.HealFreq = 0.2 AccessorFuncDT(ENT, "StoredHealth", "StoredHealth") AccessorFunc(ENT, "Placer", "Placer") function ENT:SetupDataTables() self:DTVar("Int", 0, "StoredHealth") end function ENT:Initialize() self:SetModel(self.Model) self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_BBOX) local b = 32 self:SetCollisionBounds(Vector(-b, -b, -b), Vector(b,b,b)) self:SetCollisionGroup(COLLISION_GROUP_WEAPON) if SERVER then self:SetMaxHealth(200) local phys = self:GetPhysicsObject() if IsValid(phys) then phys:wake() end self:SetUseType(CONTINUOUS_USE) end self:SetHealth(200) self:SetColor(Color(180, 180, 250, 255)) self:SetStoredHealth(200) self:SetPlacer(nil) self.NextHeal = 0 self.fingerprints = {} end function ENT:AddToStorage(amount) self:SetStoredHealth(math.min(self.MaxStored, self:GetStoredHealth() + amount)) end function ENT:TakeFromStorage(amount) -- if we only have 5 healthpts in store, that is the amount we heal amount = math.min(amount, self:GetStoredHealth()) self:SetStoredHealth(math.max(0, self:GetStoredHealth() - amount)) return amount end local healsound = Sound("items/medshot4.wav") local failsound = Sound("items/medshotno1.wav") local last_sound_time = 0 function ENT:GiveHealth(ply, max_heal) if self:GetStoredHealth() > 0 then max_heal = max_heal or self.MaxHeal local dmg = ply:GetMaxHealth() - ply:Health() if dmg > 0 then -- constant clamping, no risks local healed = self:TakeFromStorage(math.min(max_heal, dmg)) local new = math.min(ply:GetMaxHealth(), ply:Health() + healed) ply:SetHealth(new) if last_sound_time + 2 < CurTime() then self:EmitSound(healsound) last_sound_time = CurTime() end if not table.HasValue(self.fingerprints, ply) then table.insert(self.fingerprints, ply) end return true else self:EmitSound(failsound) end else self:EmitSound(failsound) end return false end function ENT:Use(ply) if IsValid(ply) and ply:IsPlayer() and ply:IsActive() then local t = CurTime() if t > self.NextHeal then local healed = self:GiveHealth(ply, self.HealRate) self.NextHeal = t + (self.HealFreq * (healed and 1 or 2)) end end end -- traditional equipment destruction effects function ENT:OnTakeDamage(dmginfo) if dmginfo:GetAttacker() == self:GetPlacer() then return end self:TakePhysicsDamage(dmginfo) self:SetHealth(self:Health() - dmginfo:GetDamage()) local att = dmginfo:GetAttacker() if IsPlayer(att) then DamageLog(Format("%s damaged health station for %d dmg", att:Nick(), dmginfo:GetDamage())) end if self:Health() < 0 then self:Remove() util.EquipmentDestroyed(self:GetPos()) if IsValid(self:GetPlacer()) then LANG.Msg(self:GetPlacer(), "hstation_broken") end end end if SERVER then -- recharge local nextcharge = 0 function ENT:Think() if nextcharge < CurTime() then self:AddToStorage(self.RechargeRate) nextcharge = CurTime() + self.RechargeFreq end end end[/lua] Weapon file [lua]if SERVER then AddCSLuaFile( "shared.lua" ) end SWEP.HoldType = "normal" if CLIENT then SWEP.PrintName = "hstation_name" SWEP.Slot = 6 SWEP.ViewModelFOV = 10 SWEP.EquipMenuData = { type = "item_weapon", desc = "hstation_desc" }; SWEP.Icon = "VGUI/ttt/icon_health" end SWEP.Base = "weapon_tttbase" SWEP.ViewModel = "models/weapons/v_crowbar.mdl" SWEP.WorldModel = "models/props/cs_office/microwave.mdl" SWEP.DrawCrosshair = false SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "none" SWEP.Primary.Delay = 1.0 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = true SWEP.Secondary.Ammo = "none" SWEP.Secondary.Delay = 1.0 -- This is special equipment SWEP.Kind = WEAPON_EQUIP SWEP.CanBuy = {ROLE_DETECTIVE} -- only detectives can buy SWEP.LimitedStock = true -- only buyable once SWEP.WeaponID = AMMO_HEALTHSTATION SWEP.AllowDrop = false SWEP.NoSights = true function SWEP:OnDrop() self:Remove() end function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:HealthDrop() end function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) self:HealthDrop() end local throwsound = Sound( "Weapon_SLAM.SatchelThrow" ) -- ye olde droppe code function SWEP:HealthDrop() if SERVER then local ply = self.Owner if not IsValid(ply) then return end if self.Planted then return end local vsrc = ply:GetShootPos() local vang = ply:GetAimVector() local vvel = ply:GetVelocity() local vthrow = vvel + vang * 200 local health = ents.Create("ttt_health_station") if IsValid(health) then health:SetPos(vsrc + vang * 10) health:Spawn() health:SetPlacer(ply) health:PhysWake() local phys = health:GetPhysicsObject() if IsValid(phys) then phys:SetVelocity(vthrow) end self:Remove() self.Planted = true end end self.Weapon:EmitSound(throwsound) end function SWEP:Reload() return false end function SWEP:OnRemove() if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then RunConsoleCommand("lastinv") end end if CLIENT then function SWEP:Initialize() self:AddHUDHelp("hstation_help", nil, true) return self.BaseClass.Initialize(self) end end function SWEP:Deploy() if SERVER and IsValid(self.Owner) then self.Owner:DrawViewModel(false) end return true end function SWEP:DrawWorldModel() end function SWEP:DrawWorldModelTranslucent() end[/lua]
Is this when it is spawned? Does it do it with all weapons?
[QUOTE=siranderson66;41867205]Is this when it is spawned? Does it do it with all weapons?[/QUOTE] Yes when it's spawned, and no just my Pain station and Health station
What is the model? cs_office/microwave?
[QUOTE=siranderson66;41867240]What is the model? cs_office/microwave?[/QUOTE] The model for the Stations..
Ok, check you have Counter-Strike: Source installed on the server, missing models can cause this.
[QUOTE=siranderson66;41867259]Ok, check you have Counter-Strike: Source installed on the server, missing models can cause this.[/QUOTE] It's not missing models, my cs:s is installed and mounted correctly.
Any LUA errors upon spawning?
[QUOTE=siranderson66;41867288]Any LUA errors upon spawning?[/QUOTE] Non, the SWEP(s) work perfectly fine other than planting where ever the cross hair is.. I thought it was the phys:Mass( 200 ) but i changed it to phys:wake() and it didn't work, so I'm kind of confused.
Change [CODE]phys:wake()[/CODE] to [CODE]phys:Wake()[/CODE]
[QUOTE=siranderson66;41867324]Change [CODE]phys:wake()[/CODE] to [CODE]phys:Wake()[/CODE][/QUOTE] Just changed, didn't realize I made it lowercase, seeing if it works. Edit: Still is not working.
It's too late for me to have a proper look at this for you, its 5AM here, hopefully someone else can help you in the meantime.
[QUOTE=siranderson66;41867402]It's too late for me to have a proper look at this for you, its 5AM here, hopefully someone else can help you in the meantime.[/QUOTE] Well, thanks for trying... I really would like to have this fixed.
Sorry, you need to Log In to post a reply to this thread.