Raised This Month: $ Target: $400
 0% 

HNS Vipmenu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
midahekki
Junior Member
Join Date: Mar 2013
Old 03-01-2013 , 05:53   HNS Vipmenu
Reply With Quote #1

Hey, could someone please make this plugin so that i can only use the command once per round.
i think its something to do with bool:AlreadyUsed[33] but i dont know how to make it work. if someone could help me i would be happy

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <colorchat>

#define ADMIN_VIP    ADMIN_LEVEL_H

new g_iMenuId;

public 
plugin_init()
{
    
register_plugin("Vipmenu""1.0""Ranel");
    
register_clcmd("say /vipmenu""VMENU");

    
g_iMenuId menu_create("\yVipmenu""HandleMenu");
    
menu_additem(g_iMenuId"HE""1");
    
menu_additem(g_iMenuId"FBx2""2");
    
menu_additem(g_iMenuId"FN""3");
    
menu_additem(g_iMenuId"USP(2bullets)""4");
}

public 
VMENU(id)
{
    if(
is_user_alive(id) && access(idADMIN_VIP) || access(idADMIN_MENU))
        
menu_display(idg_iMenuId);
}

public 
HandleMenu(idiMenuIdiItem)
{
    if(
iItem == MENU_EXIT || !is_user_alive(id))
        return 
PLUGIN_HANDLED;
        
}
        
    switch(
iItem)
    {
        case 
0
        {
            
give_item(id"weapon_hegrenade");
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed HeGrenade");
        }
        
        case 
1:
        {
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_flashbang");
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed 2 FlashBangs");
        }
        
        
        case 
2:
        {
            
give_item(id"weapon_smokegrenade");
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed FrostNade");
        }
        
        case 
3:
        {
            new 
iWeapon give_itemid"weapon_usp" )
            
cs_set_weapon_ammoiWeapon)
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed USP with 2 bullets");
        }
    }
    
    return 
PLUGIN_HANDLED;

midahekki is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 06:06   Re: HNS Vipmenu
Reply With Quote #2

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <colorchat>
#include <cstrike>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define ADMIN_VIP    ADMIN_LEVEL_H 

new bool:AlreadyUsed[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn",1)
}

public 
fwPlayerSpawn(id) {
    if(!
AlreadyUsed[id])
    {
        if(
get_user_flags(id) & ADMIN_VIP)
        {
            new 
menu menu_create"Menu:""menuhandle");
            
menu_additem(menu"HE""1"); 
            
menu_additem(menu"FBx2""2"); 
            
menu_additem(menu"FN""3"); 
            
menu_additem(menu"USP(2bullets)""4"); 
            
            
menu_setprop(menuMPROP_EXITMEXIT_ALL);
            
menu_display(idmenu0);
        }
    }
}
public 
menuhandle(id,menu,item) {
    if( 
item == MENU_EXIT 
    {
        
menu_destroymenu ); 
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfomenuitemaccessdata,5iName63callback );  
    new 
key str_to_numdata );
    switch( 
key )
    {
        case 
1: {
            
give_item(id"weapon_hegrenade");
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed HeGrenade");
        }
        case 
2: {
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_flashbang");
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed 2 FlashBangs");
        }
        case 
3: {
            
give_item(id"weapon_smokegrenade"); 
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed FrostNade");
        }
        case 
4: {
            new 
iWeapon give_itemid"weapon_usp" )
            
cs_set_weapon_ammoiWeapon)
            
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed USP with 2 bullets");
        }
    }
    
AlreadyUsed[id] = true
    ColorChat
(idNORMAL"^x04[^x03Vipmenu^x04]^x01 Only one use");
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1254\\ deff0\\ deflang1055{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by Erdener; 03-01-2013 at 07:03.
Erdener is offline
midahekki
Junior Member
Join Date: Mar 2013
Old 03-01-2013 , 06:52   Re: HNS Vipmenu
Reply With Quote #3

When i try to compile, this line has error.
PHP Code:
if(!AlreadyUsed[id]) 
: error: undefined symbol "id"
how to fix?
midahekki is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 06:55   Re: HNS Vipmenu
Reply With Quote #4

if(!AlreadyUsed[id])
{
g_iMenuId = menu_create("\yVipmenu", "HandleMenu");
menu_additem(g_iMenuId, "HE", "1");
menu_additem(g_iMenuId, "FBx2", "2");
menu_additem(g_iMenuId, "FN", "3");
menu_additem(g_iMenuId, "USP(2bullets)", "4");
}

Put this part in the VMENU function...
xfirestorm is offline
midahekki
Junior Member
Join Date: Mar 2013
Old 03-01-2013 , 07:00   Re: HNS Vipmenu
Reply With Quote #5

Doesn't work.
midahekki is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 07:04   Re: HNS Vipmenu
Reply With Quote #6

try again.

Last edited by Erdener; 03-01-2013 at 07:04.
Erdener is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 07:05   Re: HNS Vipmenu
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <colorchat>

#define ADMIN_VIP    ADMIN_LEVEL_H

new g_iMenuId;

new 
bool:AlreadyUsed[33];

public 
plugin_init()
{
    
register_plugin("Vipmenu""1.0""Ranel");
    
register_clcmd("say /vipmenu""VMENU");

    
g_iMenuId menu_create("\yVipmenu""HandleMenu");
    
menu_additem(g_iMenuId"HE""1");
    
menu_additem(g_iMenuId"FBx2""2");
    
menu_additem(g_iMenuId"FN""3");
        
menu_additem(g_iMenuId"USP(2bullets)""4");
}

public 
VMENU(id)
{
    if(
is_user_alive(id) && AlreadyUsed[id] && access(idADMIN_VIP) || access(idADMIN_MENU)) {
        
menu_display(idg_iMenuId);
    }
}

public 
HandleMenu(idiMenuIdiItem)
{
    if(
iItem == MENU_EXIT || !is_user_alive(id))
        return 
PLUGIN_HANDLED;

    
AlreadyUsed[id] = true;
    switch(
iItem)
    {
        case 
0:
        {
            
give_item(id"weapon_hegrenade");
                        
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed HeGrenade");
        }

        case 
1:
        {
            
give_item(id"weapon_flashbang");
                        
give_item(id"weapon_flashbang");
                        
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed 2 FlashBangs");
        }


        case 
2:
        {
            
give_item(id"weapon_smokegrenade");
                        
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed FrostNade");
        }

                case 
3:
                {
                        new 
iWeapon give_itemid"weapon_usp" )
            
cs_set_weapon_ammoiWeapon)
                        
ColorChat(idNORMAL"^x04[^x03Vipmenu^x04]^x01 You choosed USP with 2 bullets");
                }
    }

    return 
PLUGIN_HANDLED;

This should.
xfirestorm is offline
midahekki
Junior Member
Join Date: Mar 2013
Old 03-01-2013 , 07:16   Re: HNS Vipmenu
Reply With Quote #8

I can still use the /vipmenu command more than once at one round
midahekki is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 07:22   Re: HNS Vipmenu
Reply With Quote #9

https://forums.alliedmods.net/showpo...94&postcount=2
Erdener is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 07:26   Re: HNS Vipmenu
Reply With Quote #10

Do you want to limit the menu to only display once, or be able to use the options in the menu only once?
If you want it only to be able to display the menu once, then move AlreadyUsed[id] = true from HandleMenu() to VMENU() inside the IF statement.

Also, add this to plugin_init:
register_event("RoundTime", "new_round", "bc")

and a new function:
PHP Code:
public new_round() {
        if(
floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor) != read_data(1)) return
        new 
counter;
        
counter 0;
        while(
counter sizeof(AlreadyUsed)) {
                
AlreadyUsed[counter] = false;
        }

So you'll reset the data of menu already being used that round.
xfirestorm 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 21:41.


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