|
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
|

12-21-2011
, 16:10
Re: menu item time limit
|
#4
|
Ok, here ya go. You can study the code that I added and change if needed. But, if you want to add it to other options or change what options it handled then you should do it on your own since you have all you need now.
PHP Code:
#include <amxmodx>
#include <fun>
#include <colorchat>
#include <stripweapons>
#include <amxmisc>
#define PLUGIN "VIP Menu"
#define VERSION "1.0"
#define AUTHOR "Extract"
#define VIP_FLAG ADMIN_LEVEL_E
enum
{
SCOREATTRIB_ARG_PLAYERID = 1,
SCOREATTRIB_ARG_FLAGS
};
enum ( <<= 1 )
{
SCOREATTRIB_FLAG_NONE = 0,
SCOREATTRIB_FLAG_DEAD = 1,
SCOREATTRIB_FLAG_BOMB,
SCOREATTRIB_FLAG_VIP
};
new pCvar_AdminVIP;
new bool:NoclipUsed[33];
new g_iNoClipNextUse[33];
new szName[33]
public plugin_init()
{
register_clcmd( "say /vipmenu","VIPMenu");
register_plugin(PLUGIN, VERSION, AUTHOR);
register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" );
pCvar_AdminVIP = register_cvar( "amx_adminvip", "1" );
}
public MessageScoreAttrib( iMsgId, iDest, iReceiver )
{
if( get_pcvar_num( pCvar_AdminVIP ) )
{
new iPlayer = get_msg_arg_int( SCOREATTRIB_ARG_PLAYERID );
if( access( iPlayer, VIP_FLAG ) )
{
set_msg_arg_int( SCOREATTRIB_ARG_FLAGS, ARG_BYTE, SCOREATTRIB_FLAG_VIP );
}
}
}
public VIPMenu(id)
{
new menu = menu_create("\rJailBreak VIP menu", "menu_handler");
menu_additem(menu, "\yGive \wAWP", "1", ADMIN_LEVEL_E);
menu_additem(menu, "\wNoclip (10s)", "2", ADMIN_LEVEL_E);
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}
public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1: Givesniper(id)
case 2:
{
new iTimestamp = get_systime()
if( g_iNoClipNextUse[id] < iTimestamp )
{
Noclip(id)
g_iNoClipNextUse[id] = iTimestamp + 90
}
else
{
client_print(id, print_chat, "You must wait %d seconds to use NoClip again", g_iNoClipNextUse[id] - iTimestamp);
}
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public Noclip(id)
{
if(!is_user_alive(id))
{
ColorChat(id, GREY, "You need to be alive to use this!")
return PLUGIN_HANDLED
}
if(NoclipUsed[id] == true)
{
ColorChat(id, GREY, "You have allready used your Noclip!")
return PLUGIN_HANDLED
}
get_user_name(id, szName, 32)
set_task(10.0, "RemoveNoclip", id)
ColorChat(0, GREY, "^4%s^3 now has noclip for 10 seconds!", szName)
set_user_noclip(id, 1)
NoclipUsed[id] = true
return PLUGIN_CONTINUE
}
public RemoveNoclip(id)
{
set_user_noclip(id, 0)
ColorChat(0, GREY, "^4%s ^3returned to normal clipping", szName)
NoclipUsed[id] = false
return PLUGIN_HANDLED
}
public Givesniper(id)
{
if(!is_user_alive(id))
{
ColorChat(id, GREY, "You need to be alive to use this!")
return PLUGIN_HANDLED
}
StripWeapons(id, Primary);
give_item(id,"weapon_awp")
give_item(id,"ammo_338magnum")
give_item(id,"ammo_338magnum")
give_item(id,"ammo_338magnum")
get_user_name(id, szName, 32)
ColorChat(id, GREY, "^4%s ^3gave himself AWP", szName)
return PLUGIN_HANDLED
}
__________________
Last edited by fysiks; 12-22-2011 at 03:02.
Reason: fixed
|
|