local playermodelstorage = {}
hook.Add("playerArrested", "zwiggityzwoot", function(ply)
for k,v in pairs(player.GetAll()) do
if v == ply then
table.insert(playermodelstorage, k, ply:GetModel())
end
end
timer.Simple(0.1,function()
ply:SetModel(prisonmodel)
end)
end)
hook.Add("playerUnArrested", "Zwonkyz", function(ply)
for k,v in pairs(player.GetAll()) do
if v == ply then
ply:SetModel(playermodelstorage[k])
print(playermodelstorage[k])
end
end
end)
So if there is more than 2 people arrested at a time, I get an error when trying to unarrest the first arrested guy = Bad argument #1 to "SetModel" (String expected, got nil)
Your code will break if someone leaves the game between the playerArrested or playerUnArrested hook calls - you should just use the player as the table key instead of doing the looping.
When you say play as the table key, do you mean player id, or the userdata
The userdata - you can use anything as a key in Lua.
I know, but isn't using the userdata the same as the userID?
I did do this instead of the userID, but it works pretty much the same :/
playermodelstorage[ply] = ply:GetModel()
The key in a player.GetAll table is not UserID. But yes, you can use UserID.
Sorry, you need to Log In to post a reply to this thread.