• Holding a gun like a pistol
    11 replies, posted
So heres some of the AK code [lua] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "ar2" end if ( CLIENT ) then SWEP.PrintName = "AK-47" SWEP.Author = "Counter-Strike" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.IconLetter = "b" killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end [/lua] And he holds the gun like [url]http://screenshot.xfire.com/s/112402327-4.jpg[/url]
[lua] function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) return true end[/lua]
and where would i put that at?
[lua] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "ar2" end if ( CLIENT ) then SWEP.PrintName = "AK-47" SWEP.Author = "Counter-Strike" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.IconLetter = "b" killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) return true end [/lua] You need to learn lua.
[lua] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "ar2" end if ( CLIENT ) then SWEP.PrintName = "AK-47" SWEP.Author = "Counter-Strike" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.IconLetter = "b" killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) return true end SWEP.Base = "weapon_rp_base" SWEP.Category = "Counter-Strike" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl" SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl" SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" ) SWEP.Primary.Recoil = 1.5 SWEP.Primary.Damage = 30 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.02 SWEP.Primary.ClipSize = 25 SWEP.Primary.Delay = 0.07 SWEP.Primary.DefaultClip = 0 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "smg1" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector( 6.1, -7, 2.5 ) SWEP.IronSightsAng = Vector( 2.8, 0, 0 )[/lua] Looks the same, nothing changed hes still holding the AK like a pistol
Alright This code works great the weapon is shoulder mounted [lua] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) end if ( CLIENT ) then SWEP.PrintName = "AK-47" SWEP.Author = "Counter-Strike" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.IconLetter = "b" killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end SWEP.HoldType = "ar2" SWEP.Base = "weapon_rp_base" SWEP.Category = "Counter-Strike" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl" SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl" SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" ) SWEP.Primary.Recoil = 1.5 SWEP.Primary.Damage = 30 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.02 SWEP.Primary.ClipSize = 25 SWEP.Primary.Delay = 0.07 SWEP.Primary.DefaultClip = 0 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "smg1" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector( 6.1, -7, 2.5 ) SWEP.IronSightsAng = Vector( 2.8, 0, 0 )[/lua] This code i tried to make the keys make it look like your hands were down to your site put it looks like your holding a pistol. [lua]if SERVER then AddCSLuaFile("shared.lua") end if CLIENT then SWEP.PrintName = "Keys" SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = false end SWEP.HoldType = "normal" SWEP.Author = "" SWEP.Instructions = "Left Click: Lock Door, Right Click: Unlock Door" SWEP.Contact = "" SWEP.Purpose = "" SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = false SWEP.AnimPrefix = "rpg" SWEP.LockSound = "doors/door_latch1.wav" SWEP.UnlockSound = "doors/door_latch3.wav" SWEP.Spawnable = false SWEP.AdminSpawnable = true SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = 0 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "" SWEP.ViewModel = "models/weapons/v_fists.mdl"; SWEP.WorldModel = "models/weapons/w_fists.mdl"; function SWEP:Initialize() if SERVER then self:SetWeaponHoldType("normal") end end function SWEP:Initialize() if SERVER then self:SetWeaponHoldType("normal") end end function SWEP:CanPrimaryAttack ( ) return true; end function SWEP:PrimaryAttack() if CLIENT then return false; end if GAMEMODE.LockOverride then self.Owner:Notify("You cannot lock doors during this event."); return false; end local EyeTrace = self.Owner:GetEyeTrace() if !EyeTrace.Entity:IsValid() or !((EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) or EyeTrace.Entity:IsVehicle()) then return false; end local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos); if Distance > 75 and EyeTrace.Entity:IsDoor() then return false; end if Distance > 100 and EyeTrace.Entity:IsVehicle() then return false; end local IsOwned = EyeTrace.Entity:GetDoorOwner(); local OwnerIsPlayer = IsOwned and EyeTrace.Entity:GetDoorOwner():IsPlayer(); local WeOwnIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner() == self.Owner; local FriendOwnsIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner():HasBuddy(self.Owner); local OrgOwnsIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner():GetOrganization() != 0 and EyeTrace.Entity:GetDoorOwner():GetOrganization() == self.Owner:GetOrganization(); local PoliceOwnsIt = EyeTrace.Entity:IsOwnedByPolice(); local MayorOwnsIt = EyeTrace.Entity:IsOwnedByMayor(); local WeArePolice = self.Owner:Team() == TEAM_POLICE; local WeAreMayor = self.Owner:Team() == TEAM_MAYOR; if IsOwned and (WeOwnIt or FriendOwnsIt or OrgOwnsIt or (PoliceOwnsIt and WeArePolice) or (MayorOwnsIt and WeAreMayor)) then EyeTrace.Entity:Fire("lock", "", 0) self.Owner:EmitSound(self.LockSound) if SERVER then if EyeTrace.Entity:IsVehicle() and !EyeTrace.Entity:IsGovVehicle() and EyeTrace.Entity:GetTable().LastSirenPlay and EyeTrace.Entity:GetTable().LastSirenPlay + 23 > CurTime() then umsg.Start('perp_car_alarm_stop'); umsg.Entity(EyeTrace.Entity); umsg.End(); EyeTrace.Entity:GetTable().LastSirenPlay = nil; elseif EyeTrace.Entity:IsDoor() and EyeTrace.Entity:GetTable().LastSirenPlay and EyeTrace.Entity:GetTable().LastSirenPlay + 30 > CurTime() then umsg.Start('perp_house_alarm_stop'); umsg.Entity(EyeTrace.Entity); umsg.End(); EyeTrace.Entity:GetTable().LastSirenPlay = nil; end end end self.Weapon:SetNextPrimaryFire(CurTime() + 1) end function SWEP:SecondaryAttack() if CLIENT then return false; end local EyeTrace = self.Owner:GetEyeTrace() if !EyeTrace.Entity:IsValid() or !((EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) or EyeTrace.Entity:IsVehicle()) then return false; end local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos); if Distance > 75 and EyeTrace.Entity:IsDoor() then return false; end if Distance > 100 and EyeTrace.Entity:IsVehicle() then return false; end local IsOwned = EyeTrace.Entity:GetDoorOwner(); local OwnerIsPlayer = IsOwned and EyeTrace.Entity:GetDoorOwner():IsPlayer(); local WeOwnIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner() == self.Owner; local FriendOwnsIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner():HasBuddy(self.Owner); local OrgOwnsIt = OwnerIsPlayer and EyeTrace.Entity:GetDoorOwner():GetOrganization() != 0 and EyeTrace.Entity:GetDoorOwner():GetOrganization() == self.Owner:GetOrganization(); local PoliceOwnsIt = EyeTrace.Entity:IsOwnedByPolice(); local MayorOwnsIt = EyeTrace.Entity:IsOwnedByMayor(); local WeArePolice = self.Owner:Team() == TEAM_POLICE; local WeAreMayor = self.Owner:Team() == TEAM_MAYOR; if IsOwned and (WeOwnIt or FriendOwnsIt or OrgOwnsIt or (PoliceOwnsIt and WeArePolice) or (MayorOwnsIt and WeAreMayor)) then EyeTrace.Entity:Fire("unlock", "", 0) self.Owner:EmitSound(self.UnlockSound) if SERVER then if EyeTrace.Entity:IsVehicle() and !EyeTrace.Entity:IsGovVehicle() and EyeTrace.Entity:GetTable().LastSirenPlay and EyeTrace.Entity:GetTable().LastSirenPlay + 23 > CurTime() then umsg.Start('perp_car_alarm_stop'); umsg.Entity(EyeTrace.Entity); umsg.End(); EyeTrace.Entity:GetTable().LastSirenPlay = nil; elseif EyeTrace.Entity:IsDoor() and EyeTrace.Entity:GetTable().LastSirenPlay and EyeTrace.Entity:GetTable().LastSirenPlay + 30 > CurTime() then umsg.Start('perp_house_alarm_stop'); umsg.Entity(EyeTrace.Entity); umsg.End(); EyeTrace.Entity:GetTable().LastSirenPlay = nil; end end else if SERVER and EyeTrace.Entity:IsVehicle() and (!EyeTrace.Entity:GetDriver() or !EyeTrace.Entity:GetDriver():IsValid() or !EyeTrace.Entity:GetDriver():IsPlayer()) and !EyeTrace.Entity:IsGovVehicle() then umsg.Start('perp_car_alarm'); umsg.Entity(EyeTrace.Entity); umsg.End(); EyeTrace.Entity:GetTable().LastSirenPlay = CurTime(); end end self.Weapon:SetNextSecondaryFire(CurTime() + 1) end [/lua]
Change the hold type: [url]http://wiki.garrysmod.com/?title=Weapon.SetWeaponHoldType[/url]
The hold type is changed to normal [lua]SWEP.HoldType = "normal"[/lua] from the keys shared.lua Even tried to add the function [lua]if SERVER then AddCSLuaFile("shared.lua") end if CLIENT then SWEP.PrintName = "Keys" SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = false end SWEP.HoldType = "normal" function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) end[/lua] Still didn't work
You have to call it on the server and client or something. [lua] function SWEP:Initalize() if SERVER then self:SetWeaponHoldType( self.HoldType ) end if CLIENT then self:SetWeaponHoldType( self.HoldType ) end end --end function [/lua] something like that I think.
set the hold type to ar2 and change [lua] function SWEP:Initialize() if SERVER then self:SetWeaponHoldType("normal") end end[/lua] to [lua] function SWEP:Initialize() self:SetWeaponHoldType("normal") end[/lua] Think with your brain not with your ass. [editline]30th March 2011[/editline] Even if you just copied the wiki example it would have worked. Is it really that hard ?
Sorry, you need to Log In to post a reply to this thread.