mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2024-12-14 10:23:17 +02:00
Trying to fix some issues with player being nil for certain GUI events.
This commit is contained in:
parent
10814e30fa
commit
5ddb5b2dee
@ -121,6 +121,11 @@ end
|
|||||||
|
|
||||||
-- Display the spawn options and explanation
|
-- Display the spawn options and explanation
|
||||||
function DisplaySpawnOptions(player)
|
function DisplaySpawnOptions(player)
|
||||||
|
if (player == nil) then
|
||||||
|
DebugPrint("DisplaySpawnOptions with no valid player...")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if (player.gui.center.spawn_opts ~= nil) then
|
if (player.gui.center.spawn_opts ~= nil) then
|
||||||
DebugPrint("Tried to display spawn options when it was already displayed!")
|
DebugPrint("Tried to display spawn options when it was already displayed!")
|
||||||
return
|
return
|
||||||
@ -791,9 +796,11 @@ function SpawnCtrlGuiClick(event)
|
|||||||
player.print("You rejected " .. joinQueuePlayerChoice .. "'s request to join your base.")
|
player.print("You rejected " .. joinQueuePlayerChoice .. "'s request to join your base.")
|
||||||
SendMsg(joinQueuePlayerChoice, "Your request to join was rejected.")
|
SendMsg(joinQueuePlayerChoice, "Your request to join was rejected.")
|
||||||
|
|
||||||
|
-- Close the waiting players menu
|
||||||
|
if (game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu) then
|
||||||
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
||||||
DisplaySpawnOptions(game.players[joinQueuePlayerChoice])
|
DisplaySpawnOptions(game.players[joinQueuePlayerChoice])
|
||||||
|
end
|
||||||
|
|
||||||
-- Find and remove the player from the joinQueue they were in.
|
-- Find and remove the player from the joinQueue they were in.
|
||||||
for index,requestingPlayer in pairs(global.sharedSpawns[player.name].joinQueue) do
|
for index,requestingPlayer in pairs(global.sharedSpawns[player.name].joinQueue) do
|
||||||
@ -805,12 +812,6 @@ function SpawnCtrlGuiClick(event)
|
|||||||
|
|
||||||
elseif (elemName == "accept_player_request") then
|
elseif (elemName == "accept_player_request") then
|
||||||
|
|
||||||
-- Send an announcement
|
|
||||||
SendBroadcastMsg(joinQueuePlayerChoice .. " is joining " .. player.name .. "'s base!")
|
|
||||||
|
|
||||||
-- Close the waiting players menu
|
|
||||||
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
|
||||||
|
|
||||||
-- Find and remove the player from the joinQueue they were in.
|
-- Find and remove the player from the joinQueue they were in.
|
||||||
for index,requestingPlayer in pairs(global.sharedSpawns[player.name].joinQueue) do
|
for index,requestingPlayer in pairs(global.sharedSpawns[player.name].joinQueue) do
|
||||||
if (requestingPlayer == joinQueuePlayerChoice) then
|
if (requestingPlayer == joinQueuePlayerChoice) then
|
||||||
@ -818,6 +819,16 @@ function SpawnCtrlGuiClick(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- If player exists, then do stuff.
|
||||||
|
if (game.players[joinQueuePlayerChoice]) then
|
||||||
|
-- Send an announcement
|
||||||
|
SendBroadcastMsg(joinQueuePlayerChoice .. " is joining " .. player.name .. "'s base!")
|
||||||
|
|
||||||
|
-- Close the waiting players menu
|
||||||
|
if (game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu) then
|
||||||
|
game.players[joinQueuePlayerChoice].gui.center.join_shared_spawn_wait_menu.destroy()
|
||||||
|
end
|
||||||
|
|
||||||
-- Spawn the player
|
-- Spawn the player
|
||||||
joiningPlayer = game.players[joinQueuePlayerChoice]
|
joiningPlayer = game.players[joinQueuePlayerChoice]
|
||||||
ChangePlayerSpawn(joiningPlayer, global.sharedSpawns[player.name].position)
|
ChangePlayerSpawn(joiningPlayer, global.sharedSpawns[player.name].position)
|
||||||
@ -829,6 +840,9 @@ function SpawnCtrlGuiClick(event)
|
|||||||
-- Create the button at the top left for setting respawn point and sharing base.
|
-- Create the button at the top left for setting respawn point and sharing base.
|
||||||
CreateSpawnCtrlGui(joiningPlayer)
|
CreateSpawnCtrlGui(joiningPlayer)
|
||||||
ExpandSpawnCtrlGui(player, event.tick)
|
ExpandSpawnCtrlGui(player, event.tick)
|
||||||
|
else
|
||||||
|
SendBroadcastMsg(joinQueuePlayerChoice .. " left the game. What an ass.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1029,7 +1043,9 @@ function BuddySpawnOptsGuiClick(event)
|
|||||||
buddyIsStillWaiting = false
|
buddyIsStillWaiting = false
|
||||||
for _,buddyName in pairs(global.waitingBuddies) do
|
for _,buddyName in pairs(global.waitingBuddies) do
|
||||||
if (buddyChoice == buddyName) then
|
if (buddyChoice == buddyName) then
|
||||||
|
if (game.players[buddyChoice]) then
|
||||||
buddyIsStillWaiting = true
|
buddyIsStillWaiting = true
|
||||||
|
end
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1144,6 +1160,11 @@ end
|
|||||||
|
|
||||||
function DisplayBuddySpawnRequestMenu(player, requestingBuddyName)
|
function DisplayBuddySpawnRequestMenu(player, requestingBuddyName)
|
||||||
|
|
||||||
|
if not player then
|
||||||
|
DebugPrint("Another gui click happened with no valid player...")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
player.gui.center.add{name = "buddy_request_menu",
|
player.gui.center.add{name = "buddy_request_menu",
|
||||||
type = "frame",
|
type = "frame",
|
||||||
direction = "vertical",
|
direction = "vertical",
|
||||||
|
Loading…
Reference in New Issue
Block a user