Raised This Month: $ Target: $400
 0% 

menu item time limit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Juk0
Member
Join Date: Mar 2009
Old 12-21-2011 , 09:49   Re: menu item time limit
Reply With Quote #1

Here is the full code:
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 ( <<= )
{
    
SCOREATTRIB_FLAG_NONE 0,
    
SCOREATTRIB_FLAG_DEAD 1,
    
SCOREATTRIB_FLAG_BOMB,
    
SCOREATTRIB_FLAG_VIP
};

 new 
pCvar_AdminVIP;

 new 
bool:NoclipUsed[33];

 new 
szName[33]
 
 public 
plugin_init()
 {

    
register_clcmd"say /vipmenu","VIPMenu");
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_messageget_user_msgid"ScoreAttrib" ), "MessageScoreAttrib" );
    
pCvar_AdminVIP register_cvar"amx_adminvip""1" );
    
 }
 
public 
MessageScoreAttribiMsgIdiDestiReceiver )
{
    if( 
get_pcvar_numpCvar_AdminVIP ) )
    {
        new 
iPlayer get_msg_arg_intSCOREATTRIB_ARG_PLAYERID );
        
        if( 
accessiPlayerVIP_FLAG ) )
        {
            
set_msg_arg_intSCOREATTRIB_ARG_FLAGSARG_BYTESCOREATTRIB_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(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

 }

 public 
menu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1Givesniper(id)

        case 
2Noclip(id)
       
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
    
 }
 public 
Noclip(id) {
    
    if(!
is_user_alive(id))
    {
        
ColorChat(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}
    
    if(
NoclipUsed[id] == true)
    {
        
ColorChat(idGREY"You have allready used your Noclip!")
        return 
PLUGIN_HANDLED
    
}
    
    
get_user_name(idszName32)

    
set_task(10.0"RemoveNoclip"id)
    
ColorChat(0GREY"^4%s^3 now has noclip for 10 seconds!"szName)
    
set_user_noclip(id1)
    
NoclipUsed[id] = true
    
return PLUGIN_CONTINUE
    
}

public 
RemoveNoclip(id)
{
    
set_user_noclip(id0)
    
ColorChat(0GREY"^4%s ^3returned to normal clipping"szName)
    
NoclipUsed[id] = false
    
return PLUGIN_HANDLED
    
}

public 
Givesniper(id)
{
    
    if(!
is_user_alive(id))
    {
        
ColorChat(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}
    
StripWeapons(idPrimary);
    
give_item(id,"weapon_awp")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
get_user_name(idszName32)
    
ColorChat(idGREY"^4%s ^3gave himself AWP"szName)
    return 
PLUGIN_HANDLED

Juk0 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-21-2011 , 16:10   Re: menu item time limit
Reply With Quote #2

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 ( <<= )
{
    
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(PLUGINVERSIONAUTHOR);

    
register_messageget_user_msgid"ScoreAttrib" ), "MessageScoreAttrib" );
    
pCvar_AdminVIP register_cvar"amx_adminvip""1" );

}

public 
MessageScoreAttribiMsgIdiDestiReceiver )
{
    if( 
get_pcvar_numpCvar_AdminVIP ) )
    {
        new 
iPlayer get_msg_arg_intSCOREATTRIB_ARG_PLAYERID );

        if( 
accessiPlayerVIP_FLAG ) )
        {
            
set_msg_arg_intSCOREATTRIB_ARG_FLAGSARG_BYTESCOREATTRIB_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(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1Givesniper(id)
        case 
2:
        {
            new 
iTimestamp get_systime()
            if( 
g_iNoClipNextUse[id] < iTimestamp )
            {
                
Noclip(id)
                
g_iNoClipNextUse[id] = iTimestamp 90
            
}
            else
            {
                
client_print(idprint_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(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}

    if(
NoclipUsed[id] == true)
    {
        
ColorChat(idGREY"You have allready used your Noclip!")
        return 
PLUGIN_HANDLED
    
}

    
get_user_name(idszName32)

    
set_task(10.0"RemoveNoclip"id)
    
ColorChat(0GREY"^4%s^3 now has noclip for 10 seconds!"szName)
    
set_user_noclip(id1)
    
NoclipUsed[id] = true
    
return PLUGIN_CONTINUE

}

public 
RemoveNoclip(id)
{
    
set_user_noclip(id0)
    
ColorChat(0GREY"^4%s ^3returned to normal clipping"szName)
    
NoclipUsed[id] = false
    
return PLUGIN_HANDLED

}

public 
Givesniper(id)
{
    if(!
is_user_alive(id))
    {
        
ColorChat(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}
    
StripWeapons(idPrimary);
    
give_item(id,"weapon_awp")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
get_user_name(idszName32)
    
ColorChat(idGREY"^4%s ^3gave himself AWP"szName)
    return 
PLUGIN_HANDLED

__________________

Last edited by fysiks; 12-22-2011 at 03:02. Reason: fixed
fysiks is offline
Juk0
Member
Join Date: Mar 2009
Old 12-22-2011 , 01:25   Re: menu item time limit
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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 ( <<= )
{
    
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(PLUGINVERSIONAUTHOR);

    
register_messageget_user_msgid"ScoreAttrib" ), "MessageScoreAttrib" );
    
pCvar_AdminVIP register_cvar"amx_adminvip""1" );

}

public 
MessageScoreAttribiMsgIdiDestiReceiver )
{
    if( 
get_pcvar_numpCvar_AdminVIP ) )
    {
        new 
iPlayer get_msg_arg_intSCOREATTRIB_ARG_PLAYERID );

        if( 
accessiPlayerVIP_FLAG ) )
        {
            
set_msg_arg_intSCOREATTRIB_ARG_FLAGSARG_BYTESCOREATTRIB_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(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1Givesniper(id)
        case 
2:
        {
            new 
iTimestamp get_systime()
            if( 
g_iNoClipNextUse[id] < iTimestamp )
            {
                
Noclip(id)
                
g_iNoClipNextUse[id] = iTimestamp
            
}
            else
            {
                
client_print(idprint_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(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}

    if(
NoclipUsed[id] == true)
    {
        
ColorChat(idGREY"You have allready used your Noclip!")
        return 
PLUGIN_HANDLED
    
}

    
get_user_name(idszName32)

    
set_task(10.0"RemoveNoclip"id)
    
ColorChat(0GREY"^4%s^3 now has noclip for 10 seconds!"szName)
    
set_user_noclip(id1)
    
NoclipUsed[id] = true
    
return PLUGIN_CONTINUE

}

public 
RemoveNoclip(id)
{
    
set_user_noclip(id0)
    
ColorChat(0GREY"^4%s ^3returned to normal clipping"szName)
    
NoclipUsed[id] = false
    
return PLUGIN_HANDLED

}

public 
Givesniper(id)
{
    if(!
is_user_alive(id))
    {
        
ColorChat(idGREY"You need to be alive to use this!")
        return 
PLUGIN_HANDLED
    
}
    
StripWeapons(idPrimary);
    
give_item(id,"weapon_awp")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
get_user_name(idszName32)
    
ColorChat(idGREY"^4%s ^3gave himself AWP"szName)
    return 
PLUGIN_HANDLED

That isnt working. You can use noclip again every time it returns back to normal clipping as before. You didnt set the 90s time in the script?

Last edited by Juk0; 12-22-2011 at 01:26.
Juk0 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-22-2011 , 03:01   Re: menu item time limit
Reply With Quote #4

Quote:
Originally Posted by Juk0 View Post
That isnt working. You can use noclip again every time it returns back to normal clipping as before. You didnt set the 90s time in the script?
Oops, looks like I forgot to add 90 to the timestamp.

PHP Code:
g_iNoClipNextUse[id] = iTimestamp 90 
__________________
fysiks is offline
Juk0
Member
Join Date: Mar 2009
Old 12-22-2011 , 04:04   Re: menu item time limit
Reply With Quote #5

Thanks alot man, i knew you guys are friendly on these forums
Juk0 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-22-2011 , 13:36   Re: menu item time limit
Reply With Quote #6

Quote:
Originally Posted by Juk0 View Post
Thanks alot man, i knew you guys are friendly on these forums
As long as people follow the rules (like you did) we are nice .
__________________
fysiks is offline
Reply



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 12:02.


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