is there any way of stripping everything in, say, a pistol class without going through and putting the name of every pistol down?
You could try creating a weapon table and specifying what they are allowed to have:
[CODE]WeaponTable = {"weapon_ttt_minigun", "weapon_zm_improvised","weapon_zm_carry"}
function PlayerCanPickupWeapon( ply, wep )
if ply:Team() == 1 ang table.HasValue( WeaponTable, wep:GetClass() ) then
return false
end
return trueendhook.Add( "PlayerCanPickupWeapon", "Team1_PlayerCanPickupWeapon", PlayerCanPickupWeapon )[/CODE]
[QUOTE=Aeternal;43842204]You could try creating a weapon table and specifying what they are allowed to have:
[CODE]WeaponTable = {"weapon_ttt_minigun", "weapon_zm_improvised","weapon_zm_carry"}
function PlayerCanPickupWeapon( ply, wep )
if ply:Team() == 1 ang table.HasValue( WeaponTable, wep:GetClass() ) then
return false
end
return trueendhook.Add( "PlayerCanPickupWeapon", "Team1_PlayerCanPickupWeapon", PlayerCanPickupWeapon )[/CODE][/QUOTE]
the goal is to clear out all pistols so I can give them a new one.
[QUOTE=Galactic;43842680]the goal is to clear out all pistols so I can give them a new one.[/QUOTE]
Oh sorry I misread
Player:StripWeapon(ClassName)
I've done something like this before. I'd recommend checking the SWEP.Slot of each if the player's weapons and remove if necessary. Try using a "for k, v in pairs (ply:GetWeapons()) do" then check if the v.Slot is the same and remove using ply:StripWeapon(v:GetClass)
[editline]9th February 2014[/editline]
If you need to get the slot of the weapon you're trying to give try weapons.Get("class").Slot
[QUOTE=Internet1001;43844689]I've done something like this before. I'd recommend checking the SWEP.Slot of each if the player's weapons and remove if necessary. Try using a "for k, v in pairs (ply:GetWeapons()) do" then check if the v.Slot is the same and remove using ply:StripWeapon(v:GetClass)
[editline]9th February 2014[/editline]
If you need to get the slot of the weapon you're trying to give try weapons.Get("class").Slot[/QUOTE]
How would that look? I'm really bad at lua.
[lua]
local wep = "weapon_ttt_m16" -- the class of the weapon you want to give
local slot = weapons.Get( "weapon_pistol" ).Slot -- get the slot of the weapon you want to give
for k, v in pairs( player.GetAll() ) do -- loop through every player
players_weapons = v:GetWeapons() -- get the player's weapons
for pos, weapon in pairs( players_weapons ) do -- loop through the player's weapons
if weapon.Slot == slot then -- check the slot of the weapon against the slot of the weapon you want to give
v:StripWeapon( weapon:GetClass() ) -- if it's the same, remove the weapon from the player
end
end
v:Give( wep ) -- finally give the weapon to the player
end
[/lua]
Sorry about the late reply
Oh, it's a single item for one player, I think I can figure out how to fix it though.
- snip
Sorry, you need to Log In to post a reply to this thread.