mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-04-29 15:35:24 +00:00
Obj Var instead of Guid check
This commit is contained in:
parent
0fef107848
commit
9707a81210
1 changed files with 73 additions and 69 deletions
|
|
@ -10,12 +10,12 @@ $dtVar::AFKTimeout = 1;
|
||||||
$dtVar::AFKtime = 60000 * 2;
|
$dtVar::AFKtime = 60000 * 2;
|
||||||
// Run from List Only instead of All clients on the server. 1 is yes, 0 is no
|
// Run from List Only instead of All clients on the server. 1 is yes, 0 is no
|
||||||
$dtVar::ListOnly = 1;
|
$dtVar::ListOnly = 1;
|
||||||
// Add clients who are normally AFK
|
// Add clients who are normally AFK
|
||||||
$dtVar::AFKList[$AFKCount++] = "";
|
$dtVar::AFKList[$AFKCount++] = "";
|
||||||
$dtVar::AFKList[$AFKCount++] = "";
|
$dtVar::AFKList[$AFKCount++] = "";
|
||||||
// Loop Check Timer
|
// Loop Check Timer
|
||||||
// How often do you want a AFKLoop. 1000 * 30 is 30 seconds
|
// How often do you want a AFKLoop. 1000 * 30 is 30 seconds
|
||||||
$dtVar::AFKloop = 1000 * 30;
|
$dtVar::AFKloop = 1000 * 30;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
@ -29,14 +29,14 @@ else
|
||||||
|
|
||||||
package DT_AFKPackage
|
package DT_AFKPackage
|
||||||
{
|
{
|
||||||
|
|
||||||
function CreateServer( %mission, %missionType )
|
function CreateServer( %mission, %missionType )
|
||||||
{
|
{
|
||||||
parent::CreateServer( %mission, %missionType );
|
parent::CreateServer( %mission, %missionType );
|
||||||
|
|
||||||
//Call to start AFKTimeout update
|
//Call to start AFKTimeout update
|
||||||
DT_AFKtimeoutLoop();
|
DT_AFKtimeoutLoop();
|
||||||
|
|
||||||
// Prevent package from being activated if it is already
|
// Prevent package from being activated if it is already
|
||||||
if(!isActivePackage(DT_AFKOverrides) && $dtVar::ListOnly)
|
if(!isActivePackage(DT_AFKOverrides) && $dtVar::ListOnly)
|
||||||
activatePackage(DT_AFKOverrides);
|
activatePackage(DT_AFKOverrides);
|
||||||
|
|
@ -54,14 +54,14 @@ package DT_AFKOverrides
|
||||||
function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch)
|
function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch)
|
||||||
{
|
{
|
||||||
Parent::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch);
|
Parent::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch);
|
||||||
|
|
||||||
DT_AFKStatusConnect(%client);
|
DT_AFKStatusConnect(%client);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GameConnection::onDrop(%client, %reason)
|
function GameConnection::onDrop(%client, %reason)
|
||||||
{
|
{
|
||||||
Parent::onDrop(%client, %reason);
|
Parent::onDrop(%client, %reason);
|
||||||
|
|
||||||
DT_AFKStatusDrop(%client);
|
DT_AFKStatusDrop(%client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,74 +71,78 @@ function GameConnection::onDrop(%client, %reason)
|
||||||
|
|
||||||
function DT_AFKStatusConnect(%client)
|
function DT_AFKStatusConnect(%client)
|
||||||
{
|
{
|
||||||
for(%x = 1; %x <= $AFKCount; %x++)
|
if($dtVar::AFKtime != 0 && !$Host::TournamentMode) //0 minutes disables
|
||||||
{
|
{
|
||||||
%guid = $dtVar::AFKList[%x];
|
for(%x = 1; %x <= $AFKCount; %x++)
|
||||||
if(%client.guid $= %guid && %guid !$= "")
|
|
||||||
{
|
{
|
||||||
$DT_AFKStatus = "ACTIVE";
|
%guid = $dtVar::AFKList[%x];
|
||||||
$DT_AFKListCount++;
|
if(%client.guid $= %guid && %guid !$= "")
|
||||||
|
{
|
||||||
|
$DT_AFKStatus = "ACTIVE";
|
||||||
|
$DT_AFKListCount++;
|
||||||
|
%client.dtAFK = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DT_AFKStatusDrop(%client)
|
function DT_AFKStatusDrop(%client)
|
||||||
{
|
{
|
||||||
for(%x = 1; %x <= $AFKCount; %x++)
|
if(%client.dtAFK)
|
||||||
{
|
$DT_AFKListCount = $DT_AFKListCount - 1;
|
||||||
%guid = $dtVar::AFKList[%x];
|
|
||||||
if(%client.guid $= %guid && %guid !$= "")
|
// for(%x = 1; %x <= $AFKCount; %x++)
|
||||||
$DT_AFKListCount = $DT_AFKListCount - 1;
|
// {
|
||||||
}
|
// %guid = $dtVar::AFKList[%x];
|
||||||
|
// if(%client.guid $= %guid && %guid !$= "")
|
||||||
|
// $DT_AFKListCount = $DT_AFKListCount - 1;
|
||||||
|
// }
|
||||||
|
|
||||||
if($DT_AFKListCount $= 0) //Wont set IDLE until all List Clients are off the server
|
if($DT_AFKListCount $= 0) //Wont set IDLE until all List Clients are off the server
|
||||||
$DT_AFKStatus = "IDLE";
|
$DT_AFKStatus = "IDLE";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function DT_AFKtimeoutLoop()
|
function DT_AFKtimeoutLoop()
|
||||||
{
|
{
|
||||||
//echo($DT_AFKStatus);
|
//echo($DT_AFKStatus);
|
||||||
|
|
||||||
switch$($DT_AFKStatus)
|
switch$($DT_AFKStatus)
|
||||||
{
|
{
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
if($dtVar::AFKtime != 0 && !$Host::TournamentMode)
|
if($dtVar::AFKtime != 0 && !$Host::TournamentMode) //0 minutes disables
|
||||||
{ //0 minutes disables
|
|
||||||
if($dtVar::ListOnly)
|
|
||||||
{
|
{
|
||||||
for(%i = 0; %i < ClientGroup.getCount(); %i ++)
|
if($dtVar::ListOnly)
|
||||||
{
|
{
|
||||||
%client = ClientGroup.getObject(%i);
|
for(%i = 0; %i < ClientGroup.getCount(); %i ++)
|
||||||
for(%x = 1; %x <= $AFKCount; %x++)
|
{
|
||||||
{
|
%client = ClientGroup.getObject(%i);
|
||||||
%guid = $dtVar::AFKList[%x];
|
if(%client.dtAFK)
|
||||||
if(!%client.isAIControlled() && isObject(%client.player) && %client.player.getState() !$= "Dead" )
|
{
|
||||||
{
|
if(!%client.isAIControlled() && isObject(%client.player) && %client.player.getState() !$= "Dead")
|
||||||
if(%client.guid $= %guid && %guid !$= "")
|
AFKChk(%client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(%i = 0; %i < ClientGroup.getCount(); %i ++)
|
||||||
|
{
|
||||||
|
%client = ClientGroup.getObject(%i);
|
||||||
|
if(!%client.isAIControlled() && isObject(%client.player) && %client.player.getState() !$= "Dead")
|
||||||
AFKChk(%client);
|
AFKChk(%client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
case IDLE:
|
||||||
else
|
//Do Nothing
|
||||||
{
|
|
||||||
for(%i = 0; %i < ClientGroup.getCount(); %i ++)
|
|
||||||
{
|
|
||||||
%client = ClientGroup.getObject(%i);
|
|
||||||
if(!%client.isAIControlled() && isObject(%client.player) && %client.player.getState() !$= "Dead")
|
|
||||||
AFKChk(%client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case IDLE:
|
|
||||||
//Do Nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isEventPending($dtVar::AFKloopSchedule))
|
if(isEventPending($dtVar::AFKloopSchedule))
|
||||||
cancel($dtVar::AFKloopSchedule);
|
cancel($dtVar::AFKloopSchedule);
|
||||||
|
|
||||||
$dtVar::AFKloopSchedule = schedule($dtVar::AFKloop, 0, "DT_AFKtimeoutLoop");
|
$dtVar::AFKloopSchedule = schedule($dtVar::AFKloop, 0, "DT_AFKtimeoutLoop");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -146,7 +150,7 @@ function DT_AFKtimeoutLoop()
|
||||||
function AFKChk(%client)
|
function AFKChk(%client)
|
||||||
{
|
{
|
||||||
if(%client.player.curTransform $= %client.player.getTransform())
|
if(%client.player.curTransform $= %client.player.getTransform())
|
||||||
{//checks to see if there position and rotation are the same.
|
{//checks to see if there position and rotation are the same.
|
||||||
%client.player.afkTimer += $dtVar::AFKloop;
|
%client.player.afkTimer += $dtVar::AFKloop;
|
||||||
if(%client.player.afkTimer >= $dtVar::AFKtime)
|
if(%client.player.afkTimer >= $dtVar::AFKtime)
|
||||||
{
|
{
|
||||||
|
|
@ -158,8 +162,8 @@ function AFKChk(%client)
|
||||||
{
|
{
|
||||||
%client.player.afkTimer = 0;//reset if moving
|
%client.player.afkTimer = 0;//reset if moving
|
||||||
}
|
}
|
||||||
|
|
||||||
%client.player.curTransform = %client.player.getTransform();//save current transform
|
%client.player.curTransform = %client.player.getTransform();//save current transform
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -169,29 +173,29 @@ function DefaultGame::AFKForceObserver(%game, %client)
|
||||||
//make sure we have a valid client...
|
//make sure we have a valid client...
|
||||||
if (%client <= 0)
|
if (%client <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// first kill this player
|
// first kill this player
|
||||||
if(%client.player)
|
if(%client.player)
|
||||||
%client.player.scriptKill(0);
|
%client.player.scriptKill(0);
|
||||||
|
|
||||||
if( %client.respawnTimer )
|
if( %client.respawnTimer )
|
||||||
cancel(%client.respawnTimer);
|
cancel(%client.respawnTimer);
|
||||||
|
|
||||||
%client.respawnTimer = "";
|
%client.respawnTimer = "";
|
||||||
|
|
||||||
// remove them from the team rank array
|
// remove them from the team rank array
|
||||||
%game.removeFromTeamRankArray(%client);
|
%game.removeFromTeamRankArray(%client);
|
||||||
|
|
||||||
// place them in observer mode
|
// place them in observer mode
|
||||||
%client.lastObserverSpawn = -1;
|
%client.lastObserverSpawn = -1;
|
||||||
%client.observerStartTime = getSimTime();
|
%client.observerStartTime = getSimTime();
|
||||||
|
|
||||||
|
|
||||||
%client.camera.getDataBlock().setMode( %client.camera, "observerFly" );
|
%client.camera.getDataBlock().setMode( %client.camera, "observerFly" );
|
||||||
messageClient(%client, 'MsgClientJoinTeam', '\c2You have been placed into observer mode due to inactivity.', %client.name, game.getTeamName(0), %client, 0 );
|
messageClient(%client, 'MsgClientJoinTeam', '\c2You have been placed into observer mode due to inactivity.', %client.name, game.getTeamName(0), %client, 0 );
|
||||||
logEcho(%client.nameBase@" (cl "@%client@") was forced into observer mode due to inactivity");
|
logEcho(%client.nameBase@" (cl "@%client@") was forced into observer mode due to inactivity");
|
||||||
%client.lastTeam = %client.team;
|
%client.lastTeam = %client.team;
|
||||||
|
|
||||||
if($Host::TournamentMode)
|
if($Host::TournamentMode)
|
||||||
{
|
{
|
||||||
if(!$matchStarted)
|
if(!$matchStarted)
|
||||||
|
|
@ -208,25 +212,25 @@ function DefaultGame::AFKForceObserver(%game, %client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch client to team 0 (observer)
|
// switch client to team 0 (observer)
|
||||||
%client.team = 0;
|
%client.team = 0;
|
||||||
%client.player.team = 0;
|
%client.player.team = 0;
|
||||||
setTargetSensorGroup( %client.target, %client.team );
|
setTargetSensorGroup( %client.target, %client.team );
|
||||||
%client.setSensorGroup( %client.team );
|
%client.setSensorGroup( %client.team );
|
||||||
|
|
||||||
// set their control to the obs. cam
|
// set their control to the obs. cam
|
||||||
%client.setControlObject( %client.camera );
|
%client.setControlObject( %client.camera );
|
||||||
commandToClient(%client, 'setHudMode', 'Observer');
|
commandToClient(%client, 'setHudMode', 'Observer');
|
||||||
|
|
||||||
// display the hud
|
// display the hud
|
||||||
//displayObserverHud(%client, 0);
|
//displayObserverHud(%client, 0);
|
||||||
updateObserverFlyHud(%client);
|
updateObserverFlyHud(%client);
|
||||||
|
|
||||||
messageAllExcept(%client, -1, 'MsgClientJoinTeam', '\c2%1 has been placed into observer mode due to inactivity.', %client.name, game.getTeamName(0), %client, 0 );
|
messageAllExcept(%client, -1, 'MsgClientJoinTeam', '\c2%1 has been placed into observer mode due to inactivity.', %client.name, game.getTeamName(0), %client, 0 );
|
||||||
|
|
||||||
updateCanListenState( %client );
|
updateCanListenState( %client );
|
||||||
|
|
||||||
// call the onEvent for this game type
|
// call the onEvent for this game type
|
||||||
%game.onClientEnterObserverMode(%client); //Bounty uses this to remove this client from others' hit lists
|
%game.onClientEnterObserverMode(%client); //Bounty uses this to remove this client from others' hit lists
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue