AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HNS Vipmenu (https://forums.alliedmods.net/showthread.php?t=209730)

midahekki 03-01-2013 05:53

HNS Vipmenu
 
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;



Erdener 03-01-2013 06:06

Re: HNS Vipmenu
 
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 }
*/ 


midahekki 03-01-2013 06:52

Re: HNS Vipmenu
 
When i try to compile, this line has error.
PHP Code:

if(!AlreadyUsed[id]) 

: error: undefined symbol "id"
how to fix?

xfirestorm 03-01-2013 06:55

Re: HNS Vipmenu
 
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...

midahekki 03-01-2013 07:00

Re: HNS Vipmenu
 
Doesn't work.

Erdener 03-01-2013 07:04

Re: HNS Vipmenu
 
try again.

xfirestorm 03-01-2013 07:05

Re: HNS Vipmenu
 
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.

midahekki 03-01-2013 07:16

Re: HNS Vipmenu
 
I can still use the /vipmenu command more than once at one round

Erdener 03-01-2013 07:22

Re: HNS Vipmenu
 
https://forums.alliedmods.net/showpo...94&postcount=2

xfirestorm 03-01-2013 07:26

Re: HNS Vipmenu
 
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.


All times are GMT -4. The time now is 21:41.

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