Raised This Month: $ Target: $400
 0% 

How to change weapon of a player?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 08:31   Re: How to change weapon of a player?
Reply With Quote #2

You mean that there is menu which shows what user can equip?

Code:
 
 #include <amxmodx>
#include <cstrike>
public plugin_init()
{
    register_plugin("Choose your weapon", "1.0", "Gadzik :*")
    register_clcmd( "say /menu", "cmdMenu" )
}

public cmdMenu( id )
{
    new menu = menu_create( "Choose Weapon", "Menu_Weapon" )
    menu_additem( menu, "Deagle", "0", 0 )
    menu_additem( menu, "USP", "1", 0 )
    menu_additem( menu, "Glock", "2", 0 )
    
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
}

public Menu_Weapon( id, menu, item )
{
    if( item == MENU_EXIT )
    {
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }
    
    new data[6], iName[64];
    new access, callback;
    menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback );
    
    new wep = str_to_num( data );
    
    switch( wep )
    {
        case 0:
        {
            give_item(id, CSW_DEAGLE);
    cs_set_user_bpammo(id, CSW_DEAGLE, 35) 
        }
        case 1:
        {
            give_item(id, CSW_USP);
    cs_set_user_bpammo(id, CSW_USP, 90) 
        }
        case 2:
        {
    give_item(id, CSW_GLOCK18);
    cs_set_user_bpammo(id, CSW_GLOCK18, 120) 
        }
    }
    
    menu_destroy( menu );
    return PLUGIN_HANDLED;
}


This is the simplest way to do this.
Gadzislaw007 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode