Hello. I am working on an SCP-RP server, and I have created a number of SWeaps.
All of them say "Scripted Weapon" and do not work.
I will show one of them, and it is located in (Server)/garrysmod/addons/scp/lua/weapons/hands
here is the cl_init.lua located under the directory mentioned above.
[CODE]
-----------------------------------------------------
include("shared.lua")
SWEP.Category = "SCP"
SWEP.PrintName = "Hands"
SWEP.Author = "zoidBergh"
SWEP.Contact = "zoidBergh"
SWEP.Instructions = "Right click to knock."
SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
function SWEP:SecondaryAttack() return end
function SWEP:PrimaryAttack() return end
[/CODE]
and here is the shared.lua:
[CODE]
-----------------------------------------------------
SWEP.WorldModel = ""
SWEP.HoldType = "normal"
SWEP.Spawnable = true
SWEP.canDrop = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
function SWEP:Deploy()
self.Owner:DrawViewModel(false)
end
function SWEP:Initialize()
self:SetHoldType("normal")
end
[/CODE]
As you can see, this sweap is pretty simple, however I have some others that are structured and formatted the same, but still get the same error as this one.
I do not get any kind of errors, so any help in realizing the problem would be great!
Give this guide on the Garry's Mod Wiki a look, it shows you how to make a simple SWEP; [url]https://wiki.garrysmod.com/page/Chair_Throwing_Gun[/url]
But to actually answer your question, your SWEP variables need to be defined in a shared file (shared.lua), instead you are only defining them in a client file (cl_init.lua)
As you could see, the cl_init.lua did reference the shared.lua, and I combined the two files to no avail.
You need to also send the client the code:
[url]http://wiki.garrysmod.com/page/Global/AddCSLuaFile[/url]
I literally done what I told you to do, and it works fine.
I created a file called weapon_scp_hands.lua in the follow directory; lua/weapons
[thumb] http://i.imgur.com/Omdvsid.jpg [/thumb]
My exact code is this;
[code]
AddCSLuaFile()
SWEP.PrintName = "Hands"
SWEP.Category = "SCP"
SWEP.Author = "zoidBergh"
SWEP.Contact = "zoidBergh"
SWEP.Instructions = "Right click to knock."
SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel = ""
SWEP.HoldType = "normal"
SWEP.Spawnable = true
SWEP.canDrop = false
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
function SWEP:SecondaryAttack()
return
end
function SWEP:PrimaryAttack()
return
end
function SWEP:Deploy()
self.Owner:DrawViewModel( false )
end
function SWEP:Initialize()
self:SetHoldType( "normal" )
end
[/code]
Again, please refer to the wiki next time
Sorry, you need to Log In to post a reply to this thread.