PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
#include <fakemeta>
#define PLUGIN_NAME "Drop or Hide the Bomb"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "K.K.Lv"
new g_droporhide
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
g_droporhide = register_cvar("amx_drop_or_hide_bomb", "1")
register_clcmd("drop", "hookdropbomb")
}
public hookdropbomb(id)
{
if (is_user_alive(id) && get_user_weapon(id) == CSW_C4 && get_pcvar_num(g_droporhide))
{
new menubody = menu_create("\ydrop bomb menu", "call_menu")
menu_additem(menubody, "\wdrop bomb", "1", 0)
menu_additem(menubody, "\whide bomb", "2", 0)
menu_setprop(menubody, MPROP_EXIT, 0)
menu_display(id, menubody, 0)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public call_menu(id, menubody, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menubody)
return PLUGIN_HANDLED
}
new iData[6], iName[32]
new iAccess, iCallback
menu_item_getinfo(menubody, item, iAccess, iData, 5, iName, 31, iCallback)
new key = str_to_num(iData)
switch (key)
{
case 1:
{
engclient_cmd(id, "drop", "weapon_c4")
menu_destroy(menubody)
return PLUGIN_HANDLED
}
case 2:
{
handle_c4_menu(id)
}
}
menu_destroy(menubody)
return PLUGIN_HANDLED
}
handle_c4_menu(id)
{
new menubody = menu_create("\yHow long do you want to hide ?", "display_menu")
menu_additem(menubody, "\w30 seconds", "1", 0)
menu_additem(menubody, "\w60 seconds", "2", 0)
menu_additem(menubody, "\w75 seconds", "3", 0)
menu_additem(menubody, "\w90 seconds", "4", 0)
menu_setprop(menubody, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menubody, 0)
}
public display_menu(id, menubody, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menubody)
return PLUGIN_HANDLED
}
new iData[6], iName[32]
new iAccess, iCallback
menu_item_getinfo(menubody, item, iAccess, iData, 5, iName, 31, iCallback)
new key = str_to_num(iData)
switch (key)
{
case 1:
{
new iEnt = fm_find_ent_by_owner(-1, "weapon_c4", id)
engclient_cmd(id, "drop", "weapon_c4")
new iBox = pev(iEnt, pev_owner)
if (!iBox || iBox == id)
return false
dllfunc(DLLFunc_Think, iBox)
set_task(30.0, "get_c4", id)
menu_destroy(menubody)
return PLUGIN_HANDLED
}
case 2:
{
new iEnt = fm_find_ent_by_owner(-1, "weapon_c4", id)
engclient_cmd(id, "drop", "weapon_c4")
new iBox = pev(iEnt, pev_owner)
if (!iBox || iBox == id)
return false
dllfunc(DLLFunc_Think, iBox)
set_task(60.0, "get_c4", id)
}
case 3:
{
new iEnt = fm_find_ent_by_owner(-1, "weapon_c4", id)
engclient_cmd(id, "drop", "weapon_c4")
new iBox = pev(iEnt, pev_owner)
if (!iBox || iBox == id)
return false
dllfunc(DLLFunc_Think, iBox)
set_task(75.0, "get_c4", id)
}
case 4:
{
new iEnt = fm_find_ent_by_owner(-1, "weapon_c4", id)
engclient_cmd(id, "drop", "weapon_c4")
new iBox = pev(iEnt, pev_owner)
if (!iBox || iBox == id)
return false
dllfunc(DLLFunc_Think, iBox)
set_task(90.0, "get_c4", id)
}
}
menu_destroy(menubody)
return PLUGIN_HANDLED
}
public get_c4(id)
{
if (is_user_alive(id))
{
"how to write here??"
}
}