Local variable set equal to targets weapons gets cleared after a strip?
3 replies, posted
Hey!
I have a weapon which basically strips the players weapons and respawns the player (Thats not exactly what it does, obviously. its just a quick explanation of the bare bones basic of the SWEP) after a select amount of time.
Before strippping of weapons take place I save the weapons said player had into a table which I try to retrieve at a later time but it all returns nil. Any ideas?
[code]
self.TargetWep = trace.Entity:GetWeapons()
PrintTable(self.TargetWep)
timer.Create("delay", 2, 1, function()
self.TargetWep = trace.Entity:GetWeapons()
trace.Entity:StripWeapons() -- the player
end)
for k, v in pairs(self.TargetWep:GetWeapons()) do
print(v) -- This prints WEAPON NIL :c
end
[/code]
It should be
for k, v in pairs(self.TargetWep) do
[QUOTE=BlackVoid;43182460]It should be
for k, v in pairs(self.TargetWep) do[/QUOTE]
Durp, thats what It was. I added GetWeapons() just incase for some retarded reason it wasnt working and that failed too. So still nope. Any ideas?
Unless I am mistaken, when setting variables to an existing table, it only links it, it does not copy it.
Try using the table.Copy() function when setting the variable.
Sorry, you need to Log In to post a reply to this thread.