I need a way to have a player get their same weapons back after they are stripped. Here is what I tried, it didn’t work.
[lua]
function takeweps()
-- find out what weapons they had
player.weps = ply:GetWeapons()
-- then strip them
ply:StripWeapons()
end
function givethemback()
-- then go through the table and give them back one by one
for k, v in pairs (player.weps) do
wep2 = v:GetClass()
ply:Give(wep2)
end
[/lua]
Don’t know why this doesn’t work. Please Help!
Well, you never establish a “player” table and you never establish a “ply” argument. Try something like this:
[lua]local meta = FindMetaTable(“player”)
if !meta then return end
function meta:SaveWeapons()
self.weaponlist = self:GetWeapons()
end
function meta:GiveWeapons()
for _,v in ipairs(self.weaponlist) do
self:Give(v:GetClass())
end
end
concommand.Add(“weapon_take”,function(ply)
ply:SaveWeapons()
ply:StripWeapons()
end)
concommand.Add(“weapon_give”,function(ply)
ply:GiveWeapons()
end)[/lua]
Thank you, I’ll try this.
[editline]02:44PM[/editline]
Not working. 
Entoros, when the weapons are stripped, the weapon entities cease to exist, so you can’t get their classes anymore. Also, the meta table is called ‘Player’, not ‘player’. Here’s the fixed version:
[lua]local meta = FindMetaTable( “Player” )
if ( meta ) then
function meta:SaveWeapons( )
self.weaponlist = self:GetWeapons( )
for k, v in pairs( self.weaponlist ) do
self.weaponlist[ k ] = v:GetClass( )
end
end
function meta:GiveWeapons( )
for _, wep in ipairs( self.weaponlist ) do
self:Give( wep )
end
end
concommand.Add( "weapon_take", function( ply )
ply:SaveWeapons( )
ply:StripWeapons( )
end )
concommand.Add( "weapon_give", function( ply )
ply:GiveWeapons( )
end )
end[/lua]
Thank you I will try!
[editline]04:09PM[/editline]
Yes! Everything works! Thank you!