Okay i was just wondering if you could help me out. The weapon is held in pistol hold type but i want it to be held in "Ar2" hold type.
The swepholdtype is on ar2 too so i can't think what the problem is..
Here is the code, can you please tell me what is wrong?
[lua]--[[
Name: "shared.lua".
Product: "Cider (Roleplay)".
--]]
if (SERVER) then
AddCSLuaFile("shared.lua");
else
SWEP.DrawAmmo = true;
SWEP.DrawCrosshair = false;
SWEP.ViewModelFlip = true;
SWEP.CSMuzzleFlashes = true;
SWEP.CustomCrosshair = true;
SWEP.Slot = 3;
SWEP.SlotPos = 1;
SWEP.IconLetter = "b";
SWEP.DrawWeaponInfoBox = true;
end;
-- Set the base and category.
SWEP.Base = "rg_base";
SWEP.Category = "Cider";
-- Set some shared information.
SWEP.PrintName = "AK47";
SWEP.Author = "********";
SWEP.Purpose = "A very powerful rifle which is great at long range.";
SWEP.Instructions = "Primary Fire: Shoot.\nUse + Secondary Fire: Change the fire mode.";
SWEP.Spawnable = false;
SWEP.AdminSpawnable = false;
SWEP.Weight = 5;
SWEP.AutoSwitchTo = false;
SWEP.AutoSwitchFrom = false;
SWEP.HoldType = "ar2";
SWEP.FiresUnderwater = false;
SWEP.HasLaser = false;
SWEP.HasSilencer = false;
SWEP.CanPenetrate = true;
SWEP.CanPenetrateWorld = true;
SWEP.BulletTracer = 1;
-- Set some information for the primary fire.
SWEP.Primary.Sound = Sound("Weapon_AK47.Single");
SWEP.Primary.Damage = 12.5;
SWEP.Primary.NumShots = 1;
SWEP.Primary.ClipSize = 25;
SWEP.Primary.DefaultClip = 25;
SWEP.Primary.Ammo = "smg1";
-- Set some information for the secondary fire.
SWEP.Secondary.ClipSize = -1;
SWEP.Secondary.DefaultClip = -1;
-- Set some information about the recoil and spray.
SWEP.RecoverTime = 0.75;
SWEP.MinSpread = 0.01;
SWEP.MaxSpread = 0.08;
SWEP.DeltaSpread = 0.01;
SWEP.MinRecoil = 1;
SWEP.MaxRecoil = 5;
SWEP.DeltaRecoil = 1;
SWEP.MinSpray = 0;
SWEP.MaxSpray = 2;
SWEP.DeltaSpray = 0.25;
-- Set some information about the iron sights.
SWEP.IronSightsPos = Vector(6.0837, -6.4072, 2.2469);
SWEP.IronSightsAng = Vector(3.0801, -0.1343, -0.1968);
SWEP.IronSightZoom = 1;
SWEP.UseScope = false;
SWEP.ScopeScale = 0.4;
SWEP.ScopeZooms = {4, 8};
SWEP.DrawSniperSights = false;
SWEP.DrawRifleSights = false;
-- Set some information about the model and visual effects.
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl";
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl";
SWEP.MuzzleEffect = "rg_muzzle_highcal";
SWEP.ShellEffect = "rg_shelleject_rifle";
SWEP.MuzzleAttachment = "1";
SWEP.ShellEjectAttachment = "2";
-- Set some modifier information.
SWEP.CrouchModifier = 0.7;
SWEP.IronSightModifier = 0.4;
SWEP.RunModifier = 1.5;
SWEP.JumpModifier = 2;
-- Set some information about the available fire modes and RPM.
SWEP.AvailableFireModes = {"Auto", "Semi"};
SWEP.AutoRPM = 600;
SWEP.SemiRPM = 500;[/lua]
Put this, in your code.
[code]
function SWEP:Initialize()
self:SetWeaponHoldType("ar2")
end
[/code]
It makes the player hold the gun, like a ar2.
[QUOTE=Leakerify;33388543]Put this, in your code.
[code]
function SWEP:Initialize()
self:SetWeaponHoldType("ar2")
end
[/code]
It makes the player hold the gun, like a ar2.[/QUOTE]
Yeah, I did add that in the code, but i got spammed with loads of errors, the gun wouldn't fire etc..
Is there any particular place it needs to go? or just anywhere..
Just saw, you are using a base.
Try removing
[code]
--[[
Name: "shared.lua".
Product: "Cider (Roleplay)".
--]]
[/code]
Tell me, if it worked.
If it doesnt - Copy the Initialize from your base and put self:SetWeaponHoldType("ar2") in.
Another method would be to just use 'SWEP.HoldType' like the wiki says.
Holdtypes are defined in all bases anyways.
[QUOTE=Leakerify;33388843]Just saw, you are using a base.
Try removing
[code]
--[[
Name: "shared.lua".
Product: "Cider (Roleplay)".
--]]
[/code]
Tell me, if it worked.
If it doesnt - Copy the Initialize from your base and put self:SetWeaponHoldType("ar2") in.
Another method would be to just use 'SWEP.HoldType' like the wiki says.
Holdtypes are defined in all bases anyways.[/QUOTE]
Okay thanks for the help mate, I'll try this tomorrow as i have to go now.
Here's an easier way.
[lua]
function SWEP:Initialize()
self:SetWeaponHoldType("self.HoldType")
end
[/lua]
Put this in the weapons base, then the HoldTypes will automatically translate from the SWEP.HoldType that you already have set in your weapons..
[QUOTE=Leakerify;33388843]Just saw, you are using a base.
Try removing
[code]
--[[
Name: "shared.lua".
Product: "Cider (Roleplay)".
--]]
[/code]
Tell me, if it worked.
If it doesnt - Copy the Initialize from your base and put self:SetWeaponHoldType("ar2") in.
Another method would be to just use 'SWEP.HoldType' like the wiki says.
Holdtypes are defined in all bases anyways.[/QUOTE]
that doesn't do shit it's commented out it's not even parsed lol
[QUOTE=Archemyde;33389798]Here's an easier way.
[lua]
function SWEP:Initialize()
self:SetWeaponHoldType("self.HoldType")
end
[/lua]
Put this in the weapons base, then the HoldTypes will automatically translate from the SWEP.HoldType that you already have set in your weapons..[/QUOTE]
that's wrong too, it's
[code]
self:SetWeaponHoldType( self.HoldType );
[/code]
jesus people stop posting on things if you don't know what you're doing.
The problem is probably something broken in RG_Base, open the RG_Base weapon and make sure the default SWEP.HoldType is shared, and check the initialise function. or better yet just post the whole base.
Okay here is the rg_Base (Shared.lua)
[lua]if SERVER then
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end
SWEP.Author = "Teta_Bonita"
SWEP.Contact = ""
SWEP.Purpose = "To crush your enemies."
SWEP.Instructions = "Aim away from face."
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.Primary.Sound = Sound("Weapon_TMP.Single")
SWEP.Primary.Damage = 40
SWEP.Primary.NumShots = 1
SWEP.AutoRPM = 200
SWEP.SemiRPM = 200
SWEP.BurstRPM = 200
SWEP.MuzzleVelocity = 1000
SWEP.AvailableFireModes = {}
SWEP.FiresUnderwater = false
SWEP.HasSilencer = false
SWEP.IsHolster = true
SWEP.CanPenetrate = false
SWEP.CanPenetrateWorld = false
SWEP.BulletTracer = 1
SWEP.MuzzleEffect = "rg_muzzle_pistol"
SWEP.ShellEjectEffect = "rg_shelleject"
SWEP.MuzzleAttachment = "1"
SWEP.ShellEjectAttachment = "2"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Sound = Sound("Weapon_AR2.Double") -- For grenade launching
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false -- Best left at false, as secondary is used for ironsights/switching firemodes
SWEP.Secondary.Ammo = "none"
SWEP.IronSightZoom = 1.2
SWEP.ScopeZooms = {5,10}
SWEP.UseScope = false
SWEP.ScopeScale = 0.4
SWEP.DrawSniperSights = false
SWEP.DrawRifleSights = false
SWEP.LaserRespawnTime = 0.9
SWEP.LaserLastRespawn = 0
SWEP.HasLaser = false
SWEP.HasSilencer = true
SWEP.MinRecoil = 0.1
SWEP.MaxRecoil = 0.5
SWEP.DeltaRecoil = 0.1
SWEP.RecoverTime = 1
SWEP.MinSpread = 0
SWEP.MaxSpread = 0
SWEP.DeltaSpread = 0
SWEP.MinSpray = 0.2
SWEP.MaxSpray = 1.5
SWEP.DeltaSpray = 0.2
SWEP.CrouchModifier = 0.7
SWEP.IronSightModifier = 0.7
SWEP.RunModifier = 1.5
SWEP.JumpModifier = 1.5
---------------------------------------------------------
--------------------Firemodes------------------------
---------------------------------------------------------
SWEP.FireModes = {}
---------------------------------------
-- Firemode: Semi Automatic --
---------------------------------------
SWEP.FireModes.Semi = {}
SWEP.FireModes.Semi.FireFunction = function(self)
self:BaseAttack()
end
SWEP.FireModes.Semi.InitFunction = function(self)
self.Primary.Automatic = false
self.Primary.Delay = 60/self.SemiRPM
end
-- We don't need to do anything for these revert functions, as self.Primary.Automatic, self.Primary.Delay, self.FireModeDrawTable.x, and self.FireModeDrawTable.y are set in every init function
SWEP.FireModes.Semi.RevertFunction = function(self)
return
end
---------------------------------------
-- Firemode: Fully Automatic --
---------------------------------------
SWEP.FireModes.Auto = {}
SWEP.FireModes.Auto.FireFunction = function(self)
self:BaseAttack()
end
SWEP.FireModes.Auto.InitFunction = function(self)
self.Primary.Automatic = true
self.Primary.Delay = 60/self.AutoRPM
end
SWEP.FireModes.Auto.RevertFunction = function(self)
return
end
-------------------------------------------
-- Firemode: Three-Round Burst --
-------------------------------------------
SWEP.FireModes.Burst = {}
SWEP.FireModes.Burst.FireFunction = function(self)
local clip = self.Weapon:Clip1()
if not self:CanFire(clip) then return end
self:BaseAttack()
timer.Simple(self.BurstDelay, self.BaseAttack, self)
if clip > 1 then
timer.Simple(2*self.BurstDelay, self.BaseAttack, self)
end
self.Weapon:SetNextPrimaryFire( CurTime() + 1 )
end
SWEP.FireModes.Burst.InitFunction = function(self)
self.Primary.Automatic = true
self.Primary.Delay = 60/self.SemiRPM + 3*self.BurstDelay -- Burst delay is derived from self.BurstRPM
end
SWEP.FireModes.Burst.RevertFunction = function(self)
return
end
---------------------------------------------------------
-----------------Init Functions----------------------
---------------------------------------------------------
local sndZoomIn = Sound("Weapon_AR2.Special1")
local sndZoomOut = Sound("Weapon_AR2.Special2")
local sndCycleZoom = Sound("Default.Zoom")
local sndCycleFireMode = Sound("Weapon_Pistol.Special2")
function SWEP:Initialize()
if SERVER then
-- This is so NPCs know wtf they are doing
self:SetWeaponHoldType(self.HoldType)
self:SetNPCMinBurst(3)
self:SetNPCMaxBurst(6)
self:SetNPCFireRate(60/self.AutoRPM)
end
self.CurFireMode = 1 -- This is just an index to get the firemode from the available firemodes table
if CLIENT then
-- We need to get these so we can scale everything to the player's current resolution.
local iScreenWidth = surface.ScreenWidth()
local iScreenHeight = surface.ScreenHeight()
-- The following code is only slightly riped off from Night Eagle
-- These tables are used to draw things like scopes and crosshairs to the HUD.
self.ScopeTable = {}
self.ScopeTable.l = iScreenHeight*self.ScopeScale
self.ScopeTable.x1 = 0.5*(iScreenWidth + self.ScopeTable.l)
self.ScopeTable.y1 = 0.5*(iScreenHeight - self.ScopeTable.l)
self.ScopeTable.x2 = self.ScopeTable.x1
self.ScopeTable.y2 = 0.5*(iScreenHeight + self.ScopeTable.l)
self.ScopeTable.x3 = 0.5*(iScreenWidth - self.ScopeTable.l)
self.ScopeTable.y3 = self.ScopeTable.y2
self.ScopeTable.x4 = self.ScopeTable.x3
self.ScopeTable.y4 = self.ScopeTable.y1
self.ParaScopeTable = {}
self.ParaScopeTable.x = 0.5*iScreenWidth - self.ScopeTable.l
self.ParaScopeTable.y = 0.5*iScreenHeight - self.ScopeTable.l
self.ParaScopeTable.w = 2*self.ScopeTable.l
self.ParaScopeTable.h = 2*self.ScopeTable.l
self.ScopeTable.l = (iScreenHeight + 1)*self.ScopeScale -- I don't know why this works, but it does.
self.QuadTable = {}
self.QuadTable.x1 = 0
self.QuadTable.y1 = 0
self.QuadTable.w1 = iScreenWidth
self.QuadTable.h1 = 0.5*iScreenHeight - self.ScopeTable.l
self.QuadTable.x2 = 0
self.QuadTable.y2 = 0.5*iScreenHeight + self.ScopeTable.l
self.QuadTable.w2 = self.QuadTable.w1
self.QuadTable.h2 = self.QuadTable.h1
self.QuadTable.x3 = 0
self.QuadTable.y3 = 0
self.QuadTable.w3 = 0.5*iScreenWidth - self.ScopeTable.l
self.QuadTable.h3 = iScreenHeight
self.QuadTable.x4 = 0.5*iScreenWidth + self.ScopeTable.l
self.QuadTable.y4 = 0
self.QuadTable.w4 = self.QuadTable.w3
self.QuadTable.h4 = self.QuadTable.h3
self.LensTable = {}
self.LensTable.x = self.QuadTable.w3
self.LensTable.y = self.QuadTable.h1
self.LensTable.w = 2*self.ScopeTable.l
self.LensTable.h = 2*self.ScopeTable.l
self.CrossHairTable = {}
self.CrossHairTable.x11 = 0
self.CrossHairTable.y11 = 0.5*iScreenHeight
self.CrossHairTable.x12 = iScreenWidth
self.CrossHairTable.y12 = self.CrossHairTable.y11
self.CrossHairTable.x21 = 0.5*iScreenWidth
self.CrossHairTable.y21 = 0
self.CrossHairTable.x22 = 0.5*iScreenWidth
self.CrossHairTable.y22 = iScreenHeight
end
self.BulletSpeed = self.MuzzleVelocity*50 -- phoenix - 39.37 -- Assuming source units are in inches per second
self.BurstDelay = 60/self.BurstRPM
self.Primary.Delay = 60/self.SemiRPM
self.FireFunction = self.FireModes[self.AvailableFireModes[self.CurFireMode]].FireFunction
self.Weapon:SetNetworkedInt("rg_firemode", 1)
self.Weapon:SetNetworkedBool("Ironsights", false)
self.Weapon:SetNWBool( "silenced", false ) -- PC Camp add
self.ScopeZooms = self.ScopeZooms or {5}
if self.UseScope then
self.CurScopeZoom = 1 -- Another index, this time for ScopeZooms
end
self:ResetVars()
end
function SWEP:Deploy()
if (SERVER) then
if (!self.DrawCrosshair or self.CustomCrosshair) then self.Owner:CrosshairDisable() end
if (self.Owner._Ammo[self.Classname]) then
self.Weapon:SetClip1(self.Owner._Ammo[self.Classname]);
end;
end
if ( self.Weapon:GetNWBool("silenced") ) then
self.Weapon:SendWeaponAnim(ACT_VM_IDLE_SILENCED);
else
self.Weapon:SendWeaponAnim(ACT_VM_IDLE);
end;
end
-- This function resets spread, recoil, ironsights, etc.
function SWEP:ResetVars()
self.NextSecondaryAttack = 0
self.CurrentSpread = self.MinSpread
self.CurrentRecoil
Move
[lua]
self:SetWeaponHoldType(self.HoldType)
[/lua]
from line 180 out of the 'if SERVER then' block; it needs to be set on both the client and the server.
[QUOTE=_nonSENSE;33401788]Move
[lua]
self:SetWeaponHoldType(self.HoldType)
[/lua]
from line 180 out of the 'if SERVER then' block; it needs to be set on both the client and the server.[/QUOTE]
Oh, I see what you mean. I will try this now, thanks mate.
Will it matter where else I put it? Or is there some specific place to put it?
It will make a matter, you have to put it in initalize.
If it is just client-side or just server-side it wont work.
Couldn't i just remove "if SERVER then" ?
EDIT: Never mind I did it, Thank you very much guys.
btw, the reason you can't remove the server if statement is because there is other data inside it that is serverside only, while removing it may not break anything, it's best to keep it there.
Sorry, you need to Log In to post a reply to this thread.