| Diegorkable |
05-08-2012 09:04 |
Re: Using code
There is something wrong in your code:
(Its your paste not a new one I've editted)
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike>
#define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author"
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_concmd("amx_giveweapon", "buyhelmet") } new const g_Weapons[33][] = { "", "p228", "shield", "scout", "hegrenade", "xm1014","c4", "mac10", "aug", "smokegrenade", "elite", "fiveseven", "ump45", "sg550", "galil", "famas", "usp", "glock18", "awp", "mp5", "m249", "m3", "m4a1", "tmp", "g3sg1", "flashbang", "deagle", "sg552", "ak47", "knife", "p90", "kevlar", "assault" }
new g_MaxBPAmmo[33] = {0,52,0,90,0,32,0,100,90,0,120,100,100,90,90, 90,100,120,30,120,200,21,90,120,90,0,35,90,90 ,0,100,0,0}
public cmd_giveweapon(id) { if ( ! ( get_user_flags(id) & ADMIN_KICK ) ) return PLUGIN_CONTINUE new arg1[32], arg2[32] read_argv(1, arg1, 31) read_argv(2, arg2, 31) new target = cmd_target(id, arg1, 0) if ( ! target ) return PLUGIN_CONTINUE new weap[40] = "weapon_" for ( new i = 1; i < 33; i++ ) { if( equali(arg2, g_Weapons[i]) ) { copy(weap[7], 32, g_Weapons[i]) give_item(target , weap) if ( i != 2 && i != 4 && i != 6 && i != 9 && i != 25 && i != 29 && i != 31 && i != 32 ) cs_set_user_bpammo(id, i, g_MaxBPAmmo[i]) return PLUGIN_CONTINUE } } client_print(id, print_console, "Weapon ^"%s^" was not found", arg2) return PLUGIN_CONTINUE }
*There is a register_clcmd at plugin_init, which registers a command for a non-existing function: 'buyhelmet:
*The function 'cmd_giveweapon' is not being used.
But if you meant that the register_clcmd would be for the cmd_giveweapon function. Then the code is indeed giving a weapon to whoever you choose to give to, not specifically bots, could be players aswell.
So if you want the register_clcmd to be related to the cmd_giveweapon, then the code should look like this:
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike>
#define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author"
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_concmd("amx_giveweapon", "cmd_giveweapon") } new const g_Weapons[33][] = { "", "p228", "shield", "scout", "hegrenade", "xm1014","c4", "mac10", "aug", "smokegrenade", "elite", "fiveseven", "ump45", "sg550", "galil", "famas", "usp", "glock18", "awp", "mp5", "m249", "m3", "m4a1", "tmp", "g3sg1", "flashbang", "deagle", "sg552", "ak47", "knife", "p90", "kevlar", "assault" }
new g_MaxBPAmmo[33] = {0,52,0,90,0,32,0,100,90,0,120,100,100,90,90, 90,100,120,30,120,200,21,90,120,90,0,35,90,90 ,0,100,0,0}
public cmd_giveweapon(id) { if ( ! ( get_user_flags(id) & ADMIN_KICK ) ) return PLUGIN_CONTINUE new arg1[32], arg2[32] read_argv(1, arg1, 31) read_argv(2, arg2, 31) new target = cmd_target(id, arg1, 0) if ( ! target ) return PLUGIN_CONTINUE new weap[40] = "weapon_" for ( new i = 1; i < 33; i++ ) { if( equali(arg2, g_Weapons[i]) ) { copy(weap[7], 32, g_Weapons[i]) give_item(target , weap) if ( i != 2 && i != 4 && i != 6 && i != 9 && i != 25 && i != 29 && i != 31 && i != 32 ) cs_set_user_bpammo(id, i, g_MaxBPAmmo[i]) return PLUGIN_CONTINUE } } client_print(id, print_console, "Weapon ^"%s^" was not found", arg2) return PLUGIN_CONTINUE }
Try it now.
Usage (in console): amx_giveweapon <Player Name/#UserID/AuthID> <Weapon name from g_Weapons variable>
|