• Reusable Jihad bomb for TTT?
    7 replies, posted
So I like doing fun rounds where I disable winning and give everyone a custom weapon like a reusable knife or an awp that has 200 bullets. But I wanted to make a custom jihad bomb. I've already taken out the ability for traitors to buy it. How do I make it so that the user does not die when using it? [CODE]AddCSLuaFile() if CLIENT then SWEP.PrintName = "Jihad Bomb" SWEP.Slot = 6 SWEP.Icon = "vgui/ttt/icon_c4" end -- Always derive from weapon_tttbase SWEP.Base = "weapon_tttbase" -- Standard GMod values SWEP.HoldType = "slam" SWEP.Primary.Ammo = "none" SWEP.Primary.Delay = 5 SWEP.Primary.ClipSize = -1 SWEP.Primary.ClipMax = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false -- Model settings SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 54 SWEP.ViewModel = "models/weapons/cstrike/c_c4.mdl" SWEP.WorldModel = "models/weapons/w_c4.mdl" --- TTT config values -- Kind specifies the category this weapon is in. Players can only carry one of -- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE. -- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8 SWEP.Kind = WEAPON_EQUIP1 -- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can -- be spawned as a random weapon. SWEP.AutoSpawnable = false -- The AmmoEnt is the ammo entity that can be picked up when carrying this gun. SWEP.AmmoEnt = "none" -- InLoadoutFor is a table of ROLE_* entries that specifies which roles should -- receive this weapon as soon as the round starts. In this case, none. SWEP.InLoadoutFor = { nil } -- If LimitedStock is true, you can only buy one per round. SWEP.LimitedStock = true -- If AllowDrop is false, players can't manually drop the gun with Q SWEP.AllowDrop = true -- If IsSilent is true, victims will not scream upon death. SWEP.IsSilent = false -- If NoSights is true, the weapon won't have ironsights SWEP.NoSights = true -- Precache custom sounds function SWEP:Precache() util.PrecacheSound( "siege/big_explosion.wav" ) util.PrecacheSound( "siege/jihad.wav" ) end -- Reload does nothing function SWEP:Reload() end -- Particle effects / Begin attack function SWEP:PrimaryAttack() self:SetNextPrimaryFire( CurTime() + 2 ) local effectdata = EffectData() effectdata:SetOrigin( self.Owner:GetPos() ) effectdata:SetNormal( self.Owner:GetPos() ) effectdata:SetMagnitude( 8 ) effectdata:SetScale( 1 ) effectdata:SetRadius( 78 ) util.Effect( "Sparks", effectdata ) self.BaseClass.ShootEffects( self ) -- The rest is done on the server if ( SERVER ) then timer.Simple( 2, function() self:Asplode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) end end -- Explosion properties function SWEP:Asplode() local k, v local ent = ents.Create( "env_explosion" ) ent:SetPos( self.Owner:GetPos() ) ent:SetOwner( self.Owner ) ent:SetKeyValue( "iMagnitude", "200" ) ent:Spawn() ent:Fire( "Explode", 0, 0 ) ent:EmitSound( "siege/big_explosion.wav", 500, 500 ) self:Remove() end -- Equipment menu information is only needed on the client if CLIENT then -- Text shown in the equip menu SWEP.EquipMenuData = { type = "Weapon", desc = "Sacrifice yourself to Allah.\n\nYour 72 virgins await." } end [/CODE]
To coderhire with that one :P
[QUOTE=Steeze;45808576]To coderhire with that one :P[/QUOTE] For something as simple as this? Why would I pay money for that?
It creates an env_explosion which causes people to die lol. You would have to use an effect like HelicopterMegaBomb instead of an actual explosion
You could use this hook: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html[/url] and then scale the damage to 0 for the user
[QUOTE=smithy285;45809191]You could use this hook: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html[/url] and then scale the damage to 0 for the user[/QUOTE] Don't link to the outdated wiki. [URL="http://wiki.garrysmod.com/page/Entity/TakeDamage"]Use the new one instead[/URL]
So how would that look in the code? I'm not very good at lua.
[QUOTE=piscaso;45809749]So how would that look in the code? I'm not very good at lua.[/QUOTE] You've been given literally everything you need. Hook this: [url]http://wiki.garrysmod.com/page/Entity/TakeDamage[/url] Use this to check for current weapon: [url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url] Use this to scale the damage: [url]http://wiki.garrysmod.com/page/GM/ScalePlayerDamage[/url] You could also use this to make sure only explosion damage is scaled, this means the player can still be killed by bullets and other damage: [url]http://wiki.garrysmod.com/page/CTakeDamageInfo/IsExplosionDamage[/url]
Sorry, you need to Log In to post a reply to this thread.