Hey, so complete noob here, i've basically just been fooling around with the skeleton game mode and the weapon
anywho, i changed the default pistol example weapon to automatic and this made it shoot way too fast, so i tried adding some local variables (PDelay and Delay)
PDelay should control the length between the shots and Delay is used as the timer
anyway when i try to spawn the weapon ingame the console says it dosent exist, so i assume it's just because of some super obvious noob error i made
i know i COULD probably just change it to a smg or something
theres probably even some internal delay variable i could alter, but i am hoping to do it this way to i learn more about lua, so please don't tell me to do it another way
[CODE]AddCSLuaFile( "shared.lua" )
SWEP.Author = ""
SWEP.Contact = ""
SWEP.Purpose = "Shooter"
SWEP.Instructions = "Shoot stuff"
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"
SWEP.AnimPrefix = "python"
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
local PDelay= 1.7
local Delay = 0
SWEP.Primary.ClipSize = 80 // Size of a clip
SWEP.Primary.DefaultClip = 320 // Default number of bullets in a clip
SWEP.Primary.Automatic = true // Automatic/Semi Auto
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = 8 // Size of a clip
SWEP.Secondary.DefaultClip = 32 // Default number of bullets in a clip
SWEP.Secondary.Automatic = false // Automatic/Semi Auto
SWEP.Secondary.Ammo = "Pistol"
/*---------------------------------------------------------
Initialize
---------------------------------------------------------*/
function SWEP:Initialize()
end
/*---------------------------------------------------------
Reload
---------------------------------------------------------*/
function SWEP:Reload()
self:DefaultReload( ACT_VM_RELOAD );
end
/*---------------------------------------------------------
Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
if (Delay >=0)
then
Delay-=0.1
end
end
/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
if (Delay==0) then
// Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end
// Play shoot sound
self:EmitSound("Weapon_AR2.Single")
// Shoot 9 bullets, 150 damage, 0.01 aimcone
self:ShootBullet( 150, 1, 0 )
// Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )
Delay=PDelay
end
end
/*---------------------------------------------------------
SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()
// Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end
// Play shoot sound
self:EmitSound("Weapon_Shotgun.Single")
// Shoot 9 bullets, 150 damage, 0.25 aimcone
self:ShootBullet( 150, 9, 0.05 )
// Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
// Punch the player's view
self.Owner:ViewPunch( Angle( -2, 0, 0 ) )
end[/CODE]
SWEP.Spawnable should equal true
No because his gamemode gives it to him
[QUOTE=Willox;24540154]No because his gamemode gives it to him[/QUOTE]
He says he's trying to spawn the weapon... So no it's not being given to him
True
well the game mode was giving it to me, i should have been clearer, i was trying to make it spawn at the start of the game mode
anyway, i figured out what was wrong with it
Delay-=0.1
=
Delay=Delay-0.1
which is kinda stupid if you ask me
Sorry, you need to Log In to post a reply to this thread.