November 23, 2024, 03:37:12 am

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] 2

Author Topic: Server-sent plugins FAQ  (Read 57345 times)

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Server-sent plugins FAQ
« on: March 12, 2013, 04:17:46 pm »

What is a "server-sent plugin"?
Server-sent plugins are a new feature in GG2 version 2.5. They allow servers to have a set of plugins which the server and players automatically download.

Despite the name, "server-sent" plugins are not sent by the server. Rather, the server sends a list of plugin names, which are used to get the plugins from http://www.ganggarrison.com/plugins/ (see "How safe are they?" below)

Why don't they work in Gang Garrison 2.5.x any more?
See this topic: http://www.ganggarrison.com/forums/index.php?topic=34113.0

Why do I get an error when I extract it to my plugins folder and run it?
Server-sent plugins are not supposed to be downloaded by you. Instead, just put the names of the plugins you want to use in your gg2.ini file (see "How do I use server-sent plugins?") and they will be automatically downloaded by your server and its players.

Plugins can detect whether they are running as server-sent plugins by checking whether "isServerSentPlugin" is set to true on their PluginEnvironment instance.

How do I use server-sent plugins?
If you want to host a server using server-sent plugins, find out the names of the plugins you want to use. You don't need to download them. Just edit the following two lines in your gg2.ini file:
Code: [Select]
ServerPluginList=
ServerPluginsRequired=0
After ServerPluginList you can put a comma-separated list of plugin names (see: http://www.ganggarrison.com/plugins/). There must not be any spaces between the plugin names and the commas. Here's an example:
Code: [Select]
ServerPluginList=lowgravity,can_you_feel_the_sunshineAfter ServerPluginsRequired you can either put 1 (requires plugins to join server) or 0 (plugins are optional but suggested to client).
If you don't want any plugins, just leave the ServerPluginList= field blank.

If you want to join a server using server-sent plugins, you'll be prompted if you want to download them. If they are required, you can either download them or disconnect. If they aren't required, you can choose to continue connecting without downloading them. You can disable the prompts in the settings. If you do this, it will download them without asking you. However, this might be dangerous. (see "How safe are they?" below)

How safe are they?
Plugins can do almost anything. They can download applications and execute them, delete files, spy on you, etc. Because of this, server-sent plugins are not downloaded like maps are, because then a server could send a malicious plugin. Instead, server-sent plugins are always downloaded from http://www.ganggarrison.com/plugins/, which only has plugins that have been screened by me or other developers. Because of this you shouldn't need to worry, but we are not perfect and something might slip past us. If you are paranoid, avoid joining servers with plugins.

How do I make a server-sent plugin?
A server-sent plugin is just a zip file with a plugin.gml file in it. When it is downloaded, it is extracted to a temporary folder, and plugin.gml is executed with argument0 being the path of the temporary folder (does NOT end in a backslash, add it yourself), so that the plugin can find any resource files that were in the zip file. The temporary folder is cleaned up for you when GG2 exits.

Plugin names must be composed only of lowercase letters, digits and underscores, and be a minimum of one letter long. If the plugin name doesn't fit this format, GG2 will error and won't load it.

When the user leaves that server, they have to quit or restart GG2, so don't worry about having to disable/enable your plugin. Server-sent plugins for a given host server are also executed on the host server itself, so you should account for this with global.isHost checks.

When you want to debug a server-sent plugin, you can create a special folder called ServerPluginsDebug in your GG2 folder, and place your plugin zip file in there with the correct .zip extension, e.g. lowgravity.zip. GG2 will check in that folder first before trying to download it.

Once you have made your server-sent plugin, you can get it reviewed and hopefully onto http://www.ganggarrison.com/plugins/ so other people can use it. Send me a PM with a link to the forum thread for the plugin, its name and the zip file, and I'll review it and either add it or ask you to change some things before it can be added. Please agree to the terms and conditions.

If you're looking for server-sent plugin examples, just download one of the existing plugins: http://www.ganggarrison.com/plugins/

How do I do networking with server-sent plugins?

From Gang Garrison 2.7.3 onwards, server-sent plugins are executed within a PluginEnvironment instance with four properties: directory (directory the plugin was extracted to), packetID (the packetID value), isServerSentPlugin (set to 1) and isLocalPlugin (set to 0). Prior to 2.7.3, the only way to get the packetID and directory was from argument1 and argument0 respectively, which are still set for compatibility.

All server-sent plugins now get a special packetID that can be used with the PluginPacket* functions to send buffers encapsulated in the new PLUGIN_PACKET packet, and to receive them. Receiving, clients get just the buffer (from the server), servers get the buffer (from the client) and the Player object (corresponding to the client). Sending, servers send the buffer to all clients, or a specific client, and clients send the buffer to just the server.

The buffers mentioned here are Faucet Networking buffers, since Gang Garrison 2 uses MedO's Faucet Networking extension. Full documentation on Faucet Networking is provided in the form of a PDF included in the ZIP file for each release. You can find Faucet Networking releases here on GitHub: https://github.com/Medo42/Faucet-Networking-Extension/releases (at the time of writing, GG2 used version 1.2.1). You need not concern yourself with any of the TCP or UDP functions, only how buffers work.

  • When a server-sent plugin is run, `argument1` is a special packetID value
  • PluginPacketSend(packetID, buffer[, loopback]) sends the buffer specified (maximum 65535 bytes), to the server (if client) or to all clients (if server), with that packetID, returns false on failure, else true. Since GG2 v2.6.9 there is an optional argument, loopback. If it is true on the server, the server will also send the buffer to itself. The buffer you give it will not be touched by GG2, you need to destroy it yourself.
  • PluginPacketSendTo(packetID, buffer, player) (server-only) sends the buffer specified (maximum 65535 bytes), to the client specified by the player Player object, with that packetID, returns false on failure, else true. Since GG2 v2.6.9, player can be global.myself on the server and it will send the buffer to itself. The buffer you give it will not be touched by GG2, you need to destroy it yourself.
  • PluginPacketPop(packetID) discards the data for the first packet received, from the server (if client) or from a client (if server), if any (returning false if not, true if so), for that packetID. This will destroy the buffer that PluginPacketGetBuffer would get you.
  • PluginPacketGetBuffer(packetID) returns the buffer of the first packet received, from the server (if client) or from a client (if server), if any (returning -1 if not), for that packetID. Buffer should not be modified or destroyed by you, use PluginPacketPop.
  • PluginPacketGetPlayer(packetID) returns the Player object representing the client responsible for the first packet received, from a client (if server, otherwise returns `noone`), if any (returning -1 if not), for that packetID.

How does plugin caching work?

It "just works" and you don't have to worry about it. The first time your client sees a particular version of a plugin, it will save a copy in the cache. Later, if it needs that particular version of that plugin again, it will retrieve it from the cache, instead of downloading it again. If you delete the cache (the ServerPluginsCache folder), nothing bad will happen, but GG2 will have to redownload any plugins that were in that cache when it next needs them.
« Last Edit: April 19, 2016, 08:06:02 am by ajf »
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

Dusty

  • 2012 Haxxy Award Winner
  • *
  • Karma: -78
  • Offline Offline
  • Posts: 10312
  • Dust in a box under a table
Re: Server-sent plugins FAQ
« Reply #1 on: May 26, 2013, 02:51:51 am »

Could we get an example of how to use pluginetworking?

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3625
    • My own website
Re: Server-sent plugins FAQ
« Reply #2 on: May 26, 2013, 03:09:56 am »

You could look at the already made server-sent plugins :P
Removed the actual functional part of my space plugin and replaced it with a comment (you still have to bear with the space themed variables though)

Code: (top of the plugin) [Select]
global.spacePacketID = argument1;
Code: (step event of any object, i usuallly use PlayerControl) [Select]
   //send your custom event
   if keyboard_check_pressed(global.down) && global.myself.object != -1 && !instance_exists(InGameMenuController) {
        var spaceBuffer;
        spaceBuffer = buffer_create();
        write_ubyte(spaceBuffer,ds_list_find_index(global.players,global.myself));
        PluginPacketSend(global.spacePacketID,spaceBuffer);
        buffer_destroy(spaceBuffer);
        if global.isHost {
            //The host doesn't send the event to itself so that should be handled here
        }
    }
 
    //process the custom event
    if global.isHost {
        while(PluginPacketGetBuffer(global.spacePacketID) != -1) {
            var spaceBuffer, space_player;
            spaceBuffer = PluginPacketGetBuffer(global.spacePacketID);
            space_player = PluginPacketGetPlayer(global.spacePacketID);
            if space_player.object != -1 && instance_exists(space_player.object) {
                //The host executes the event for other players here (if the player has an object in this case)
               
                buffer_clear(spaceBuffer);
                write_ubyte(spaceBuffer, ds_list_find_index(global.players,space_player));
                PluginPacketSend(global.spacePacketID,spaceBuffer);
            }
           
            buffer_destroy(spaceBuffer);
            PluginPacketPop(global.spacePacketID);
        }
    } else {
        while(PluginPacketGetBuffer(global.spacePacketID) != -1) {
            var spaceBuffer, space_player;
            spaceBuffer = PluginPacketGetBuffer(global.spacePacketID);
            space_player = ds_list_find_value(global.players,read_ubyte(spaceBuffer));
            if space_player != -1 {
                if space_player.object != -1 && instance_exists(space_player.object) {
                    //The client executes the event for any player here.
                }
            }       
            buffer_destroy(spaceBuffer);
            PluginPacketPop(global.spacePacketID);
        }
    }
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Re: Server-sent plugins FAQ
« Reply #3 on: May 26, 2013, 03:49:08 am »

Btw, no need to destroy buffers that you got from PluginPacketGetBuffer, since PluginPacketPop does that for you. Also, it's not a good idea to use the same variable name for sending and receiving buffers.
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3625
    • My own website
Re: Server-sent plugins FAQ
« Reply #4 on: May 26, 2013, 03:54:48 am »

ok :P
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

Dusty

  • 2012 Haxxy Award Winner
  • *
  • Karma: -78
  • Offline Offline
  • Posts: 10312
  • Dust in a box under a table
Re: Server-sent plugins FAQ
« Reply #5 on: May 26, 2013, 04:05:28 am »

So, I made a folder called "ServerPluginsDebug", dropped a .zip file, named Sprites (lazy naming), with a plugin.gml into it, and added Sprites to my .ini
Apparently it's an invalid plugin.
Oh. It seems like it HAS to be lowercase. That seems silly.
« Last Edit: May 26, 2013, 04:06:53 am by Dusty »
Logged

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Re: Server-sent plugins FAQ
« Reply #6 on: May 26, 2013, 05:00:49 am »

So, I made a folder called "ServerPluginsDebug", dropped a .zip file, named Sprites (lazy naming), with a plugin.gml into it, and added Sprites to my .ini
Apparently it's an invalid plugin.
Oh. It seems like it HAS to be lowercase. That seems silly.
I didn't want to type out the 26 uppercase characters too :P
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Re: Server-sent plugins FAQ
« Reply #7 on: July 07, 2013, 08:33:14 pm »

Updated to note caching.
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

notarctic

  • just arctic, what gives?
  • ******
  • Karma: 8
  • Offline Offline
  • Posts: 4888
  • 👎👀 bad aim ba̷̶ ԁ aIm 👎 thats❌ some bad 👎👎aim
Re: Server-sent plugins FAQ
« Reply #8 on: August 01, 2013, 12:49:18 am »

Quote
Why don't they work in Gang Garrison 2.5.x any more?
See this topic: http://www.ganggarrison.com/forums/index.php?topic=34113.0
for anyone using 2.5 as a mod (highly doubt it but meh) here's the legacy repository you can direct your game to
http://arcticmustang.github.io/gg2plugins
« Last Edit: January 27, 2014, 10:11:28 pm by arctic »
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

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Re: Server-sent plugins FAQ
« Reply #9 on: August 31, 2013, 04:08:29 pm »

Quote
Why don't they work in Gang Garrison 2.5.x any more?
See this topic: http://www.ganggarrison.com/forums/index.php?topic=34113.0
for anyone using 2.5 as a mod (highly doubt it but meh) here's the legacy repository you can direct your game to
http://arcticmustang.github.io/gg2plugins
orrrrr just use ServerPluginsDebug?
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

iLegend

  • 2013 Haxxy Award Winner
  • *****
  • Karma: 0
  • Offline Offline
  • Posts: 869
  • Force is always the answer.
    • Mah Resume
Re: Server-sent plugins FAQ
« Reply #10 on: August 31, 2013, 07:48:01 pm »

sooooo how exactly do you test server sent plugins.
Logged
<SecretMan> do i put BotAim.gml in plugins folder?
i hear los angeles is pretty good for casual sex with minors

notarctic

  • just arctic, what gives?
  • ******
  • Karma: 8
  • Offline Offline
  • Posts: 4888
  • 👎👀 bad aim ba̷̶ ԁ aIm 👎 thats❌ some bad 👎👎aim
Re: Server-sent plugins FAQ
« Reply #11 on: August 31, 2013, 08:02:07 pm »

sooooo how exactly do you test server sent plugins.
uh like what are you trying to do?
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

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3421
  • she's never quite as dead as you think
Re: Server-sent plugins FAQ
« Reply #12 on: August 31, 2013, 08:22:59 pm »

sooooo how exactly do you test server sent plugins.
/ServerPluginsDebug?
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

notarctic

  • just arctic, what gives?
  • ******
  • Karma: 8
  • Offline Offline
  • Posts: 4888
  • 👎👀 bad aim ba̷̶ ԁ aIm 👎 thats❌ some bad 👎👎aim
Re: Server-sent plugins FAQ
« Reply #13 on: August 31, 2013, 08:24:29 pm »

sooooo how exactly do you test server sent plugins.
/ServerPluginsDebug?
stick your plugin in there and put the plugin name into the ini
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

iLegend

  • 2013 Haxxy Award Winner
  • *****
  • Karma: 0
  • Offline Offline
  • Posts: 869
  • Force is always the answer.
    • Mah Resume
Re: Server-sent plugins FAQ
« Reply #14 on: August 31, 2013, 10:02:47 pm »

its pretty annoying zipping the plugin every time I wanna test it :(
Logged
<SecretMan> do i put BotAim.gml in plugins folder?
i hear los angeles is pretty good for casual sex with minors
Pages: [1] 2
 

Page created in 0.035 seconds with 50 queries.