May 16, 2022, 02:33:06 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Due to a rise in bot activity, new posters need to be approved before posting.

Join the community Discord server!

Pages: [1]

Author Topic: [Server] Server-side Afk checker (AntiIdle)  (Read 1215 times)

[FR]YB

  • 2013 Haxxy Award Winner
  • *
  • Karma: 28
  • Offline Offline
  • Posts: 642
  • There are 11 people playing holy sh
[Server] Server-side Afk checker (AntiIdle)
« on: June 08, 2019, 06:28:58 pm »

(See this topic for why this plugin exists)

What it does
Sends players that stay at the exact same coordinates for 45 seconds into the spectator team.
Meant to prevent idling/inactive players from sitting in the same place and taking up a slot in the team, or stalling a round of arena.

Install
Download the attached .gml file, and put it into your Plugins folder
Server side plugin (will work for hosts, but joining players will not have any effect on the server)
Built for 2.9.2

Code: (Source) [Select]
globalvar AFKChecker;
AFKChecker = id;

TIME_FRAMES = 45 * 30;

object_event_add(Character, ev_create, 0, '
    AFKChecker_afktimer = 0;
');

object_event_add(Character, ev_step, ev_step_end, '
    if (global.isHost) {
        if (variable_local_exists("x_previous"))
        if (x == x_previous) && (y == y_previous) {
            AFKChecker_afktimer += 1 * global.delta_factor;
            if (AFKChecker_afktimer > AFKChecker.TIME_FRAMES) {
           
           
                if(player.object != -1)
                {
                    if (!instance_exists(lastDamageDealer) || lastDamageDealer == player)
                    {
                        sendEventPlayerDeath(player, player, noone, DAMAGE_SOURCE_BID_FAREWELL);
                        doEventPlayerDeath(player, player, noone, DAMAGE_SOURCE_BID_FAREWELL);
                    }
                    else
                    {
                        var assistant;
                        assistant = secondToLastDamageDealer;
                        if (lastDamageDealer.object)
                            if (lastDamageDealer.object.healer)
                                assistant = lastDamageDealer.object.healer;
                        sendEventPlayerDeath(player, lastDamageDealer, assistant, DAMAGE_SOURCE_FINISHED_OFF);
                        doEventPlayerDeath(player, lastDamageDealer, assistant, DAMAGE_SOURCE_FINISHED_OFF);
                    }
                }
                player.team = TEAM_SPECTATOR;
                ServerPlayerChangeteam(ds_list_find_index(global.players, player), player.team, global.sendBuffer);
                clearPlayerDominations(player);
                with(GameServer) {
                    ServerBalanceTeams();
                }
            }
        } else {
            AFKChecker_afktimer = 0;
        }
    }
');
« Last Edit: July 16, 2019, 02:16:17 am by [FR]YB »
Logged

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1305
  • Offline Offline
  • Posts: 12416
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #1 on: June 24, 2019, 07:44:45 pm »

Why are you checking to see if the variable x_previous exists when GM has aliases for your previous x and y positions (xprevious and yprevious respectively). Also, wouldn't it be a little counterintuitive to run this if the server has chat? With that tiny timeframe I mean.
« Last Edit: June 24, 2019, 08:25:03 pm by Saniblues »
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

notarctic

  • just arctic, what gives?
  • ******
  • Karma: 8
  • Offline Offline
  • Posts: 4904
  • 👎👀 bad aim ba̷̶ ԁ aIm 👎 thats❌ some bad 👎👎aim
    • arcticland
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #2 on: June 27, 2019, 12:22:14 pm »

Quote
exact same coordinates
what's stopping someone from using a script to move a pixel or jump every few seconds?
Logged
[1:37:51 PM] Derpduck: arctic u need to quote ppl that make shit posts in case they edit them
[4:20:15 PM] Rubeus Hashgrid: i cant discover anything fuck you imageshack

Derpduck

  • 2011 Haxxy Finalist
  • *
  • Karma: 42
  • Offline Offline
  • Posts: 5770
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #3 on: June 27, 2019, 04:30:57 pm »

Quote
exact same coordinates
what's stopping someone from using a script to move a pixel or jump every few seconds?
Being sane enough to not make a script to not get AFK kicked from an empty server.

PrOF

  • Full Member
  • ***
  • Karma: 43
  • Offline Offline
  • Posts: 599
  • Sometimes a dev. Only sometimes
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #4 on: June 27, 2019, 05:21:09 pm »

Quote
exact same coordinates
what's stopping someone from using a script to move a pixel or jump every few seconds?
Nothing, but that also fools the built-in afk kick, so it's not worse than that
Logged

[FR]YB

  • 2013 Haxxy Award Winner
  • *
  • Karma: 28
  • Offline Offline
  • Posts: 642
  • There are 11 people playing holy sh
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #5 on: June 30, 2019, 01:31:17 pm »

Why are you checking to see if the variable x_previous exists when GM has aliases for your previous x and y positions (xprevious and yprevious respectively).
Oh, I thought x_previous actually was the built-in, and that it didn't work sometimes for wonky GM reasons. I just updated the code to change that.

Also, wouldn't it be a little counterintuitive to run this if the server has chat? With that tiny timeframe I mean.
I don't think so, the plugin doesn't kick, it just forces you into spectator team, which is what the game is supposed to do anyway. You don't want someone in your team to stay idle for 30 seconds or more.

Quote
exact same coordinates
what's stopping someone from using a script to move a pixel or jump every few seconds?
We'll cross that bridge when we come to it

[FR]YB

  • 2013 Haxxy Award Winner
  • *
  • Karma: 28
  • Offline Offline
  • Posts: 642
  • There are 11 people playing holy sh
Re: [Server] Server-side Afk checker (AntiIdle)
« Reply #6 on: July 16, 2019, 02:22:20 am »

Why are you checking to see if the variable x_previous exists when GM has aliases for your previous x and y positions (xprevious and yprevious respectively). Also, wouldn't it be a little counterintuitive to run this if the server has chat? With that tiny timeframe I mean.
I just reverted the plugin code to do that again. xprevious and yprevious only differ from x and y during event_step_normal, which means that's the only event in which I can destroy a Character to put them into spectator team. However, destroying a Character in normal step event causes an error with quote's bubbles (and possibly other projectiles), and I don't quite yet understand how bubbles are destroyed when their owner dies. It looks like the bubbles are destroyed if they're more than 160 pixels away from their owner, so if there's no owner the distance is infinite which destroys them? I'm really unsure.
« Last Edit: July 16, 2019, 02:22:46 am by [FR]YB »
Logged
Pages: [1]
 

Page created in 0.043 seconds with 36 queries.