TTT Jihad Issue

Shared.lua of the weapon_jihadbomb


// Variables that are used on both client and server
 
SWEP.Author         = "Stingwraith"
SWEP.Contact        = "stingwraith123@yahoo.com"
SWEP.Purpose        = "Sacrifice yourself for Allah."
SWEP.Instructions   = "Left Click to make yourself EXPLODE. Right click to taunt."
SWEP.DrawCrosshair      = false
 
SWEP.Spawnable          = true
SWEP.AdminSpawnable     = true      // Spawnable in singleplayer or by server admins
 
SWEP.ViewModel          = "models/weapons/v_jb.mdl"
SWEP.WorldModel         = "models/weapons/w_jb.mdl"
 
 
SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = false
SWEP.Primary.Ammo           = "none"
SWEP.Primary.Delay          = 3
 
SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = false
SWEP.Secondary.Ammo         = "none"
 
/*---------------------------------------------------------
    Reload does nothing
---------------------------------------------------------*/
function SWEP:Reload()
end  
 
function SWEP:Initialize()
    util.PrecacheSound("siege/big_explosion.wav")
    util.PrecacheSound("siege/jihad.wav")
end
 
 
/*---------------------------------------------------------
   Think does nothing
---------------------------------------------------------*/
function SWEP:Think()   
end
 
 
/*---------------------------------------------------------
    PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 3)
 
     
    local effectdata = EffectData()
        effectdata:SetOrigin( self.Owner:GetPos() )
        effectdata:SetNormal( self.Owner:GetPos() )
        effectdata:SetMagnitude( 8 )
        effectdata:SetScale( 1 )
        effectdata:SetRadius( 16 )
    util.Effect( "Sparks", effectdata )
     
    self.BaseClass.ShootEffects( self )
     
     
    // The rest is only done on the server
    if (SERVER) then
        timer.Simple(2, function() self:Asplode() end )
        self.Owner:EmitSound( "siege/jihad.wav" )
    end
 
end
 
--The asplode function
function SWEP:Asplode()
local k, v
     
    // Make an explosion at your position
    local ent = ents.Create( "env_explosion" )
        ent:SetPos( self.Owner:GetPos() )
        ent:SetOwner( self.Owner )
        ent:Spawn()
        ent:SetKeyValue( "iMagnitude", "250" )
        ent:Fire( "Explode", 0, 0 )
        ent:EmitSound( "siege/big_explosion.wav", 500, 500 )
         
        self.Owner:Kill( )
        self.Owner:AddFrags( -1 )
  
        for k, v in pairs( player.GetAll( ) ) do
          v:ConCommand( "play siege/big_explosion.wav
" )
        end
 
end
 
 
/*---------------------------------------------------------
    SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack() 
     
    self.Weapon:SetNextSecondaryFire( CurTime() + 1 )
     
    local TauntSound = Sound( "vo/npc/male01/overhere01.wav" )
 
    self.Weapon:EmitSound( TauntSound )
     
    // The rest is only done on the server
    if (!SERVER) then return end
     
    self.Weapon:EmitSound( TauntSound )
 
 
end

I also added the weapon to the traitor menu through the shared.lua in the “terrortown” folder. I just need some help on figuring out what’s going wrong with it, it’s not even showing up in the T menu, at all.

Well, this is not set up for TTT. This code makes the weapon spawn randomly on the map.

Take a look at this guide, and make it compatible for TTT

Almost done scripted jihad, but it float in the air and can be used all the time:

if CLIENT then
SWEP.PrintName = “Jihad”
SWEP.Slot = 6

SWEP.EquipMenuData = {
type = “item_weapon”,
name = “Jihad”,
desc = “JEEHAADD”
};

SWEP.Icon = “VGUI/ttt/icon_jihad”
end

if SERVER then
resource.AddFile(“materials/VGUI/ttt/icon_jihad.vmt”)
end
SWEP.Base = “weapon_tttbase”

SWEP.Kind = WEAPON_EQUIP1
SWEP.CanBuy = {ROLE_TRAITOR} – only traitors can buy
SWEP.AutoSpawnable = false

SWEP.DrawCrosshair = false

SWEP.Spawnable = true
SWEP.AdminSpawnable = false // Spawnable in singleplayer or by server admins

SWEP.ViewModel = “models/weapons/v_jb.mdl”
SWEP.WorldModel = “models/weapons/w_jb.mdl”

SWEP.AllowDrop = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”
SWEP.Primary.Delay = 3

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

/---------------------------------------------------------
Reload does nothing
---------------------------------------------------------
/
function SWEP:Reload()
end

function SWEP:Initialize()
util.PrecacheSound(“siege/big_explosion.wav”)
util.PrecacheSound(“siege/jihad.wav”)
end

/---------------------------------------------------------
Think does nothing
---------------------------------------------------------
/
function SWEP:Think()
end

/---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------
/
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 3)

local effectdata = EffectData()
	effectdata:SetOrigin( self.Owner:GetPos() )
	effectdata:SetNormal( self.Owner:GetPos() )
	effectdata:SetMagnitude( 8 )
	effectdata:SetScale( 1 )
	effectdata:SetRadius( 16 )
util.Effect( "Sparks", effectdata )

self.BaseClass.ShootEffects( self )


// The rest is only done on the server
if (SERVER) then
	timer.Simple(2, function() self:Asplode() end )
	self.Owner:EmitSound( "siege/jihad.wav" )
end

end

–The asplode function
function SWEP:Asplode()
local k, v

// Make an explosion at your position
local ent = ents.Create( "env_explosion" )
	ent:SetPos( self.Owner:GetPos() )
	ent:SetOwner( self.Owner )
	ent:Spawn()
	ent:SetKeyValue( "iMagnitude", "250" )
	ent:Fire( "Explode", 0, 0 )
	ent:EmitSound( "siege/big_explosion.wav", 500, 500 )
	
	self.Owner:Kill( )

	for k, v in pairs( player.GetAll( ) ) do
	  v:ConCommand( "play siege/big_explosion.wav

" )
end

end

/---------------------------------------------------------
SecondaryAttack
---------------------------------------------------------
/
function SWEP:SecondaryAttack()

self.Weapon:SetNextSecondaryFire( CurTime() + 1 )

local TauntSound = Sound( "vo/npc/male01/overhere01.wav" )

self.Weapon:EmitSound( TauntSound )

// The rest is only done on the server
if (!SERVER) then return end

self.Weapon:EmitSound( TauntSound )

end

I just have a problem with them floating after being dropped or used. Can you find out what the problem with that is?

As the manager of a server that has a jihad tailored for TTT use, my recommendation is either learn Lua or find a guy who knows Lua to help. It’s never a good idea to download random crap without knowing how to use it properly.

Here’s a stripped down version of my server’s Jihad’s shared.lua:

[lua]

if SERVER then
AddCSLuaFile( “shared.lua” )
end

if CLIENT then
SWEP.PrintName = “Jihad Bomb”
SWEP.Slot = 6

SWEP.EquipMenuData = {
type = “item_weapon”,
name = “Jihad Bomb”,
desc = “Left Click to blow yourself up!”
};

SWEP.Icon = “VGUI/ttt/icon_jihad”
end

SWEP.ViewModelFlip = false
SWEP.AllowDrop = false
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.LimitedStock = true

SWEP.Base = “weapon_tttbase”

// Variables that are used on both client and server

SWEP.DrawCrosshair = false

SWEP.ViewModel = “models/weapons/v_jb.mdl”
SWEP.WorldModel = “models/weapons/w_jb.mdl”

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”
SWEP.Primary.Delay = 3

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

SWEP.Exploding = false

/---------------------------------------------------------
Reload does nothing
---------------------------------------------------------
/
function SWEP:Reload()
end

function SWEP:Initialize()
util.PrecacheSound(“weapons/jihad/big_explosion.wav”)
util.PrecacheSound(“weapons/jihad/jihad.wav”)
end

function SWEP:OnDrop()
self:Remove()
end

function SWEP:Holster()
if self.Exploding then return false end
end

/---------------------------------------------------------
Think does nothing
---------------------------------------------------------
/
function SWEP:Think()
end

/---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------
/
function SWEP:PrimaryAttack()
self.Weapon:SetNextSecondaryFire(CurTime() + 3)
self.Weapon:SetNextPrimaryFire(CurTime() + 3)
self.Exploding = true

local effectdata = EffectData()
	effectdata:SetOrigin( self.Owner:GetPos() )
	effectdata:SetNormal( self.Owner:GetPos() )
	effectdata:SetMagnitude( 8 )
	effectdata:SetScale( 1 )
	effectdata:SetRadius( 16 )
util.Effect( "Sparks", effectdata )

self.BaseClass.ShootEffects( self )


// The rest is only done on the server
if (SERVER) then
      self.Owner:EmitSound("weapons/jihad/jihad.wav")
      end

end

–The asplode function
function SWEP:Asplode()
local k, v

// Make an explosion at your position
local ent = ents.Create( "env_explosion" )
	ent:SetPos( self.Owner:GetPos() )
	ent:SetOwner( self.Owner )
	ent:Spawn()
	ent:SetKeyValue( "iMagnitude", "250" )
	ent:Fire( "Explode", 0, 0 )
	ent:EmitSound( "weapons/jihad/big_explosion.wav", 500, 500 )
	
	self.Owner:Kill( )
	//self.Owner:AddFrags( -1 )

	for k, v in pairs( player.GetAll( ) ) do
	  v:ConCommand( "play weapons/jihad/big_explosion.wav

" )
end

end
[/lua]

It might produce a few errors, 'cause my server’s Jihad Bomb does a few extra things that I’m not gonna give out for free so I cut out some of the code, but here you go anyway.

It cannot be dropped, so the Traitor is forced to use it after they buy it (this is to prevent innocents from getting a weapon that’s used to clear out an entire room in one blast, so they don’t lose a fuckload of karma in one round). Also, when the traitor is killed and the weapon drops automatically, it gets removed from existence, so it’s a one-use weapon. The Jihad can be “defused” by killing the traitor before it goes off, but that’s just part of the standard Jihad bomb anyway.

Make sure to add in the secondary attack to Vladmirs script too

The secondary attack is just a function that plays that “Hey over here!” clip. I removed it from mine 'cause I added a much better secondary fire. :smiley: