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-20-2011 , 08:51   menu item time limit
Reply With Quote #1

Hey!

Im not good at scripting yet so i need help with menu item time limit code, so if someone picks like "noclip" from menu once, and tries to do it again in 90 seconds, menu says "You can pick noclip after 90 seconds".

Thanks already
Juk0 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-20-2011 , 15:47   Re: menu item time limit
Reply With Quote #2

Have a variable that contains the timestamp at which they can use it again. Then, everytime they call the menu (or whatever) you check to see if their stored time is less than get_systime(). If yes, then let them choose, if no, show your message. Each time they choose, add the 90 to get_systime() and store that as the new timestamp.
__________________
fysiks is offline
Juk0
Member
Join Date: Mar 2009
Old 12-20-2011 , 17:02   Re: menu item time limit
Reply With Quote #3

Thanks for reply fysik, but could you post me the full code? Im not enought good at scripting yet, im doing my first plugin at this moment. Sorry aboat my poor english.
Juk0 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-20-2011 , 17:24   Re: menu item time limit
Reply With Quote #4

Quote:
Originally Posted by Juk0 View Post
Thanks for reply fysik, but could you post me the full code? Im not enought good at scripting yet, im doing my first plugin at this moment. Sorry aboat my poor english.
If I post code it will be exactly what I said in words. If you want me to add it in for you then you need to post your full code.
__________________
fysiks is offline
Juk0
Member
Join Date: Mar 2009
Old 12-21-2011 , 09:49   Re: menu item time limit
Reply With Quote #5

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 #6

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
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