Author Topic: [Solved] Run function when player leaves minigame or server  (Read 1165 times)

How do you run a function when a player leaves a minigame?
« Last Edit: July 12, 2016, 12:18:15 PM by Farad »

do a trace and call /leaveMinigame and see what gets called

my guess is all leave minigame requests are processed through that servercmd.

Package serverCmdLeaveMiniGame(%client). If Slayer is enabled you might want to check if it's a Slayer minigame and they have permission to leave before running your code.
Code: (Slayer) [Select]
function serverCmdLeaveMinigame(%client)
{
%mini = getMinigameFromObject(%client);

if(!isSlayerMinigame(%mini) || (%can = %mini.canLeave(%client)))
parent::serverCmdLeaveMinigame(%client);
else if(!%can)
{
messageClient(%client, '', "\c5You don't have permission to do that.");
return;
}
}

Package serverCmdLeaveMiniGame(%client).
Ok I did something like that, but I just realized that serverCmdLeaveMinigame doesn't call when a player leaves the server. I need something that runs when the players disconnects from the server also.

Ok I did something like that, but I just realized that serverCmdLeaveMinigame doesn't call when a player leaves the server. I need something that runs when the players disconnects from the server also.
Maybe package GameConnection::onClientLeaveGame(%this)

gameConnection::onDrop(%client)

gameConnection::onDrop(%client)
What's the difference between gameConnection::onDrop(%client) and GameConnection::onClientLeaveGame(%this)?

What's the difference between gameConnection::onDrop(%client) and GameConnection::onClientLeaveGame(%this)?

not really anything

onClientLeaveGame is called from inside onDrop
so generally it doesn't matter which one you would use

What's the difference between gameConnection::onDrop(%client) and GameConnection::onClientLeaveGame(%this)?
They both would serve the same purpose for what you're trying to accomplish. I've just always used ::onClientLeaveGame.