[Pawn] Tutorial for Counter-Strike 1.6 [Pawn]

Discussion in 'Programming General' started by DarkAngelRng, Dec 30, 2011.

[Pawn] Tutorial for Counter-Strike 1.6 [Pawn]
  1. Unread Dec 30, 2011 at 6:52 PM
  2. DarkAngelRng
    Joined:
    Dec 16, 2011
    Posts:
    110
    Referrals:
    1
    Sythe Gold:
    0

    DarkAngelRng Active Member

    [Pawn] Tutorial for Counter-Strike 1.6 [Pawn]

    Hi everyone, like the title says. This is a tutorial about how to make a nice plugin for counter-strike 1.6!

    All info explained in the code itselves!

    PHP:
    // ###################################################################################
    // **     *     * * *    * * *   * * * *   *          * * * * *  * * * * **     *
    // * *    *   *      *   *    *  *     *   *          *          *     * * *    *
    // *  *   *   *      *   *    *  *     *   *          *          *     * *  *   *
    // *   *  *   *      *   * * *   *     *   *          * * * * *  *     * *   *  *
    // *    * *   ********   *       *     *   *          *          *     * *    * *
    // *     **   *      *   *       *     *   *          *          *     * *     **
    // *      *   *      *   *       * * * *   * * * * *  * * * * *  * * * * *      *
    // ###################################################################################
    #include <amxmodx>

    #define VERSION "1.0"

    new menu

    public plugin_init() {
        
    register_plugin("Simple Menu"VERSION"NapoleoN#"// Only using a define for Version to optimize the code!
        
    register_clcmd("say /menu""Cmd_Menu"// Register our function + command
    }

    public 
    Cmd_Menu(id) { // Make our public function
        
    if(is_user_alive(id)) { // Check if our user is alive
            
    menu menu_create("Menu Title""menu_handler"// Create our menu
            
            
    menu_additem(menu"Hello!""1"// Add an item to our menu
            
    menu_additem(menu"Goodbye!""2"// Add an item to our menu
            
            
    menu_display(idmenu// Display our menu
        
    }
        else { 
    // If the user is not online, then use else. "if(!is_user_alive(id))" would work aswell.
            
    return PLUGIN_HANDLED // Do nothing with our plugin.
        
    }
        return 
    PLUGIN_HANDLED // End our function
    }

    public 
    menu_handler(idmenuitem) { // Make our public function for the menu_handler
        
    if(item == MENU_EXIT) { // If the option the player took is Exit, then
            
    menu_destroy(menu// Destroy our menu
            
    return PLUGIN_HANDLED
        
    }
        
        if(
    is_user_alive(id)) { // Check if our user is still alive, he might die while looking at the menu.
            
    new szName[32]; get_user_name(idszNamesizeof(szName) - 1// Retrieve the name from the user
            
    switch(item) {
                case 
    0client_print(0print_chat"Hello there! my name is %s!"szName// Print our message to everyone!
                
    case 1client_print(0print_chat"Goodbye! Have a nice day further %s!"szName// Print our message to everyone!
            
    }
        }
        else { 
    // If the user is not online, then use else. "if(!is_user_alive(id))" would work aswell.
            
    client_print(idprint_chat"You're not alive!")
        }
        return 
    PLUGIN_HANDLED
    }
    Hope you learned something!
     
  3. Unread Jan 5, 2012 at 3:23 PM
  4. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    6,593
    Referrals:
    15
    Sythe Gold:
    157
    Location:
    Canada
    Gohan has AIDS Extreme Homosex MushyMuncher

    Blupig ~
    Retired Global Moderator Zombie Technical Core

    [Pawn] Tutorial for Counter-Strike 1.6 [Pawn]

    This is more like a source lol, and I'm moving it to C++.
     
  5. Unread Jan 6, 2012 at 10:32 AM
  6. DarkAngelRng
    Joined:
    Dec 16, 2011
    Posts:
    110
    Referrals:
    1
    Sythe Gold:
    0

    DarkAngelRng Active Member

    [Pawn] Tutorial for Counter-Strike 1.6 [Pawn]

    It's a programming language to make plugins for a game called Counter-Strike 1.6.

    This plugin just makes a menu and outputs the choosen number out of the menu.
     
< VB.NET Video Tutorials | Can runescape-like games be written in C++? >

Users viewing this thread
1 guest