Raised This Month: $32 Target: $400
 8% 

Gun Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lo6idZe
Member
Join Date: May 2008
Old 10-09-2008 , 12:30   Gun Menu
Reply With Quote #1

Why does this menu not working ?


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#tryinclude "menu.cfg"
#if !defined _menucfg_included
#assert Menu configuration file required!
#elseif AMXX_VERSION_NUM < 180
#assert AMX Mod X v1.8.0 or greater required!
#endif
 
#define OFFSET_TEAM 114
#define OFFSET_ARMOR 112
#define OFFSET_CSMONEY 115
#define OFFSET_PRIMARYWEAPON 116
#define OFFSET_WEAPONTYPE 43
#define OFFSET_CLIPAMMO 51
#define EXTRAOFFSET_WEAPONS 4
#define OFFSET_LASTPRIM 368
#define OFFSET_AMMO_338MAGNUM 377
#define OFFSET_AMMO_762NATO 378
#define OFFSET_AMMO_556NATOBOX 379
#define OFFSET_AMMO_556NATO 380
#define OFFSET_AMMO_BUCKSHOT 381
#define OFFSET_AMMO_45ACP 382
#define OFFSET_AMMO_57MM 383
#define OFFSET_AMMO_50AE 384
#define OFFSET_AMMO_357SIG 385
#define OFFSET_AMMO_9MM 386
#define OFFSET_LASTSEC 369
#define TASKID_INITROUND 222
#define TASKID_STARTROUND 153
#define TASKID_BALANCETEAM 375
#define TASKID_WEAPONSMENU 564
#define TASKID_SPAWNDELAY 786
#define EQUIP_PRI (1<<0)
#define EQUIP_SEC (1<<1)
#define EQUIP_GREN (1<<2)
#define EQUIP_ALL (1<<0 | 1<<1 | 1<<2)
#define _random(%1) random_num(0, %1 - 1)
#define fm_get_user_team(%1) get_pdata_int(%1, OFFSET_TEAM)
#define fm_get_user_money(%1) get_pdata_int(%1, OFFSET_CSMONEY)
#define fm_get_weapon_id(%1) get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
#define fm_get_weapon_ammo(%1) get_pdata_int(%1, OFFSET_CLIPAMMO, EXTRAOFFSET_WEAPONS)
#define fm_set_weapon_ammo(%1,%2) set_pdata_int(%1, OFFSET_CLIPAMMO, %2, EXTRAOFFSET_WEAPONS)
#define fm_lastprimary(%1) get_pdata_cbase(id, OFFSET_LASTPRIM)
#define fm_lastsecondry(%1) get_pdata_cbase(id, OFFSET_LASTSEC)
new const g_weapon_ammo[][] =
{
{ -
1, -},
1352 },
{ -
1, -},
1090 },
{ -
1, -},
732 },
{ -
1, -},
30100 },
3090 },
{ -
1, -},
30120 },
20100 },
25100 },
3090 },
3590 },
2590 },
12100 },
20120 },
1030 },
30120 },
100200 },
832 },
3090 },
30120 },
2090 },
{ -
1, -},
735 },
3090 },
3090 },
{ -
1, -},
50100 }
}
enum
{
MAX_CLIP 0,
MAX_AMMO
}
enum
{
MENU_PRIMARY 1,
MENU_SECONDARY
}
enum
{
CS_TEAM_UNASSIGNED 0,
CS_TEAM_T,
CS_TEAM_CT,
CS_TEAM_SPECTATOR
}
new 
cvar_weaponsmenucvar_enabled 
new bool:g_showmenu[33], bool:g_menufailsafe[33], g_player_weapons[33][2], g_menuposition[33], g_maxplayers
new bool:g_roundstarted
public plugin_init()
{
register_plugin("Menu""0""KIL & kam1kadze")

register_dictionary("menu.txt")

cvar_enabled register_cvar("bh_enabled""1")
cvar_weaponsmenu register_cvar("bh_weaponsmenu""1")

if(!
get_pcvar_num(cvar_enabled)) 
return

register_clcmd("say /guns""cmd_enablemenu")
register_menu("Equipment"1023"action_equip")
register_menu("Primary"1023"action_prim")
register_menu("Secondary"1023"action_sec")
g_maxplayers get_maxplayers()
}
public 
client_connect(id)
{
g_showmenu[id] = true
g_player_weapons
[id][0] = -1
g_player_weapons
[id][1] = -1
g_menufailsafe
[id] = false
}
 
public 
client_disconnect(id)
{
remove_task(TASKID_WEAPONSMENU id)
}
 
public 
logevent_round_start()
{
g_roundstarted true
if(get_pcvar_num(cvar_weaponsmenu))
{
static 
idteam
for(id 1id <= g_maxplayersid++) if(is_user_alive(id))
{
team fm_get_user_team(id)
if(
team == CS_TEAM_T || team == CS_TEAM_CT)
{
if(
g_showmenu[id])
{
add_delay(id"display_equipmenu")

g_menufailsafe[id] = true
set_task
(10.0"task_weaponsmenu"TASKID_WEAPONSMENU id)
}
else 
equipweapon(idEQUIP_ALL)
}
}
}
}
public 
task_spawned(taskid)
{
static 
id
id 
taskid TASKID_SPAWNDELAY
if(is_user_alive(id))
{
if(
get_pcvar_num(cvar_weaponsmenu) && g_roundstarted && g_showmenu[id])
display_equipmenu(id)
}
}
public 
task_weaponsmenu(taskid)
{
static 
id
id 
taskid TASKID_WEAPONSMENU

if(is_user_alive(id) && g_menufailsafe[id])
display_equipmenu(id)
}
public 
display_equipmenu(id)
{
static 
menubody[512], len
len 
formatex(menubody511"\y%L^n^n"id"MENU_TITLE1")

static 
bool:hasweap
hasweap 
= ((g_player_weapons[id][0]) != -&& (g_player_weapons[id][1] != -1)) ? true false

len 
+= formatex(menubody[len], 511 len,"\w1. %L^n"id"MENU_NEWWEAPONS")
len += formatex(menubody[len], 511 len,"%s2. %L^n"hasweap "\w" "\d"id"MENU_PREVSETUP")
len += formatex(menubody[len], 511 len,"%s3. %L^n^n"hasweap "\w" "\d"id"MENU_DONTSHOW")
len += formatex(menubody[len], 511 len,"\w5. %L^n"id"MENU_EXIT")

static 
keys
keys 
= (MENU_KEY_1|MENU_KEY_5)

if(
hasweap
keys |= (MENU_KEY_2|MENU_KEY_3)

show_menu(idkeysmenubody, -1"Equipment")
}
public 
action_equip(idkey)
{
if(!
is_user_alive(id))
return 
PLUGIN_HANDLED

switch(key)
{
case 
0display_weaponmenu(idMENU_PRIMARYg_menuposition[id] = 0)
case 
1equipweapon(idEQUIP_ALL)
case 
2:
{
g_showmenu[id] = false
equipweapon
(idEQUIP_ALL)
client_print(idprint_chat"%L"id"MENU_CMDENABLE")
}
}

if(
key 0)
{
g_menufailsafe[id] = false
remove_task
(TASKID_WEAPONSMENU id)
}
return 
PLUGIN_HANDLED
}
public 
display_weaponmenu(idmenuidpos)
{
if(
pos || menuid 0)
return

static 
start
start 
pos 8

static maxitem
maxitem 
menuid == MENU_PRIMARY sizeof g_primaryweapons sizeof g_secondaryweapons
if(start >= maxitem)
start pos g_menuposition[id]

static 
menubody[512], len
len 
formatex(menubody511"\y%L\w^n^n"idmenuid == MENU_PRIMARY "MENU_TITLE2" "MENU_TITLE3")
static 
end
end 
start 8
if(end maxitem)
end maxitem

static keys
keys 
MENU_KEY_0

static ab
0

for(startend; ++a
{
keys |= (1<<b)
len += formatex(menubody[len], 511 len,"%d. %s^n", ++bmenuid == MENU_PRIMARY g_primaryweapons[a][0]: g_secondaryweapons[a][0])
}
if(
end != maxitem)
{
formatex(menubody[len], 511 len"^n9. %L^n0. %L"id"MENU_MORE"idpos "MENU_BACK" "MENU_EXIT")
keys |= MENU_KEY_9
}
else 
formatex(menubody[len], 511 len"^n0. %L"idpos "MENU_BACK" "MENU_EXIT")

show_menu(idkeysmenubody, -1menuid == MENU_PRIMARY "Primary" "Secondary")
}
public 
action_prim(idkey)
{
if(!
is_user_alive(id))
return 
PLUGIN_HANDLED
switch(key)
{
case 
8display_weaponmenu(idMENU_PRIMARY, ++g_menuposition[id])
case 
9display_weaponmenu(idMENU_PRIMARY, --g_menuposition[id])
default:
{
g_player_weapons[id][0] = g_menuposition[id] * key
equipweapon
(idEQUIP_PRI)

display_weaponmenu(idMENU_SECONDARYg_menuposition[id] = 0)
}
}
return 
PLUGIN_HANDLED
}
public 
action_sec(idkey)
{
if(!
is_user_alive(id))
return 
PLUGIN_HANDLED

switch(key
{
case 
8display_weaponmenu(idMENU_SECONDARY, ++g_menuposition[id])
case 
9display_weaponmenu(idMENU_SECONDARY, --g_menuposition[id])
default:
{
g_menufailsafe[id] = false
remove_task
(TASKID_WEAPONSMENU id)

g_player_weapons[id][1] = g_menuposition[id] * key
equipweapon
(idEQUIP_SEC)
equipweapon(idEQUIP_GREN)
}
}
return 
PLUGIN_HANDLED
}
stock fm_strip_user_weapons(index
{
static 
stripent
if(!pev_valid(stripent))
{
stripent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
dllfunc(DLLFunc_Spawnstripent), set_pev(stripentpev_solidSOLID_NOT)
}
dllfunc(DLLFunc_Usestripentindex)

return 
1
}
stock bacon_give_weapon(indexweapon[])
{
if(!
equal(weapon,"weapon_"7))
return 
0
static ent
ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringweapon))

if(!
pev_valid(ent)) 
return 
0

set_pev
(entpev_spawnflagsSF_NORESPAWN)
dllfunc(DLLFunc_Spawnent)

if(!
ExecuteHamB(Ham_AddPlayerItemindexent))
{
if(
pev_valid(ent)) set_pev(entpev_flagspev(entpev_flags) | FL_KILLME)
return 
0
}
ExecuteHamB(Ham_Item_AttachToPlayerentindex)
return 
1
}
stock bacon_strip_weapon(indexweapon[])
{
if(!
equal(weapon"weapon_"7)) 
return 
0
static weaponid 
weaponid 
get_weaponid(weapon)

if(!
weaponid
return 
0
static weaponent
weaponent 
fm_find_ent_by_owner(-1weaponindex)

if(!
weaponent
return 
0
if(get_user_weapon(index) == weaponid
ExecuteHamB(Ham_Weapon_RetireWeaponweaponent)
if(!
ExecuteHamB(Ham_RemovePlayerItemindexweaponent)) 
return 
0

ExecuteHamB
(Ham_Item_Killweaponent)
set_pev(indexpev_weaponspev(indexpev_weapons) & ~(1<<weaponid))
return 
1
}
stock fm_get_user_bpammo(indexweapon)
{
static 
offset
switch(weapon)
{
case 
CSW_AWPoffset OFFSET_AMMO_338MAGNUM
case CSW_SCOUTCSW_AK47CSW_G3SG1offset OFFSET_AMMO_762NATO
case CSW_M249offset OFFSET_AMMO_556NATOBOX
case CSW_FAMASCSW_M4A1CSW_AUG
CSW_SG550CSW_GALICSW_SG552offset OFFSET_AMMO_556NATO
case CSW_M3CSW_XM1014offset OFFSET_AMMO_BUCKSHOT
case CSW_USPCSW_UMP45CSW_MAC10offset OFFSET_AMMO_45ACP
case CSW_FIVESEVENCSW_P90offset OFFSET_AMMO_57MM
case CSW_DEAGLEoffset OFFSET_AMMO_50AE
case CSW_P228offset OFFSET_AMMO_357SIG
case CSW_GLOCK18CSW_TMPCSW_ELITE
CSW_MP5NAVYoffset OFFSET_AMMO_9MM
default: offset 0
}
return 
offset get_pdata_int(indexoffset) : 0
}
stock fm_set_user_bpammo(indexweaponamount)
{
static 
offset
switch(weapon)
{
case 
CSW_AWPoffset OFFSET_AMMO_338MAGNUM
case CSW_SCOUTCSW_AK47CSW_G3SG1offset OFFSET_AMMO_762NATO
case CSW_M249offset OFFSET_AMMO_556NATOBOX
case CSW_FAMASCSW_M4A1CSW_AUG
CSW_SG550CSW_GALICSW_SG552offset OFFSET_AMMO_556NATO
case CSW_M3CSW_XM1014offset OFFSET_AMMO_BUCKSHOT
case CSW_USPCSW_UMP45CSW_MAC10offset OFFSET_AMMO_45ACP
case CSW_FIVESEVENCSW_P90offset OFFSET_AMMO_57MM
case CSW_DEAGLEoffset OFFSET_AMMO_50AE
case CSW_P228offset OFFSET_AMMO_357SIG
case CSW_GLOCK18CSW_TMPCSW_ELITE
CSW_MP5NAVYoffset OFFSET_AMMO_9MM
default: offset 0
}

if(
offset
set_pdata_int(indexoffsetamount)

return 
1
}
stock fm_find_ent_by_owner(index, const classname[], owner
{
static 
ent
ent 
index

while((ent engfunc(EngFunc_FindEntityByStringent"classname"classname)) && pev(entpev_owner) != owner) {}

return 
ent
}
stock equipweapon(idweapon)
{
if(!
is_user_alive(id)) 
return
static 
weaponid[2], weaponentweapname[32]

if(
weapon EQUIP_PRI)
{
weaponent fm_lastprimary(id)
weaponid[1] = get_weaponid(g_primaryweapons[g_player_weapons[id][0]][1])

if(
pev_valid(weaponent))
{
weaponid[0] = fm_get_weapon_id(weaponent)
if(
weaponid[0] != weaponid[1])
{
get_weaponname(weaponid[0], weapname31)
bacon_strip_weapon(idweapname)
}
}
else
weaponid[0] = -1

if(weaponid[0] != weaponid[1])
bacon_give_weapon(idg_primaryweapons[g_player_weapons[id][0]][1])

fm_set_user_bpammo(idweaponid[1], g_weapon_ammo[weaponid[1]][MAX_AMMO])
}
if(
weapon EQUIP_SEC)
{
weaponent fm_lastsecondry(id)
weaponid[1] = get_weaponid(g_secondaryweapons[g_player_weapons[id][1]][1])

if(
pev_valid(weaponent))
{
weaponid[0] = fm_get_weapon_id(weaponent)
if(
weaponid[0] != weaponid[1])
{
get_weaponname(weaponid[0], weapname31)
bacon_strip_weapon(idweapname)
}
}
else
weaponid[0] = -1

if(weaponid[0] != weaponid[1])
bacon_give_weapon(idg_secondaryweapons[g_player_weapons[id][1]][1])

fm_set_user_bpammo(idweaponid[1], g_weapon_ammo[weaponid[1]][MAX_AMMO])
}

if(
weapon EQUIP_GREN)
{
static 
i
for(0sizeof g_grenadesi++) if(!user_has_weapon(idget_weaponid(g_grenades[i])))
bacon_give_weapon(idg_grenades[i])
}

stock add_delay(index, const task[])
{
switch(
index)
{
case 
1..8set_task(0.1taskindex)
case 
9..16set_task(0.2taskindex)
case 
17..24set_task(0.3taskindex)
case 
25..32set_task(0.4taskindex)
}
}
public 
cmd_enablemenu(id)

if(
get_pcvar_num(cvar_weaponsmenu))
{
client_print(idprint_chat"%L"idg_showmenu[id] == false "MENU_REENABLED" "MENU_ALENABLED")
g_showmenu[id] = true
}
}
public 
bot_weapons(id)
{
g_player_weapons[id][0] = _random(sizeof g_primaryweapons)
g_player_weapons[id][1] = _random(sizeof g_secondaryweapons)

equipweapon(idEQUIP_ALL)


Last edited by Lo6idZe; 10-09-2008 at 12:40.
Lo6idZe is offline
Lo6idZe
Member
Join Date: May 2008
Old 10-09-2008 , 12:36   Re: Gun Menu
Reply With Quote #2

menu.cfg file

PHP Code:
#if defined _menucfg_included
#endinput
#endif
#define _menucfg_included
// primary weapons (menu|game)
new g_primaryweapons[][][] = 

"M4A1""weapon_m4a1" },
"AK47""weapon_ak47" },
"AUG""weapon_aug" },
"SG552""weapon_sg552" },
"Galil""weapon_galil" },
"Famas""weapon_famas" },
"MP5 Navy""weapon_mp5navy" },
"XM1014""weapon_xm1014" },
"M3""weapon_m3" },
"P90""weapon_p90" },
"M249""weapon_m249" },
"SG550""weapon_sg550" },
"G3SG1""weapon_g3sg1" 
}
// secondary weapons (menu|game)
new g_secondaryweapons[][][] = 

"Deagle""weapon_deagle" },
"USP""weapon_usp" },
"Elite""weapon_elite" 
}
// grenade loadout (game)
new g_grenades[][] = 

"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"

Lo6idZe is offline
Reply


Thread Tools
Display Modes

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:47.


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