AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to change weapon of a player? (https://forums.alliedmods.net/showthread.php?t=133510)

-=hunter=- 07-26-2010 07:58

How to change weapon of a player?
 
How to make that the player select the certain weapon from all available arsenal?

Gadzislaw007 07-26-2010 08:31

Re: How to change weapon of a player?
 
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.

-=hunter=- 07-26-2010 08:37

Re: How to change weapon of a player?
 
Player has many weapons. I know id of certain weapon (player has this weapon). I need that player select this weapon.

Gadzislaw007 07-26-2010 10:03

Re: How to change weapon of a player?
 
I don't understand what do you mean, dude.
Why do you want give weapon that player already has?

ConnorMcLeod 07-26-2010 10:47

Re: How to change weapon of a player?
 
engclient_cmd(PLAYERID, WEAPONNAME)

Code:
engclient_cmd(id, "weapon_knife")

Gadzislaw007 07-26-2010 11:50

Re: How to change weapon of a player?
 
Crap.... I'm so stupid, actually I didn't think about that in this way. Sorry.

-=hunter=- 07-26-2010 23:53

Re: How to change weapon of a player?
 
ConnorMcLeod Thank you very much! :)

DaxProxy 07-28-2010 08:09

Re: How to change weapon of a player?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1252028)
engclient_cmd(PLAYERID, WEAPONNAME)

Code:
engclient_cmd(id, "weapon_knife")

I had no idea there is such command, this is going to solve quite a few problems for me, thankyou.


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

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