• Need help adding an individual lightsaber with Rubat's Lightsaber addon
    4 replies, posted
I'm not completely alien to adding SWEPs on Gmod but alien as a motherfucker with Glua. I want to add a lightsaber (using rb655's addon as a base) with its settings set in stone and unchangeable (The length, width, color, model bla bla bla are set by code and not the spawnmenu). My current code : (I tried to use this guide as reference) AddCSLuaFile() if ( SERVER ) then util.AddNetworkString( "rb655_holdtype" ) resource.AddWorkshop( "111412589" ) CreateConVar( "rb655_lightsaber_infinite", "0" ) end SWEP.PrintName = "Force Pike" SWEP.Author = "Robotboy655" SWEP.Category = "Robotboy655's Weapons" SWEP.Purpose = "To slice off each others limbs and heads." SWEP.Instructions = "Protect the emperor at all costs." SWEP.RenderGroup = RENDERGROUP_BOTH SWEP.Slot = 0 SWEP.SlotPos = 4 SWEP.Spawnable = true SWEP.DrawAmmo = false SWEP.DrawCrosshair = false SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.DrawWeaponInfoBox = false SWEP.ViewModel = "models/weapons/v_crowbar.mdl" SWEP.WorldModel = "models/pike/pike.mdl" SWEP.ViewModelFOV = 55 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 = true SWEP.Secondary.Ammo = "none" SWEP.IsLightsaber = true SWEP.Base = "weapon_lightsaber"
https://files.facepunch.com/forum/upload/1804/dad805ca-d0a3-4d23-8efe-26dfb9ece9f2/image.png if ( SERVER ) then util.AddNetworkString( "rb655_holdtype" ) resource.AddWorkshop( "111412589" ) CreateConVar( "rb655_lightsaber_infinite", "0" ) end You should delete this from your code
Maybe I lied when I knew how to do SWEPs (I only know how to edit their stats :V) I pasted this and deleted the code block. local ply = Entity( 1 ) -- This is your player object local wep = ply:Give( "weapon_lightsaber" ) if ( !IsValid( wep ) ) then return end -- The player already has the weapon wep.WeaponSynched = true -- Prevent the weapon from loading settings from the Sandbox tool wep:SetMaxLength( 420 ) -- Blade length wep:SetCrystalColor( Vector( 255, 0, 0 ) ) -- Blade color - must be a Vector, not a Color wep:SetDarkInner( false ) -- Whether the blade inner part is dark or not wep:SetWorldModel( "models/pike/pike.mdl" ) -- The full model path wep:SetBladeWidth( 20 ) -- Blade width wep.LoopSound = "lightsaber/saber_loop" .. math.random( 1, 8 ) .. ".wav" -- Hum sound, full paths wep.SwingSound = "lightsaber/saber_swing" .. math.random( 1, 2 ) .. ".wav" -- Swing sound wep:SetOnSound( "lightsaber/saber_on" .. math.random( 1, 4 ) .. ".wav" ) -- On sound wep:SetOffSound( "lightsaber/saber_off" .. math.random( 1, 4 ) .. ".wav" ) -- Off sound -- These are optional wep:SetForce( 150 ) -- Starting Amount of Force. Will autoregen to GetMaxForce(). wep:SetWorksUnderwater( false ) -- Default = true, if set to false, will auto disable upon entering water wep:SetMaxForce( 150 ) -- Sets the maximum force amount. Default is 100. wep.HitSound = "lightsaber/saber_hit.wav" -- Overrides the looping wall hit sound It gives me an error telling me it doesn't know what to do with the Give method.
I am not here to write code for you, if you do not know how to code, either hire someone who does, or learn to do it yourself.
That's fine, you have a busy life. If anyone wants to solve this (imo simple) problem, they get 10 schmekels.
Sorry, you need to Log In to post a reply to this thread.