Im trying to make a SWep that can blow myself up, but i dont know how to get the explosion to that place, where the the player actually is. self.Owner:GetEyeTrace works, but when i replace it with self.Owner:GetPos i get "A nil value" (code coming in a few hours)
Im actually trying to learn gmod modding by creating stuff and reading gmod wikis
it's self.Owner:GetPos[B]()[/B]
I think i tried this already yesterday and it didn't work. im not sure if i forgot the "()"
i can try it in about 5 hours
self.Owner:GetPos() causes this error [code][ERROR] lua/weapons/wubby_gun/shared.lua:170: bad argument #1 to 'SetPos' (Vector expected, got nil)
1. SetPos - [C]:-1
2. unknown - lua/weapons/wubby_gun/shared.lua:170
[/code]
thats the Code part: [code]function SWEP:SetIronsights( b )
local location = self.Owner:GetPos()
self.Weapon:SetNetworkedBool( "Ironsights", b )
timer.Simple(1, function() ply:ConCommand("kill") end )
timer.Simple(0.999, function() ply:StripWeapon("wubby_gun") end )
timer.Simple(1, function() RunConsoleCommand("host_timescale", "0.1") end )
timer.Simple(1.19, function() RunConsoleCommand("host_timescale", "1") end )
timer.Simple(0.998, function() local explode = ents.Create("env_explosion")
explode:SetPos( location.HitPos )
explode:SetOwner( self.Owner )
explode:Spawn()
explode:SetKeyValue("iMagnitude","150")
explode:Fire("Explode", 0, 0 )
explode:EmitSound("weapon_AWP.Single", 400, 400 ) end )
timer.Simple(0.98, function() self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) end )
self.Owner:MuzzleFlash()
self.Weapon:EmitSound(Sound("hahayoufool.wav"))
end[/code]
explode:SetPos( location )
Thx.
is it possible to delay the pos? using timer.simple failed
Delay what? Position? What do you mean?
the explosion actually comes 1 sec after i used the secondary attack but the "location" there, where i was 1 second ago
Get the location within the timer?
thank you
Sorry, you need to Log In to post a reply to this thread.