Hello, recently I have been trying to add combustible lemons to my ttt server as a traitor weapon only but when i apply it in and a traitor tries to use it, they end up having infinite ammo. The ammo counter does not change from 01-00 and stays there as the player throws infinite grenades.
Here is the code I have used and tinkered with a little:
[CODE]if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight= 5
SWEP.AutoSwitchTo= false
SWEP.AutoSwitchFrom= false
resource.AddFile( "materials/lemnade/lemnade.png" )
end
if ( CLIENT ) then
SWEP.PrintName = "Lemon Grenade"
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.DrawAmmo= false
SWEP.DrawCrosshair= false
end
SWEP.Author = "The One Free-Man,Thermadyle,Biohazard,fixed by Hds46"
SWEP.Contact= ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.Category = "Toybox Sweps"
SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.ViewModel = "models/weapons/v_lemnade.mdl"
SWEP.ViewModelFOV = 55
SWEP.ViewModelFlip = false
SWEP.WorldModel = "models/weapons/w_grenade.mdl"
SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = 1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.LastSpoke = 0
SWEP.LastLemon = 0
SWEP.IsThrowing = true
SWEP.IconLetter = "x"
SWEP.WepSelectIcon = Material("lemnade/lemnade.png")
SWEP.BounceWeaponIcon = false
function SWEP:Reload() end
function SWEP:Think() end
function SWEP:Initialize()
self:SetWeaponHoldType( "grenade" )
end
function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
// Set us up the texture
surface.SetDrawColor(255, 255, 255, alpha)
surface.SetMaterial( self.WepSelectIcon )
// Lets get a sin wave to make it bounce
local fsin = 0
if (self.BounceWeaponIcon == true) then
fsin = math.sin(CurTime() * 10) * 5
end
// Borders
//y = y + 25
//x = x + 25
wide = wide - 45
// Draw that mother
//surface.DrawTexturedRect(x + (fsin), y - (fsin), wide - fsin * 2, (wide / 2) + (fsin))
surface.DrawTexturedRect( x + 25, y , 128, 100 )
// Draw weapon info box
self:PrintWeaponInfo(x + wide + 20, y + tall * 0.95, alpha)
end
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 2.6)
self:SendWeaponAnim( ACT_VM_PULLBACK_HIGH )
self:GetOwner():ViewPunch( Angle( -1, -1, 0 ) * 4 )
if self.LastLemon < CurTime() then self:EmitSound( "lemongrenade/COMBUSTABLE-.wav" ) end
self.LastSpoke = CurTime() + 1
timer.Simple( 1, function()
self:SendWeaponAnim( ACT_VM_THROW )
if self.LastLemon < CurTime() then self:EmitSound( "lemongrenade/-LEMON.wav" ) end
self.LastSpoke = CurTime() + 1.0
self:GetOwner():ViewPunch( Angle( 1, 1, 0 ) * 10 )
timer.Simple( .1, function()
if CLIENT then return end
self:EmitSound( "weapons/iceaxe/iceaxe_swing1.wav" )
local forw = self:GetOwner():EyeAngles():Forward()
local lemon = ents.Create( "lemon_grenade" )
lemon:SetPos( self:GetOwner():GetShootPos() + forw * 20 )
lemon:Spawn()
lemon:GetPhysicsObject():SetVelocity( forw * 1400 )
self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
end )
timer.Simple( .5, function() if IsValid( self ) then self:Deploy() end end )
end )
end
function SWEP:SecondaryAttack()
if self.LastSpoke < CurTime() then
self.LastSpoke = CurTime() + 3
self.LastLemon = CurTime() + 3
self:EmitSound( "lemongrenade/lemongrenade_0" .. math.random( 1, 5 ) .. ".wav" )
end
end
function SWEP:Deploy()
if IsValid( self ) then
self:SendWeaponAnim( ACT_VM_DRAW )
self.Weapon:SetNextPrimaryFire(CurTime() + 1.0)
end
end
// GRENADE ENTITY
// Fixed by Hds46
local Grenade = {}
Grenade.Type = "anim"
Grenade.Base = "base_anim"
if SERVER then
function Grenade:Initialize()
self:SetModel( "models/houseburning/houseburning.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
end
function Grenade:PhysicsCollide( tabl, obj )
if self.Exploded then return end
self.Exploded = true
self:EmitSound( "ambient/fire/mtov_flame2.wav" )
self:SetMoveType( MOVETYPE_NONE )
self:SetColor( Color( 0, 0, 0, 0 ) )
self:SetMaterial( "models/effects/vol_light001" )
self:DrawShadow( false )
for _,b in pairs ( ents.FindInSphere(self:GetPos(),1) ) do
if b:GetClass() == "env_sprite" and b:GetName() == "Hds46_addon_lemonade_lemsprite" then
b:Remove()
end
end
local BOOM = EffectData()
BOOM:SetScale( 4 )
local BurnedBodies = {
"models/Humans/Charple01.mdl",
"models/Humans/Charple02.mdl",
"models/Humans/Charple03.mdl",
"models/Humans/Charple04.mdl"
}
local Block = {
"npc_turret_floor",
"npc_rollermine",
"npc_cscanner",
"npc_hunter",
"npc_manhack",
"npc_vortigaunt",
"npc_antlionguard",
"npc_headcrab",
"npc_headcrab_black",
"npc_headcrab_fast",
"npc_antlion_worker",
"npc_antlion",
"npc_dog"
}
local val = 120
local rep = 10
for i = 1, rep do
timer.Simple( .1 * i, function()
if self:IsValid() then
for i = 1, 3 do
BOOM:SetOrigin( self:GetPos() + Vector( math.random( -val, val ), math.random( -val, val ), math.random( -val / 3, val / 3 ) ) )
util.Effect( "HelicopterMegaBomb", BOOM )
end
local i = math.random( 1, 2 )
if ( i == 1 ) then
self:EmitSound( "ambient/fire/ignite.wav" )
elseif ( i == 2 ) then
self:EmitSound( "ambient/fire/gascan_ignite1.wav" )
else
end
for _, ent in pairs( ents.FindInSphere( self:GetPos(), val * 1.9 ) ) do
if ( ent:IsPlayer() or ent:IsNPC() or ent:GetClass() == "prop_ragdoll" ) and not table.HasValue( Block, ent:GetClass() ) then
ent:TakeDamage( math.random( 5, 15 ) )
if ent:GetClass() == "prop_ragdoll" then
local physExplo = ents.Create( "env_physexplosion" )
physExplo:SetPos( self:GetPos() )
physExplo:SetKeyValue( "Magnitude", "45" ) -- Power of the Physicsexplosion
physExplo:SetKeyValue( "radius", "300" ) -- Radius of the explosion
physExplo:SetKeyValue( "targetentityname", "prop_ragdoll" )
physExplo:SetKeyValue( "spawnflags", "0" )
physExplo:Spawn()
physExplo:Fire( "Explode", "", 0.02 )
physExplo:Fire( "Kill", "", 0.03 )
end
elseif table.HasValue( Block,
I'd suggest changing
[lua]SWEP.DrawAmmo= false[/lua]
to
[lua]SWEP.DrawAmmo= true[/lua]
Its a complete guess but worth a try! :)
[quote]SWEP.DrawAmmo= false[/quote]
..... surely you mean:
[code]SWEP.DrawAmmo = false[/code]
......?
[QUOTE=Roag15;43864131]..... surely you mean:
[code]SWEP.DrawAmmo = false[/code]
......?[/QUOTE]
It didn't work D:
Since he wasn't getting Lua errors I'm sure that it wouldn't matter too much and that it would still have the same effect.
I think the issue is that the SWEP was never designed to HAVE ammo.
[QUOTE=BFG9000;43871638]I think the issue is that the SWEP was never designed to HAVE ammo.[/QUOTE]
I'm not quite sure that's it because i could have sworn seeing a server or two with this mod or a similar mod :\
They can have the same type of swep, but they probably coded in such a feature.
I was looking in your primaryattack, and I notice at any time it doesn't actually "remove" it from the player, try doing that?
Just add:
[lua]self:Remove()[/lua]
[QUOTE=Nookyava;43874714]They can have the same type of swep, but they probably coded in such a feature.
I was looking in your primaryattack, and I notice at any time it doesn't actually "remove" it from the player, try doing that?
Just add:
[lua]self:Remove()[/lua][/QUOTE]
Hey i placed it but where should i because when i did edit, it just kicks me out of the server with a lua error.
This is the error.
[CODE][ERROR] addons/lemonade swep/lua/weapons/weapon_lemnade/shared.lua:94: Tried to
use a NULL entity!
1. SendWeaponAnim - [C]:-1
2. unknown - addons/lemonade swep/lua/weapons/weapon_lemnade/shared.lua:94
Timer Failed! [Simple][@addons/lemonade swep/lua/weapons/weapon_lemnade/shared.l
ua (line 92)]
Unknown command "sv_tags"[/CODE]
Sorry, you need to Log In to post a reply to this thread.