This is me guessing because I have very little experience with multiplayer (zero with online player manipulation) and I can't test this, so:
Code:
main:
thread PlayerCheck
end
PlayerCheck:
local.player = $player // get initial player array
if (local.player.size > 0) // server isn't empty
{
local.index = 1 // start at player 1
level.resync = NIL // reset player re-sync flag
waitthread InstantiateJumpChecks local.player local.index // initialise JumpCheck threads for each player
while (!level.resync && local.player.size > 0)
{
if (local.player.size < $player.size) // someone has joined
{
local.index = (local.player.size + 1) // get index to start from
level.resync = true // sync up the players so we can give them a JumpCheck
}
waitframe
}
waitframe
goto PlayerCheck // someone joined (or disconnected), re-synchronise array (don't wait long)
}
wait 1
goto PlayerCheck // server is empty, check until we get someone (wait a bit longer)
end
InstantiateJumpChecks local.player local.index:
level.inProgress = true
for (local.i = local.index; local.i <= local.player.size; local.i++)
{
if (local.player[local.i] && !local.player[local.i].isHandled && local.player[local.i] == $player[local.i])
{
local.player[local.i] thread JumpCheck
$player[local.i].isHandled = true
}
if !(local.player[local.i] == $player[local.i])
level.resync = true
if (level.resync)
break // someone disconnected during instantiation, finish early and do PlayerCheck again
}
level.inProgress = NIL
end
JumpCheck:
while (self)
{
if (isAlive self && self getposition == "offground" && self.useheld)
{
println "JUMPING & USING - DO SOME STUFF!"
while (self && isAlive self && self getposition == "offground")
waitframe // wait until you land
println "FINISHED - TRY AGAIN?"
}
waitframe
}
if (!self && level.inProgress) // someone has disconnected during the instantiation process
level.resync = true
end
Maybe useless, but I decided to take a little shot at what it may look like. It could be augmented by taking further advantage of the local.player array as a reference.
Edit: just tested what I could (1 player) - it works, but I think at this point it will fire the code even if you fall and press use.