| pingplug |
08-02-2011 05:35 |
Weaponmenu
1 Attachment(s)
weapons
Primary:
"awp"
"mp5navy"
"galil"
"m249"
"famas"
"mac10"
"ump45"
"xm1014"
Secondary:
"usp"
"deagle"
"fiveseven"
"elite"
Quote:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <fakemeta>
#include <cstrike>
#include <fun>
#define PLUGIN "weapon_GIVE"
#define VERSION "1.0"
#define AUTHOR "pingplug"
//Weapon Striper
#define OFFSET_PRIMARYWEAPON 116
#define OFFSET_C4_SLOT 372
new g_WeaponBPAmmo[] =
{
0,
52,
0,
90,
1,
32,
1,
100,
90,
1,
120,
100,
100,
90,
90,
90,
100,
120,
30,
120,
200,
32,
90,
120,
90,
2,
35,
90,
90,
0,
100
}
new const g_PrimaryWeapons[][] =
{
"none",
"awp",
"mp5navy",
"galil",
"m249",
"famas",
"mac10",
"ump45",
"xm1014"
};
new const g_SecondaryWeapons[][] =
{
"none",
"usp",
"deagle",
"fiveseven",
"elite"
};
new g_PrimaryWeaponMenu, g_SecondaryWeaponMenu;
public plugin_init()
{
register_plugin("Weapon Menu", "0.0.1", "pingplug");
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", 1);
g_PrimaryWeaponMenu = menu_create("Choose your primary weapon", "PrimaryWeaponMenuHandler");
//Primary Weapons Menu
new szPrimaryNum[3];
for(new i = 1; i < sizeof(g_PrimaryWeapons); i++)
{
num_to_str(i , szPrimaryNum , charsmax(szPrimaryNum));
menu_additem(g_PrimaryWeaponMenu , g_PrimaryWeapons[ i ] , szPrimaryNum , 0);
}
menu_setprop(g_PrimaryWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
//Secondary Weapons Menu
g_SecondaryWeaponMenu = menu_create("Choose your primary weapon", "SecondaryWeaponMenuHandler");
new szSecondaryNum[3];
for(new i = 1; i < sizeof(g_SecondaryWeapons); i++)
{
num_to_str(i , szSecondaryNum , charsmax(szSecondaryNum));
menu_additem(g_SecondaryWeaponMenu , g_SecondaryWeapons[ i ] , szSecondaryNum , 0);
}
menu_setprop(g_SecondaryWeaponMenu , MPROP_EXIT , MEXIT_NEVER);
}
public fwdPlayerSpawn(id)
{
if(is_user_alive(id))
{
StripUserWeapons(id)
menu_display(id, g_PrimaryWeaponMenu);
}
}
public PrimaryWeaponMenuHandler( id , iMenu , iItem )
{
new szKey[ 3 ] , Dummy;
menu_item_getinfo( iMenu , iItem , Dummy , szKey , 2 , "" , 0 , Dummy );
new iSelectedWeapon = str_to_num( szKey );
if(!iSelectedWeapon)
return PLUGIN_HANDLED;
new weaponName[32];
format(weaponName, charsmax(weaponName), "weapon_%s", g_PrimaryWeapons[iSelectedWeapon]);
Give_Weapon(id, weaponName);
menu_display(id, g_SecondaryWeaponMenu);
return PLUGIN_CONTINUE;
}
public SecondaryWeaponMenuHandler( id , iMenu , iItem )
{
new szKey[ 3 ] , Dummy;
menu_item_getinfo( iMenu , iItem , Dummy , szKey , 2 , "" , 0 , Dummy );
new iSelectedWeapon = str_to_num( szKey );
if(!iSelectedWeapon)
return PLUGIN_HANDLED;
new weaponName[32];
format(weaponName, charsmax(weaponName), "weapon_%s", g_SecondaryWeapons[iSelectedWeapon]);
Give_Weapon(id, weaponName);
return PLUGIN_CONTINUE;
}
stock Give_Weapon(id, const weapon[])
{
give_item(id, weapon);
new iWeaponId = get_weaponid(weapon);
cs_set_user_bpammo(id, iWeaponId, g_WeaponBPAmmo[iWeaponId]);
}
stock StripUserWeapons(id)
{
new iC4Ent = get_pdata_cbase(id, OFFSET_C4_SLOT);
if( iC4Ent > 0 )
{
set_pdata_cbase(id, OFFSET_C4_SLOT, FM_NULLENT);
}
strip_user_weapons(id);
give_item(id, "weapon_knife");
set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0);
if( iC4Ent > 0 )
{
entity_set_int(id, EV_INT_weapons, entity_get_int(id, EV_INT_weapons) | (1<<CSW_C4));
set_pdata_cbase(id, OFFSET_C4_SLOT, iC4Ent);
cs_set_user_bpammo(id, CSW_C4, 1);
cs_set_user_plant(id, 1);
}
return PLUGIN_HANDLED;
}
|
|