Hier mal das Lua Script
Der unten deaktivierte Teil
Code:
if change == false then
SWEP.WorldModel = "models/weapons/w_kampflanze.mdl"
else
SWEP.WorldModel = "models/weapons/w_kampflanze2.mdl"
end
macht das Problem. Ich vermute anhand der Fehlermeldung das man "Global" Variablen anscheinend nicht einfach wieder ändern kann.
Code:
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "ar2"
end
local change = false
if ( CLIENT ) then
SWEP.PrintName = "Forcelance"
SWEP.Author = "Dunkelbier"
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.Description = "The Forcelance from the Scifi-Series Andromeda"
SWEP.Purpose = ""
SWEP.Instructions = "Primary fire: Shoot / Fight \n\nSecondary Fire: Toggle Close combat / distance attack"
end
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_kampflanze.mdl"
SWEP.WorldModel = "models/weapons/w_kampflanze.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Recoil = 2
SWEP.Primary.Damage = 0
SWEP.Primary.NumShots = 0
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 45
SWEP.Primary.Delay = 0.2
SWEP.Primary.DefaultClip = 900
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "ar2"
SWEP.Secondary.Delay = 1
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
/*---------------------------------------------------------
Primary Attack
---------------------------------------------------------*/
local Right = 3.5
local Forward = 14
local Up = -3.2
local Up2 = -3
local mode = 1
local pang = false
util.PrecacheSound("weapons/V_kampflanze/fire.wav")
util.PrecacheSound("weapons/V_kampflanze/reload.wav")
util.PrecacheSound("common/bugreporter_succeeded.wav")
util.PrecacheSound("npc/turret_floor/ping.wav")
function SWEP:Init()
mode = 1
self.Weapon:SetNetworkedBool( "mode1", true )
return true;
end
function SWEP:Think()
-- if change == false then
-- SWEP.WorldModel = "models/weapons/w_kampflanze.mdl"
-- else
-- SWEP.WorldModel = "models/weapons/w_kampflanze2.mdl"
--end
end
function SWEP:PrimaryAttack()
if (SERVER) then
local trace = self.Owner:GetEyeTrace()
if self.Weapon:Clip1() > 0 then
self:TakePrimaryAmmo( 1 )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Weapon:EmitSound("weapons/V_kampflanze/fire.wav")
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetEntity( trace.Entity )
effectdata:SetAttachment( trace.PhysicsBone )
util.Effect( "selection_indicator", effectdata )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Owner:GetShootPos() )
effectdata:SetAttachment( 1 )
effectdata:SetEntity( self.Weapon )
util.Effect( "ToolTracer", effectdata )
local delay = 0.2
self.Weapon:SetNextPrimaryFire(CurTime() + delay)
bullet = {}
bullet.Num=1
bullet.Src= self.Owner:GetShootPos()
bullet.Dir= self.Owner:GetAimVector()
bullet.Spread=Vector(0,0,0)
bullet.Tracer=1
bullet.Force=10
bullet.Damage= 10
self.Owner:FireBullets(bullet)
end
end
end
function SWEP:SecondaryAttack()
if change == false then
game.ConsoleCommand("cam_command 1\n")
game.ConsoleCommand("cam_idealyaw 0\n")
game.ConsoleCommand("cam_idealpitch 15\n")
self.Primary.Automatic = false
self.Weapon:SetNetworkedBool( "change", true )
change = true
else
game.ConsoleCommand("cam_command 2\n")
game.ConsoleCommand("cam_idealyaw 90\n")
game.ConsoleCommand("cam_idealpitch 0\n")
self.Primary.Automatic = true
self.Weapon:SetNetworkedBool( "change", false )
change = false
end
end
function SWEP:Deploy()
-- self.Owner:EmitSound("laser/dep.wav")
game.ConsoleCommand("cam_command 2\n")
game.ConsoleCommand("cam_idealyaw 90\n")
game.ConsoleCommand("cam_idealpitch 0\n")
return true;
end
function SWEP:Holster()
-- self.Owner:EmitSound("laser/holster.wav")
game.ConsoleCommand("cam_command 2\n")
game.ConsoleCommand("cam_idealyaw 90\n")
game.ConsoleCommand("cam_idealpitch 0\n")
return true;
end
function SWEP:Reload()
if change == false then
self.Weapon:DefaultReload( ACT_VM_RELOAD );
if self.Weapon:Clip1() < 45 and self:Ammo1() > 0 then
self.Weapon:EmitSound("weapons/V_kampflanze/reload.wav")
end
end
end