Raised This Month: $ Target: $400
 0% 

How to change weapon of a player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 07-26-2010 , 07:58   How to change weapon of a player?
Reply With Quote #1

How to make that the player select the certain weapon from all available arsenal?
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
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
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 07-26-2010 , 08:37   Re: How to change weapon of a player?
Reply With Quote #3

Player has many weapons. I know id of certain weapon (player has this weapon). I need that player select this weapon.
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 10:03   Re: How to change weapon of a player?
Reply With Quote #4

I don't understand what do you mean, dude.
Why do you want give weapon that player already has?
Gadzislaw007 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-26-2010 , 10:47   Re: How to change weapon of a player?
Reply With Quote #5

engclient_cmd(PLAYERID, WEAPONNAME)

Code:
engclient_cmd(id, "weapon_knife")
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
DaxProxy
Senior Member
Join Date: Sep 2007
Old 07-28-2010 , 08:09   Re: How to change weapon of a player?
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________

Want ApolloRP for Counter-Strike? Show your support: http://forums.alliedmods.net/showthr...39#post1264739
DaxProxy is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 11:50   Re: How to change weapon of a player?
Reply With Quote #7

Crap.... I'm so stupid, actually I didn't think about that in this way. Sorry.
Gadzislaw007 is offline
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 07-26-2010 , 23:53   Re: How to change weapon of a player?
Reply With Quote #8

ConnorMcLeod Thank you very much!
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
Reply



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