I looked for some PointShop permanent weapons and couldn't find any, I made my own code for it and i have encountered a bug and can't seem to fix it. Basically the bug with it is you have the weapon purchased and you click spectate only mode you end up being given the weapon in spectator and it kills people. I need to find a way to basically check if they have the spectator only mode checked off and then make a new function to strip the weapon from them if they are in spectator.
[CODE]ITEM.Name = 'Example Weapon'
ITEM.Price = 1000
ITEM.Model = 'models/weapons/w_rif_m4a1.mdl'
ITEM.SingleUse = false
ITEM.WeaponClass = 'weapon_ttt_example'
function ITEM:OnEquip(ply)
if not ply:Alive() then return end
ply:StripWeapon('weapon_ttt_m16', 'weapon_zm_shotgun', 'weapon_zm_rifle', 'weapon_zm_mac10', 'weapon_zm_sledge')
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnHolster(ply)
if not ply:Alive() then return end
ply:StripWeapon(self.WeaponClass)
ply:Give('weapon_ttt_m16') -- Also don't know why you're giving the player a weapon for holstering it..
ply:SelectWeapon('weapon_ttt_m16')
end
function ITEM:PlayerSpawn(ply)
ply:StripWeapon('weapon_ttt_m16', 'weapon_zm_shotgun', 'weapon_zm_rifle', 'weapon_zm_mac10', 'weapon_zm_sledge')
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end[/CODE]
Use ply:Team() to check whether the player is a spectator or not.
Could you possibly give me a example of what it would look like? Sorry, i am a beginner to Lua and have a few troubles.
[code]if ply:IsSpec() then return end[/code]
Add that to the OnEquip.
I have a simpler way. Just make a new folder under pointshop-master/lua/items example "permaweapons". In that folder make a _category lua file (You can copy it's format from another one). Then in the desired lua file put this but to your weapon of choice. Works on our server.
[CODE]ITEM.Name = 'Trench Gun'
ITEM.Price = 30000
ITEM.Model = 'models/weapons/w_shot_trenchg90.mdl'
ITEM.WeaponClass = 'weapon_winchester'
function ITEM:OnEquip(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
end[/CODE]
[QUOTE=fappymcfap;45435677]I have a simpler way. Just make a new folder under pointshop-master/lua/items example "permaweapons". In that folder make a _category lua file (You can copy it's format from another one). Then in the desired lua file put this but to your weapon of choice. Works on our server.
[CODE]ITEM.Name = 'Trench Gun'
ITEM.Price = 30000
ITEM.Model = 'models/weapons/w_shot_trenchg90.mdl'
ITEM.WeaponClass = 'weapon_winchester'
function ITEM:OnEquip(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
end[/CODE][/QUOTE]
That doesn't have any functions to prevent non-alive players from not getting weapons.
K so i did what you said and got this error[CODE]ITEM.Name = 'AK-47'
ITEM.Price = 500
ITEM.Model = 'models/weapons/v_rif_ak47.mdl'
ITEM.SingleUse = false
ITEM.WeaponClass = 'weapon_ttt_ak47'
function ITEM:OnEquip(ply)
if ply:IsSpec() return end -- Check if player is in spectator
if not ply:Alive() then return end -- Check if player is alive
ply:StripWeapon('weapon_zm_mac10', 'weapon_zm_rifle', 'weapon_ttt_m16', 'weapon_zm_shotgun', 'weapon_zm_sledge') -- Strip all the primary weapons they could have picked up
ply:Give(self.WeaponClass) -- Give them the WeaponClass
ply:SelectWeapon(self.WeaponClass) -- Equip the WeaponClass
end
function ITEM:OnHolster(ply)
if not ply:Alive() then return end -- Check if the player is alive
ply:StripWeapon(self.WeaponClass) -- Take away the WeaponClass
ply:Give('') -- Give them nothing instead of the WeaponClass
ply:SelectWeapon('weapon_zm_improvised') -- Switch to their crowbar
end
function ITEM:PlayerSpawn(ply)
if ply:IsSpec() return end
ply:StripWeapon('weapon_zm_mac10', 'weapon_zm_rifle', 'weapon_ttt_m16', 'weapon_zm_shotgun', 'weapon_zm_sledge') -- Strip all the primary weapons they could have picked up
ply:Give(self.WeaponClass) -- Give them the WeaponClass
ply:SelectWeapon(self.WeaponClass) -- Equip the WeaponClass
end[/CODE]
[CODE][ERROR] addons/pointshop-master/lua/items/weapons/ak47.lua:10: 'then' expected near 'return'
1. unknown - addons/pointshop-master/lua/items/weapons/ak47.lua:0
[/CODE]
[QUOTE=SkyzAEColo;45436206]K so i did what you said and got this error[/QUOTE]
The Error is literally your answer. Read it.
Put a then after IsSpec()
Sorry, you need to Log In to post a reply to this thread.