manage when a player join the server
This commit is contained in:
parent
36cf818731
commit
5f3495b2a8
@ -17,7 +17,6 @@ use ManiaControl\Manialinks\ManialinkManager;
|
|||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
|
|
||||||
|
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
@ -43,6 +42,7 @@ class ClimbTheMap implements ManialinkPageAnswerListener, TimerListener, Command
|
|||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
const CB_UPDATEPBS = 'Trackmania.ClimbTheMap.UpdatePBs';
|
const CB_UPDATEPBS = 'Trackmania.ClimbTheMap.UpdatePBs';
|
||||||
|
const CB_REQUESTPB = 'Trackmania.ClimbTheMap.RequestPB';
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
const M_SETPLAYERSPB = 'Trackmania.ClimbTheMap.SetPlayersPB';
|
const M_SETPLAYERSPB = 'Trackmania.ClimbTheMap.SetPlayersPB';
|
||||||
@ -115,6 +115,7 @@ class ClimbTheMap implements ManialinkPageAnswerListener, TimerListener, Command
|
|||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback');
|
||||||
|
|
||||||
$this->maniaControl->getCallbackManager()->registerScriptCallbackListener(self::CB_UPDATEPBS, $this, 'handleUpdatePBs');
|
$this->maniaControl->getCallbackManager()->registerScriptCallbackListener(self::CB_UPDATEPBS, $this, 'handleUpdatePBs');
|
||||||
|
$this->maniaControl->getCallbackManager()->registerScriptCallbackListener(self::CB_REQUESTPB, $this, 'handleRequestPB');
|
||||||
|
|
||||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::A_SHOW_ALTITUDE_RECORDS, $this, 'handleShowAltitudeRecords');
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::A_SHOW_ALTITUDE_RECORDS, $this, 'handleShowAltitudeRecords');
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener('records', $this, 'handleShowAltitudeRecords', false);
|
$this->maniaControl->getCommandManager()->registerCommandListener('records', $this, 'handleShowAltitudeRecords', false);
|
||||||
@ -145,16 +146,6 @@ class ClimbTheMap implements ManialinkPageAnswerListener, TimerListener, Command
|
|||||||
$this->handleStartRound();
|
$this->handleStartRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle when a player connects
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function handlePlayerConnect(Player $player) {
|
|
||||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleStartRound() {
|
public function handleStartRound() {
|
||||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||||
$logins = [];
|
$logins = [];
|
||||||
@ -224,6 +215,24 @@ class ClimbTheMap implements ManialinkPageAnswerListener, TimerListener, Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle when a player connects
|
||||||
|
* Can't use the C++ Callback because the it's received by Maniacontrol before that the Maniascript initialized the Player
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function handleRequestPB(array $data) {
|
||||||
|
$login = $data[1][0];
|
||||||
|
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||||
|
if ($map === null) return;
|
||||||
|
|
||||||
|
// Send PB
|
||||||
|
$pbs = $this->getPlayersPB($map->index, [$login]);
|
||||||
|
if (count($pbs) > 0) {
|
||||||
|
$this->maniaControl->getClient()->triggerModeScriptEvent(self::M_SETPLAYERSPB, [json_encode($pbs)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function handle1Minute() {
|
public function handle1Minute() {
|
||||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||||
if ($map === null) return;
|
if ($map === null) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user