September 07, 2025, 04:26:45 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: [1]

Author Topic: [Server] Dynamic healer limit  (Read 1232 times)

[FR]YB

  • 2013 Haxxy Award Winner
  • *
  • Karma: 28
  • Offline Offline
  • Posts: 642
  • There are 11 people playing holy sh
[Server] Dynamic healer limit
« on: September 09, 2018, 11:26:35 am »

Restricts healer, until a certain amount of players are in the server. 8 players or more enables 1 healer; 12 players or more, enables 2 healers; 18 or more, 3 healers.
Class limits are synced with clients when it changes. Current healers won't get kicked out of their class if the class limit decreases.

This is a plugin for server hosts. It won't do anything if you use the plugin and join a server.
If you host a server and want to use this plugin, download the attached gml file and put it into your Plugins folder.

Code: [Select]
// Restricts healer, until a certain amount of players are in the server.
// 8 players or more enables 1 healer
// 12 players or more enables 2 healers
// 18 players or more enables 3 healers

// YB, 2018
// Everyone is allowed to modify or republish this plugin freely

globalvar dynamicMedicLimit;
dynamicMedicLimit = id;

ONE_MED_FROM = 8
TWO_MEDS_FROM = 12
THREE_MEDS_FROM = 18

controller = object_add();
object_set_persistent(controller, true);

object_event_add(PlayerControl, ev_create, 0, '
    if (global.isHost) {
        instance_create(0,0,dynamicMedicLimit.controller);
    }
');
object_event_add(PlayerControl, ev_destroy, 0, '
    with(dynamicMedicLimit.controller) {
        instance_destroy();
    }
');


object_event_add(controller, ev_step, ev_step_end, '
    var new, current, nbPlayers;
   
    nbPlayers = ds_list_size(global.players) - global.dedicatedMode;
    current = global.classlimits[CLASS_MEDIC];
   
    new = 0;
    if (nbPlayers >= dynamicMedicLimit.ONE_MED_FROM) {
        new = 1;
    }
    if (nbPlayers >= dynamicMedicLimit.TWO_MEDS_FROM) {
        new = 2;
    }
    if (nbPlayers >= dynamicMedicLimit.THREE_MEDS_FROM) {
        new = 3;
    }
   
    // update if changed
    if (new != current) {
        global.classlimits[CLASS_MEDIC] = new;
        serializeState(FULL_UPDATE, global.sendBuffer);
    }
');

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1910
  • Almost too much seasoning.
Re: [Server] Dynamic healer limit
« Reply #1 on: September 09, 2018, 12:26:52 pm »

lol, didn't I mention this ages ago and people denied it?

Thanks again YB, solid plug
Logged

<3 Bustatunez

AKVARI

  • Full Member
  • ***
  • Karma: 11
  • Offline Offline
  • Posts: 508
Re: [Server] Dynamic healer limit
« Reply #2 on: September 09, 2018, 01:22:25 pm »

lol, didn't I mention this ages ago and people denied it?
That's like every request made for GG2.

Anyways, atleast YB won't have to host 2 servers now.

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12519
  • Another one --
Re: [Server] Dynamic healer limit
« Reply #3 on: September 09, 2018, 04:04:36 pm »

if it was made as a feature request it was rejected for being too highly specific
as a plugin it's 100% okay and even desirable imo
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters
Pages: [1]
 

Page created in 0.035 seconds with 31 queries.