Jump to content
WWW.CSELITES.COM
CSElites known as [www.cselites.com], a virtual world from May 1, 2012, which continues to grow in the gaming world. CSELITES.COM has over 65k members in continuous expansion, coming from different parts of the world.
More
TZM.CSELITES.COM 178.33.179.182:27015 connect
GOLD.CSELITES.COM 51.75.87.10:27015 connect
MIX.CSELITES.COM 45.13.151.118:27015 connect

[Tutorial] Creating a Simple Command in AMXX Pawn Scripting


DadoDz

Recommended Posts

  • Community Administrators

[STEP - 1] Setting up Your AMXX Plugin

 

  • On your server, find the scripting folder inside the AMX Mod X directory.

Example: 

cstrike/addons/amxmodx/scripting

 

  • Inside the scripting folder, create a new .sma file.

Example: 

hello_command.sma

 

 

[STEP - 2] Write the Pawn Script

 

#include <amxmodx>  // Include AMX Mod X include file for functions

#define PLUGIN "Simple Command" 	// Plugin Name
#define VERSION "1.0"           	// Plugin Version
#define AUTHOR "Your Name"      	// Plugin Author

// This will execute when the plugin is loaded
public plugin_init()
{
    // Register the plugin
    register_plugin(PLUGIN, VERSION, AUTHOR);

    // Register the command
    register_clcmd("say /hello", "cmd_hello");
}

// This function is called when a player types /hello in chat
public cmd_hello(id) 
{
    // Make sure the player is valid and connected
    if (!is_user_connected(id)
        return PLUGIN_HANDLED;
        
    // Get the player's name
    static name[64];
    get_user_name(id, name, charsmax(name));

    // Send a message to the player
    client_print(id, print_chat, "Hello, %s! Welcome to the server.", name);
        
    return PLUGIN_HANDLED;
}

 

Explanation:

  • #include <amxmodx>
  • This is an essential include file that provides access to AMX Mod X functions.

 

  • public plugin_init()
  • This function is automatically called when the plugin is loaded.
  • Here, we register a new command /hello using register_clcmd.

 

  • register_plugin(PLUGIN, VERSION, AUTHOR);
  • This is necessary for the plugin to be recognized by the server and for information to be shown in the plugin list.

 

  • is_user_connected(id)
  • Checks if the player is connected to the server.

 

  • get_user_name(id, name, charsmax(name))
  • This function retrieves the player's name and stores it in the name array

 

  • client_print(id, print_chat, "message")
  • Sends a message to the player's chat.

 

[STEP - 3] Compile the Plugin

 

 

  • Upload your .sma file or use the compile button to generate .amxx file (the compiled plugin).

 

  • Upload the compiled .amxx file to the plugins folder of your AMX Mod X server.

Example:

cstrike/addons/amxmodx/plugins
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

  • Open the plugins.ini file located in addons/amxmodx/configs, add the name of your compiled plugin at the end of the file.

Example:

hello_command.amxx
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

[STEP - 4] Testing the Plugin

 

  • Restart Your Server, then connect to the server in the game,  and in the chat box type /hello.

 

  • The server will respond with a message like: "Hello, [your player name]! Welcome to the server.".

 

 

That's it! You’ve created a simple command plugin in AMXX Pawn Scripting.

This tutorial covers the basics, but you can expand it by adding more features.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.