Added error handling to respawn

Checks to make sure there are points to search through for the player to
respawn at.
master
Austin Shenk 2013-01-17 21:10:04 -05:00
parent 3411e29093
commit 50fb976006
1 changed files with 14 additions and 18 deletions

View File

@ -103,25 +103,21 @@ end
function adventures.requestRespawnPosition(player)
local id = adventures.playerCheckPoints[player:get_player_name()]
local points = adventures.respawnPoints[id]
local adjusted = false
local startID = id
while points == nil and id > 0 do
adjusted = true
id = id-1
points = adventures.respawnPoints[id]
end
if id == 0 then
return adventures.requestSpawnPosition(player)
else
local points = adventures.respawnPoints[id]
local adjusted = false
local startID = id
while points == nil and id > 0 do
adjusted = true
id = id-1
points = adventures.respawnPoints[id]
end
if id == 0 then
return adventures.requestSpawnPosition(player)
end
if adjusted then
print("Adventures Message: Respawn area #"..startID.." does not exist adjusted to respawn area #"..id)
end
local i = math.random(table.getn(points))
player:setpos(points[i])
return true
end
if adjusted then
print("Adventures Message: Respawn area #"..startID.." does not exist adjusted to respawn area #"..id)
end
local i = math.random(table.getn(points))
player:setpos(points[i])
return true
end