I have no idea if its the code I am using or what... But I dont like it cause people are getting killed randomly. Its been happening for some time whenever I notice it I have to slay the spectator for it to stop.
Here is my pointshop weapon code
[code]ITEM.Name = 'Galil'
ITEM.Price = 40000
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.WeaponClass = 'galil'
function ITEM:OnEquip(ply)
for k,v in pairs(ply:GetWeapons())do
if v.Kind == weapons.Get(self.WeaponClass).Kind then
WEPS.DropNotifiedWeapon(ply,v)
end
end
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
end[/code]
If you could tell me what to change id highly appreciate it <3
Modify to suit your own needs
[code]ITEM.Name = 'Keyboard Crowbar'
ITEM.Price = 1200
ITEM.Model = 'models/weapons/w_keyboard.mdl'
ITEM.WeaponClass = 'weapon_zm_keyboard'
ITEM.Description = 'This item will reskin your crowbar into a keyboard. Damage, push and death icons are not affected.'
function ITEM:OnEquip(ply)
ply:StripWeapon('weapon_zm_improvised')
if not ply:IsSpec() then
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
if not ply:IsSpec() then
ply:Give('weapon_zm_improvised')
ply:SelectWeapon('weapon_zm_improvised')
end
end
[/code]
[QUOTE=NiandraLades;45781397]Modify to suit your own needs
[/QUOTE]
Sooo like
[code]ITEM.Name = 'galil'
ITEM.Price = 40000
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.WeaponClass = 'galil'
function ITEM:OnEquip(ply)
ply:StripWeapon('galil')
if not ply:IsSpec() then
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
if not ply:IsSpec() then
ply:Give('galil')
ply:SelectWeapon('galil')
end
end[/code]
This sould work right?
Yes, it should.
[QUOTE=TripsLetash;45787863]Yes, it should.[/QUOTE]
Sweet. Thanks!
Didnt work... Players wouldnt even spawn with a weapon :/
[QUOTE=D3M0NiiCx;45787811]Sooo like
[code]ITEM.Name = 'galil'
ITEM.Price = 40000
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.WeaponClass = 'galil'
function ITEM:OnEquip(ply)
ply:StripWeapon('galil')
if not ply:IsSpec() then
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
if not ply:IsSpec() then
ply:Give('galil')
ply:SelectWeapon('galil')
end
end[/code]
This sould work right?[/QUOTE]
[QUOTE=TripsLetash;45787863]Yes, it should.[/QUOTE]
Yea.. No.
Why are you stripping the weapon while Equipping it? And why are you giving them a galil if they're holstering the item?
It doesn't make any sense what so ever
[QUOTE=JasonMan34;45789193]Yea.. No.
Why are you stripping the weapon while Equipping it? And why are you giving them a galil if they're holstering the item?
It doesn't make any sense what so ever[/QUOTE]
Well you see... Im dumb :/
[QUOTE=D3M0NiiCx;45787965]Sweet. Thanks!
Didnt work... Players wouldnt even spawn with a weapon :/[/QUOTE]
Is galil an actual entity name?
[lua]
ITEM.Name = 'Galil'
ITEM.Model = 'weapons/w_galil.mdl'
ITEM.Price = 200
ITEM.Class = 'weapon_ttt_galil'
ITEM.Kind = WEAPON_HEAVY
function ITEM:PlayerSpawn( ply )
if not ply:IsSpec() then
for k, v in pairs( ply:GetWeapons() ) do
if v.Kind == self.Kind then
ply:StripWeapon( v:Class() )
end
end
ply:Give( self.Class )
end
end
[/lua]
This might work, sorry for poor phone formatting.
[QUOTE=HumbleTH;45789465]Is galil an actual entity name?
[lua]
ITEM.Name = 'Galil'
ITEM.Model = 'weapons/w_galil.mdl'
ITEM.Price = 200
ITEM.Class = 'weapon_ttt_galil'
ITEM.Kind = WEAPON_HEAVY
function ITEM:PlayerSpawn( ply )
if not ply:IsSpec() then
for k, v in pairs( ply:GetWeapons() ) do
if v.Kind == self.Kind then
ply:StripWeapon( v:Class() )
end
end
ply:Give( self.Class )
end
end
[/lua]
This might work, sorry for poor phone formatting.[/QUOTE]
Yeah. So in actuality I would put this?
[code]ITEM.Name = 'Galil'
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.Price = 1337
ITEM.Class = 'galil'
function ITEM:PlayerSpawn( ply )
if not ply:IsSpec() then
for k, v in pairs( ply:GetWeapons() ) do
if v.Kind == self.Kind then
ply:StripWeapon( v:Class() )
end
end
ply:Give( self.Class )
end
end[/code]
[QUOTE=D3M0NiiCx;45790260]Yeah. So in actuality I would put this?
[code]ITEM.Name = 'Galil'
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.Price = 1337
ITEM.Class = 'galil'
function ITEM:PlayerSpawn( ply )
if not ply:IsSpec() then
for k, v in pairs( ply:GetWeapons() ) do
if v.Kind == self.Kind then
ply:StripWeapon( v:Class() )
end
end
ply:Give( self.Class )
end
end[/code][/QUOTE]
You missed putting the item's kind.
the kind is WEAPON_PISTOL for secondary and WEAPON_HEAVY for prinary.
[QUOTE=HumbleTH;45790341]You missed putting the item's kind.
the kind is WEAPON_PISTOL for secondary and WEAPON_HEAVY for prinary.[/QUOTE]
Alright cool. I will try this later today.
[QUOTE=HumbleTH;45790341]You missed putting the item's kind.
the kind is WEAPON_PISTOL for secondary and WEAPON_HEAVY for prinary.[/QUOTE]
tried it :/ Didnt seem to work
Is this a single use item?
Either way, why modify pointshop weapons like this?
I've made single use and permanent weapons and never have I used "for k,v in pairs"
[QUOTE=JasonMan34;45803699]Is this a single use item?
Either way, why modify pointshop weapons like this?
I've made single use and permanent weapons and never have I used "for k,v in pairs"[/QUOTE]
Its permanent.
[QUOTE=D3M0NiiCx;45809195]Its permanent.[/QUOTE]
So why not just do[CODE]ITEM.Name = 'Galil'
ITEM.Price = 40000
ITEM.Model = 'models/weapons/w_rif_galil.mdl'
ITEM.WeaponClass = 'galil'
ITEM.SingleUse = false
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnEquip(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end[/CODE]
I did it a long time ago and I don't have the code anymore so this might not be it.
But I think this is what I did. And it worked just fine.
Sorry, you need to Log In to post a reply to this thread.