Catalog News Guides Community For contributors
Everything for CS 1.6 / CSS / CS:GO servers - Plugins | Builds | Models | Maps » Articles » Articles about CS 1.6 » Pawn from Scratch? Invite to join a STEAM group

Pawn from Scratch? Invite to join a STEAM group

06.06.2024, 16:55adminViews: 227Comments: 0
Pawn from Scratch? Invite to join a STEAM group

About this content

Pawn с Нуля?  Инвайн на вступление в группу STEAM
Pawn from Scratch? Invite to join a STEAM group
CS 1.6 servers can become not only a place to play, but also a community that brings players together beyond the game. One effective way to create such a community is to invite players to a Steam group. In this article, we’ll look at how to write a plugin for your CS 1.6 server that automatically invites players to your Steam group.

Step 1: Installing AMX Mod X

AMX Mod X is a popular modification for CS 1.6 servers that lets you create and use various plugins. To get started, you need to install AMX Mod X on your server:

  1. Download AMX Mod X from the official website AMX Mod X.
  2. Unpack the downloaded archive and copy the files to your server’s directory.
  3. Configure the files  liblist.gam и metamod.ini to load AMX Mod X when the server starts.

Step 2: Getting a Steam API Key

To interact with the Steam API, you’ll need an API key. Here’s how to get one:

  1. Visit Steam API.
  2. Sign in to your Steam account.
  3. Get your personal API key, which will be used for requests to the Steam API.

Step 3: Installing the amx_http plugin

To send HTTP requests from the server, we’ll need the plugin amx_http. Follow these steps:

  1. Download and install amx_http from the GitHub repository.
  2. Copy the plugin files to the  addons/amxmodx/plugins directory of your server.
  3. Add the line  amx_http.amxx to the file  plugins.ini in the  directory addons/amxmodx/configs.

Step 4: Writing a plugin to invite players

Let’s create a plugin that will send players a message with a link to join your Steam group.

  1. Create a new file in the  addons/amxmodx/scripting, for example  steam_group_inviter.sma.
  2. Add the following code:            
  3. #include <amxmodx>

    #include <hamsandwich>

    #include <amx_http>


    #define PLUGIN "Steam Group Inviter"

    #define VERSION "1.0"

    #define AUTHOR "Author"


    // Your Steam API key

    #define STEAM_API_KEY "YOUR_STEAM_API_KEY"

    // Your Steam group ID

    #define STEAM_GROUP_ID "YOUR_STEAM_GROUP_ID"


    public plugin_init() {

        register_plugin(PLUGIN, VERSION, AUTHOR);

        register_event("ClientConnect", "OnClientConnect", "a");

    }


    public OnClientConnect(id) {

        new authid[32];

        get_user_authid(id, authid, charsmax(authid));


        // Формирование сообщения со ссылкой на группу

        new group_invite_message[128];

        format(group_invite_message, charsmax(group_invite_message), "Присоединяйтесь к нашей Steam-группе: https://steamcommunity.com/groups/%s", STEAM_GROUP_ID);


        client_print(id, print_chat, group_invite_message);


        // Выполнение HTTP-запроса для добавления пользователя в группу

        new query_url[256];

        format(query_url, charsmax(query_url), "https://api.steampowered.com/ISteamWebAPIUtil/ResolveVanityURL/v1/?key=%s&vanityurl=%s", STEAM_API_KEY, authid);


        http_get(query_url, "OnHttpRequestComplete");

    }


    // Function to handle HTTP request completion

    public OnHttpRequestComplete(const data[], const response_code, const response_data[]) {

        if (response_code == 200) {

            // Обработка ответа от Steam API (если необходимо)

        } else {

            // Обработка ошибки HTTP-запроса

        }

    }


  4. Step 5: Restarting the server

    After completing all the previous steps, restart the CS 1.6 server so the new plugin can start working. Now every player who joins your server will receive a message with a link to your Steam group.

    Conclusion

    Creating a plugin to automatically invite players to a Steam group is a great way to expand your server community. Using AMX Mod X and the Steam API, you can easily configure such a plugin, which will not only improve interactions with players but also help your group grow.




Comments (0)

Add comment

Leave a comment

New content by email

Subscription with email confirmation. No more than one email per day. Unsubscribe via the link in any email.

Join the community

Register · Reset password