Hi,
so im messing around a bit in gmod and lua with a basic gamemode. Problem is now that the SWEP i want to add is not registered [QUOTE]Attempted to create unknown entity weapon_ctfflag[/QUOTE]. I dont really understand why because an entity which i created works flawlessly.
[LUA]if(SERVER) then
AddCSLuaFile()
end
SWEP.HoldType = "melee"
if CLIENT then
SWEP.PrintName = "Flag"
SWEP.Slot = 1
end
SWEP.Base = "weapon_base"
SWEP.Primary.Damage = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel = "models/weapons/w_crowbar.mdl"
function SWEP:Initialize()
util.PrecacheModel(self.ViewModel)
util.PrecacheModel(self.WorldModel)
self:SetWeaponHoldType(self.HoldType)
end
function SWEP:ShouldDropOnDie()
return false
end
function SWEP:OnDrop()
self:Remove()
end
function SWEP:Reload()
end
function SWEP:Think()
end
function SWEP:PrimaryAttack()
return
end
function SWEP:SecondaryAttack()
return
end
function SWEP:CanPrimaryAttack()
return false
end
function SWEP:CanSecondaryAttack()
return false
end[/LUA]
Can you post where you put the file and its name?
[code]
if(SERVER) then
AddCSLuaFile()
end
SWEP.HoldType = "melee"
if CLIENT then
SWEP.PrintName = "Flag"
SWEP.Slot = 1
end[/code]
Unrelated, but you can just get rid of the IF-s here, they are worthless.
[CODE]C:\Game Server\gmod\garrysmod\gamemodes\ctf\entities\weapons[/CODE] file name is [CODE]weapon_ctfflag.lua[/CODE]
Is the gamemode actully getting loaded?
try and move the folder to the lua directory.
yea gamemode is running fine apart from the weapon file being loaded.
Edit: i tested the script in [CODE]lua/weapons[/CODE] and it works just fine.
Edit 2: Im not sure but i think you have to restart the server or something to load new entities or atleast weapons. It works now.
Sorry, you need to Log In to post a reply to this thread.