Raised This Month: $12 Target: $400
 3% 

Solved VIP Menu Plugin problems with compiling


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
l00ka
Junior Member
Join Date: Sep 2012
Old 03-28-2020 , 10:29   VIP Menu Plugin problems with compiling
Reply With Quote #1

Hello,

I'm currently trying to learn to make amxx plugin and started it by doing an "easy" VIP Menu Plugin.
What it should do, is giving to the VIP an selected feature for next round by choosing them in the current round from the VIP Menu.
At the moment I have 3 Options in the menu:
1. Give Kevler & Helm (This works)
2. Give Free Nades ( This works)
3. Give HP Bonus by killing enemy (This does not work!)

So, for the number 3 I use the code from this plugin. https://forums.alliedmods.net/showthread.php?t=221384

I tested that plugin from the link and it works fine.
But when I use it in my code it does not work. See function add_bonus_hp().

What I also tried is copying the code from the working plugin of the above link, overwrite my hole code with the code from the working plugin and compile it. It compiles without errors.
After register the plugin in the plugins.ini file and trying it out in game to my surprise it don't work. How is that possible?
What did I do wrong ?

Thanks for helping.

My code:
PHP Code:
/* Plugin created by .l00ka*/

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

#define PLUGIN "VIP Menu by .l00ka"
#define VERSION "1.0"
#define AUTHOR ".l00ka"
new mVIPmenu// Menu
new mcbVIPMenu// Menu Callback
new VipUsed[33];
new const 
PREFIX[] = { "!g[VIP-MENU]!n" };
new 
nSelectedItem 0;
new 
health_addhealth_hs_addhealth_max;
new 
nKillernKiller_hpnHp_addnHp_max;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
//register_event("DeathMsg", "execOnNextRound", "a", "1>0");
    
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
    
register_clcmd("say vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
    
// Features
    
health_add         register_cvar("vipmenu_hp""15"); //How many hp VIP will get per kill 
    
health_hs_add         register_cvar("vipmenu_hp_hs""30"); //How many hp VIP will get per head shot kill 
    
health_max         register_cvar("vipmenu_max_hp""100"); //How many hp VIP can have in total 
}


public 
FwdHamSpawn_Post(id)
{
    
// Restrict menu for one time per round
    
if (is_user_alive(id)) {
        
execOnNextRound(id);
        
VipUsed[id] = false;
    }
}


public 
showVIPmenu(idlevel)
{
    if( !( 
get_user_flagsid ) & level ) )
    {
        
console_printid"You have no access to this command." );
        return 
PLUGIN_HANDLED;
    }
    if(!
VipUsed[id]) 
    {    
        
/* Menu Choose VIP Feature: */
        
mVIPmenu menu_create("\yChoose VIP Feature: ^n\rby .l00ka""mh_VipMenuHandler");
        
mcbVIPMenu menu_makecallback("mcb_VIPMenu")
        switch(
nSelectedItem) {
            case 
0
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            
            case 
1
            {
                
menu_additem(mVIPmenu"Kevler + Helm \r*""1"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
2:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack \r*""2"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
3:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill \r*""3"ADMIN_LEVEL_HmcbVIPMenu);
            }
        }    
        
menu_setprop(mVIPmenuMPROP_EXITMEXIT_ALL);
        
/* Menu End */
        
menu_display(idmVIPmenu0);
        
        return 
PLUGIN_HANDLED;
    }
    else if(
VipUsed[id])
    {
        
client_printc(id"%s You Already used !gVIP Menu!n this round. Please wait till next round!"PREFIX);
    }
    else 
    {
        
client_printc(id"%s Only !gAdmins!n and !gVIPs!n may use the VIP Menu"PREFIX);
        return 
PLUGIN_HANDLED;
        
    }
    return 
PLUGIN_HANDLED;
}


/* Menu Choose VIP Feature: */

public mh_VipMenuHandler(idmenuitem) {
    if( 
item == MENU_EXIT ) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;            
                
nSelectedItem key;
                
client_printc(id"%s !gKevler!n and !gHelm!n will be added next round."PREFIX);
            }
            
        }
        case 
2:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gGranade Pack!n will be added next round."PREFIX);
            }
        }
        case 
3:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gHP Bonus!n will be added next round."PREFIX);
            }
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;        
    
}


// Methode that executs the feature of selected MenutItem o next round.
public execOnNextRound(id) {
    switch(
nSelectedItem) {
        case 
1
        {        
            
give_item(id"item_assaultsuit");
            
set_user_armor(id100);
            
        }
        case 
2:
        {
            
give_item(id"weapon_hegrenade");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
        }
        case 
3:
        {
            
add_bonus_hp();
            
        } 
    }
}



// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);        
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
{
    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
    }
}

}



public 
mcb_VIPMenu(idmenuitem) {
/* This is the callback-event, here you can set items enabled or disabled. */
/* If you want to enable an item, use: return ITEM_ENABLED */
/* If you want to disable an item, use: return ITEM_DISABLED */
return ITEM_DISABLED;
}


public 
add_bonus_hp()
{

      
    
// Killer id
    
nKiller read_data(1);
    
    if ( (
read_data(3) == 1) && (read_data(5) == 0) )
    {
        
nHp_add get_pcvar_num (health_hs_add);
    }
    else
        
nHp_add get_pcvar_num (health_add);
        
nHp_max get_pcvar_num (health_max);
        
// Updating Killer HP
        
if(!(get_user_flags(nKiller) & ADMIN_LEVEL_H))
            return;
        
        
nKiller_hp get_user_health(nKiller);
        
nKiller_hp += nHp_add;
        
// Maximum HP check
        
if (nKiller_hp nHp_maxnKiller_hp nHp_max;
        
set_user_health(nKillernKiller_hp);
        
// Screen fading
        
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller);
        
write_short(1<<10);
        
write_short(1<<10);
        
write_short(0x0000);
        
write_byte(0);
        
write_byte(0);
        
write_byte(200);
        
write_byte(75);
        
message_end();
    


Last edited by l00ka; 04-02-2020 at 11:41. Reason: Resolved!
l00ka is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-28-2020 , 10:43   Re: VIP Menu Plugin problems with compiling
Reply With Quote #2

Made an example for you

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

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Bonus HP Example"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pHeadShot;
new 
pKill;
new 
pMaxHp;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("DeathMsg""eDeath""a"); // Register DeathMsg Event.
    
    
pHeadShot register_cvar("amx_headshot""30");
    
pKill register_cvar("amx_kill""15");
    
pMaxHp register_cvar("amx_maxhp""100");
}

public 
eDeath()
{
    
// Save our info.
    
new iAttacker read_data(1);
    new 
iVictim read_data(2);
    
    if(
is_user_alive(iAttacker) && iAttacker != iVictim && iAttacker != && get_user_team(iAttacker) != get_user_team(iVictim))
    {
        new 
iMaxHp get_pcvar_num(pMaxHp);
        new 
iHeadShot read_data(3);
        
        if(
iHeadShot)
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pHeadShot), 0iMaxHp));
        }
        
        else
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pKill), 0iMaxHp));
        }
    }

__________________

Last edited by Napoleon_be; 03-28-2020 at 10:44.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-28-2020 , 10:44   Re: VIP Menu Plugin problems with compiling
Reply With Quote #3

You can't just copy the function from an event and use it like that.

You have no paremeters in the function. "read_data" isn't able to retrieve anything here since this is not an event.

There is no killer and attacker - you can only pass one "id" here.

What you should do is leave the event as it is, and use a bool to check if the player should recieve a bonus. Set that bool to true in the menu handler, case 3, instead of using the "add_bonus_hp" function here.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
l00ka
Junior Member
Join Date: Sep 2012
Old 03-28-2020 , 10:49   Re: VIP Menu Plugin problems with compiling
Reply With Quote #4

Your Example works. Great!
I will try to build it into my Code.
And will post if it works.

Thank you!

Quote:
Originally Posted by Napoleon_be View Post
Made an example for you

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

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Bonus HP Example"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new pHeadShot;
new 
pKill;
new 
pMaxHp;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("DeathMsg""eDeath""a"); // Register DeathMsg Event.
    
    
pHeadShot register_cvar("amx_headshot""30");
    
pKill register_cvar("amx_kill""15");
    
pMaxHp register_cvar("amx_maxhp""100");
}

public 
eDeath()
{
    
// Save our info.
    
new iAttacker read_data(1);
    new 
iVictim read_data(2);
    
    if(
is_user_alive(iAttacker) && iAttacker != iVictim && iAttacker != && get_user_team(iAttacker) != get_user_team(iVictim))
    {
        new 
iMaxHp get_pcvar_num(pMaxHp);
        new 
iHeadShot read_data(3);
        
        if(
iHeadShot)
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pHeadShot), 0iMaxHp));
        }
        
        else
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pKill), 0iMaxHp));
        }
    }

l00ka is offline
l00ka
Junior Member
Join Date: Sep 2012
Old 03-28-2020 , 11:35   Re: VIP Menu Plugin problems with compiling
Reply With Quote #5

After building in the code from @Napoleon_be and following the advice from @OciXCrom
it still doesn't work 100%. The hp bonus feature is working from the next round but after killing an enemy the hp goes back to 100 no matter if headshot or normal kill. Somewhere there is still a problem in my code I guess.

PHP Code:
/* Plugin created by .l00ka*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "VIP Menu by .l00ka"
#define VERSION "1.0"
#define AUTHOR ".l00ka"
new mVIPmenu// Menu
new mcbVIPMenu// Menu Callback
new VipUsed[33];
new const 
PREFIX[] = { "!g[VIP-MENU]!n" };
new 
nSelectedItem 0;
new 
pHeadShot;
new 
pKill;
new 
pMaxHp;
new 
nKillernKiller_hpnHp_addnHp_max;
new 
checkReceiveBonusHP;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("DeathMsg""add_bonus_hp""a""1>0");
    
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
    
register_clcmd("say vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
    
// Features
    
pHeadShot register_cvar("amx_headshot""30");
    
pKill register_cvar("amx_kill""15");
    
pMaxHp register_cvar("amx_maxhp""100");
    
checkReceiveBonusHP false;
}


public 
FwdHamSpawn_Post(id)
{
    
// Restrict menu for one time per round
    
if (is_user_alive(id)) {
        
execOnNextRound(id);
        
VipUsed[id] = false;
    }
}


public 
showVIPmenu(idlevel)
{
    if( !( 
get_user_flagsid ) & level ) )
    {
        
console_printid"You have no access to this command." );
        return 
PLUGIN_HANDLED;
    }
    if(!
VipUsed[id]) 
    {    
        
/* Menu Choose VIP Feature: */
        
mVIPmenu menu_create("\yChoose VIP Feature: ^n\rby .l00ka""mh_VipMenuHandler");
        
mcbVIPMenu menu_makecallback("mcb_VIPMenu")
        switch(
nSelectedItem) {
            case 
0
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            
            case 
1
            {
                
menu_additem(mVIPmenu"Kevler + Helm \r*""1"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
2:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack \r*""2"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
3:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill \r*""3"ADMIN_LEVEL_HmcbVIPMenu);
            }
        }    
        
menu_setprop(mVIPmenuMPROP_EXITMEXIT_ALL);
        
/* Menu End */
        
menu_display(idmVIPmenu0);
        
        return 
PLUGIN_HANDLED;
    }
    else if(
VipUsed[id])
    {
        
client_printc(id"%s You Already used !gVIP Menu!n this round. Please wait till next round!"PREFIX);
    }
    else 
    {
        
client_printc(id"%s Only !gAdmins!n and !gVIPs!n may use the VIP Menu"PREFIX);
        return 
PLUGIN_HANDLED;
        
    }
    return 
PLUGIN_HANDLED;
}


/* Menu Choose VIP Feature: */

public mh_VipMenuHandler(idmenuitem) {
    if( 
item == MENU_EXIT ) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;            
                
nSelectedItem key;
                
client_printc(id"%s !gKevler!n and !gHelm!n will be added next round."PREFIX);
            }
            
        }
        case 
2:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gGranade Pack!n will be added next round."PREFIX);
            }
        }
        case 
3:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gHP Bonus!n will be added next round."PREFIX);
            }
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;        
    
}


// Methode that executs the feature of selected MenutItem o next round.
public execOnNextRound(id) {
    switch(
nSelectedItem) {
        case 
1
        {        
            
give_item(id"item_assaultsuit");
            
set_user_armor(id100);
            
checkReceiveBonusHP false;
            
        }
        case 
2:
        {
            
give_item(id"weapon_hegrenade");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
checkReceiveBonusHP false;
        }
        case 
3:
        {
            
checkReceiveBonusHP true;
        }
    }
}



// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);        
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
{
    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
    }
}

}



public 
mcb_VIPMenu(idmenuitem) {
/* This is the callback-event, here you can set items enabled or disabled. */
/* If you want to enable an item, use: return ITEM_ENABLED */
/* If you want to disable an item, use: return ITEM_DISABLED */
return ITEM_DISABLED;
}


public 
add_bonus_hp()
{

    if(
checkReceiveBonusHP) {
    
// Save our info.
        
new iAttacker read_data(1);
        new 
iVictim read_data(2);
        
        if(
is_user_alive(iAttacker) && iAttacker != iVictim && iAttacker != && get_user_team(iAttacker) != get_user_team(iVictim))
        {
        new 
iMaxHp get_pcvar_num(pMaxHp);
        new 
iHeadShot read_data(3);
        
        if(
iHeadShot)
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pHeadShot), 0iMaxHp));
        }
        
        else
        {
            
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pKill), 0iMaxHp));
        }
        }
    }
    

l00ka is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-28-2020 , 13:24   Re: VIP Menu Plugin problems with compiling
Reply With Quote #6

clamp() is there to make sure that the value doesn't cross a specified value. In my example, i used the pcvar amx_maxhp

Your cvar is this one: health_max = register_cvar("vipmenu_max_hp", "100");

Just change the 100 value to your likings.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
l00ka
Junior Member
Join Date: Sep 2012
Old 03-28-2020 , 14:44   Re: VIP Menu Plugin problems with compiling
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
clamp() is there to make sure that the value doesn't cross a specified value. In my example, i used the pcvar amx_maxhp

Your cvar is this one: health_max = register_cvar("vipmenu_max_hp", "100");

Just change the 100 value to your likings.
The killer should not have more then 100 HP. The problem is that he doesnt get constantly 30 HP on headshot kill or 15 HP on regular kill.

I set max hp to 300 to test how much HP player actually gets and if first kill is headshot he gets 120 HP and on second kill 35 HP.
And when first kill is regular kill he gets 60 HP and on second kill again 60 HP.

When I tested only your code it works perfectly, but when I include it in my code it does strange behavier like above mentioned.
l00ka is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-28-2020 , 15:08   Re: VIP Menu Plugin problems with compiling
Reply With Quote #8

Weird, it should work. Post the code u are currently using.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
l00ka
Junior Member
Join Date: Sep 2012
Old 03-28-2020 , 17:06   Re: VIP Menu Plugin problems with compiling
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
Weird, it should work. Post the code u are currently using.
Yes its really weird.

here is the code:
PHP Code:
/* Plugin created by .l00ka*/

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

#define PLUGIN "VIP Menu by .l00ka"
#define VERSION "1.0"
#define AUTHOR ".l00ka"
new mVIPmenu// Menu
new mcbVIPMenu// Menu Callback
new VipUsed[33];
new const 
PREFIX[] = { "!g[VIP-MENU]!n" };
new 
nSelectedItem 0;
new 
pHeadShot;
new 
pKill;
new 
pMaxHp;
new 
checkReceiveBonusHP;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("DeathMsg""add_bonus_hp""a""1>0");
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
    
register_clcmd("say vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
    
// Features
    
pHeadShot register_cvar("vipmenu_hp_hs""30");
    
pKill register_cvar("vipmenu_hp""15");
    
pMaxHp register_cvar("vipmenu_max_hp""100");
    
checkReceiveBonusHP false;
}


public 
FwdHamSpawn_Post(id)
{
    if (
is_user_alive(id)) {
        
execOnNextRound(id);
        
// Restrict menu for one time per round
        
VipUsed[id] = false;
    }
}


public 
showVIPmenu(idlevel)
{
    if( !( 
get_user_flagsid ) & level ) )
    {
        
console_printid"You have no access to this command." );
        return 
PLUGIN_HANDLED;
    }
    if(!
VipUsed[id]) 
    {    
        
/* Menu Choose VIP Feature: */
        
mVIPmenu menu_create("\yChoose VIP Feature: ^n\rby .l00ka""mh_VipMenuHandler");
        
mcbVIPMenu menu_makecallback("mcb_VIPMenu")
        switch(
nSelectedItem) {
        
            case 
0
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            
            case 
1
            {
                
menu_additem(mVIPmenu"Kevler + Helm \r*""1"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
2:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack \r*""2"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
3:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill \r*""3"ADMIN_LEVEL_HmcbVIPMenu);
            }
        }    
        
menu_setprop(mVIPmenuMPROP_EXITMEXIT_ALL);
        
/* Menu End */
        
menu_display(idmVIPmenu0);
        
        return 
PLUGIN_HANDLED;
    }
    else if(
VipUsed[id])
    {
        
client_printc(id"%s You Already used !gVIP Menu!n this round. Please wait until next round!"PREFIX);
    }
    else 
    {
        
client_printc(id"%s Only !gAdmins!n and !gVIPs!n may use the VIP Menu"PREFIX);
        return 
PLUGIN_HANDLED;
        
    }
    return 
PLUGIN_HANDLED;
}


/* Menu Choose VIP Feature: */

public mh_VipMenuHandler(idmenuitem) {
    if( 
item == MENU_EXIT ) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;            
                
nSelectedItem key;
                
client_printc(id"%s !gKevler!n and !gHelm!n will be added next round."PREFIX);
            }
            
        }
        case 
2:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gGranade Pack!n will be added next round."PREFIX);
            }
        }
        case 
3:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gHP Bonus!n will be added next round."PREFIX);
            }
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;        
    
}


/* Methode that will be called at next round start. */
public execOnNextRound(id) {
    switch(
nSelectedItem) {
        case 
1
        {        
            
give_item(id"item_assaultsuit");
            
set_user_armor(id100);
            
checkReceiveBonusHP false;
            
        }
        case 
2:
        {
            
give_item(id"weapon_hegrenade");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
checkReceiveBonusHP false;
        }
        case 
3:
        {
            
checkReceiveBonusHP true;
        }
    }
}



// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);        
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
{
    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
    }
}

}



public 
mcb_VIPMenu(idmenuitem) {
/* This is the callback-event, here you can set items enabled or disabled. */
/* If you want to enable an item, use: return ITEM_ENABLED */
/* If you want to disable an item, use: return ITEM_DISABLED */
return ITEM_DISABLED;
}


public 
add_bonus_hp()
{
    if(
checkReceiveBonusHP) {
    
// Save our info.
        
new iAttacker read_data(1);
        new 
iVictim read_data(2);
        
        if(
is_user_alive(iAttacker) && iAttacker != iVictim && iAttacker != && get_user_team(iAttacker) != get_user_team(iVictim))
        {
         new 
iMaxHp get_pcvar_num(pMaxHp);
         new 
iHeadShot read_data(3);
        
         if(
iHeadShot)
         {
        
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pHeadShot), 0iMaxHp));
         }
         else
         {
              
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pKill), 0iMaxHp));
         }
        }
    }
    

l00ka is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-29-2020 , 08:14   Re: VIP Menu Plugin problems with compiling
Reply With Quote #10

Try again, Let me know if it works or not.

PHP Code:
/* Plugin created by .l00ka*/

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

#define PLUGIN "VIP Menu by .l00ka"
#define VERSION "1.0"
#define AUTHOR ".l00ka"


new mVIPmenu// Menu
new mcbVIPMenu// Menu Callback
new VipUsed[33];
new const 
PREFIX[] = { "!g[VIP-MENU]!n" };
new 
nSelectedItem 0;
new 
pHeadShot;
new 
pKill;
new 
pMaxHp;
new 
checkReceiveBonusHP[33];


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("DeathMsg""add_bonus_hp""a");
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
    
register_clcmd("say vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vm""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
register_clcmd("say /vipmenu""showVIPmenu"ADMIN_LEVEL_H);
    
    
// Features
    
pHeadShot register_cvar("vipmenu_hp_hs""30");
    
pKill register_cvar("vipmenu_hp""15");
    
pMaxHp register_cvar("vipmenu_max_hp""100");
}

public 
client_putinserver(id)
{
    
checkReceiveBonusHP[id] = false;
}

public 
FwdHamSpawn_Post(id)
{
    if (
is_user_alive(id)) 
    {
        
execOnNextRound(id);
        
// Restrict menu for one time per round
        
VipUsed[id] = false;
    }
}


public 
showVIPmenu(idlevel)
{
    if( !( 
get_user_flagsid ) & level ) )
    {
        
console_printid"You have no access to this command." );
        return 
PLUGIN_HANDLED;
    }
    if(!
VipUsed[id]) 
    {    
        
/* Menu Choose VIP Feature: */
        
mVIPmenu menu_create("\yChoose VIP Feature: ^n\rby .l00ka""mh_VipMenuHandler");
        
mcbVIPMenu menu_makecallback("mcb_VIPMenu")
        switch(
nSelectedItem) {
        
            case 
0
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            
            case 
1
            {
                
menu_additem(mVIPmenu"Kevler + Helm \r*""1"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
2:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack \r*""2"ADMIN_LEVEL_HmcbVIPMenu);
                
menu_additem(mVIPmenu"HP Bonus on Kill""3"ADMIN_LEVEL_H0);
            }
            case 
3:
            {
                
menu_additem(mVIPmenu"Kevler + Helm""1"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"Grenade Pack""2"ADMIN_LEVEL_H0);
                
menu_additem(mVIPmenu"HP Bonus on Kill \r*""3"ADMIN_LEVEL_HmcbVIPMenu);
            }
        }    
        
menu_setprop(mVIPmenuMPROP_EXITMEXIT_ALL);
        
/* Menu End */
        
menu_display(idmVIPmenu0);
        
        return 
PLUGIN_HANDLED;
    }
    else if(
VipUsed[id])
    {
        
client_printc(id"%s You Already used !gVIP Menu!n this round. Please wait until next round!"PREFIX);
    }
    else 
    {
        
client_printc(id"%s Only !gAdmins!n and !gVIPs!n may use the VIP Menu"PREFIX);
        return 
PLUGIN_HANDLED;
        
    }
    return 
PLUGIN_HANDLED;
}


/* Menu Choose VIP Feature: */

public mh_VipMenuHandler(idmenuitem) {
    if( 
item == MENU_EXIT ) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;            
                
nSelectedItem key;
                
client_printc(id"%s !gKevler!n and !gHelm!n will be added next round."PREFIX);
            }
            
        }
        case 
2:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gGranade Pack!n will be added next round."PREFIX);
            }
        }
        case 
3:
        {
            if(
nSelectedItem != key) {            
                
VipUsed[id] = true;    
                
nSelectedItem key;
                
client_printc(id"%s !gHP Bonus!n will be added next round."PREFIX);
            }
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;        
    
}


/* Methode that will be called at next round start. */
public execOnNextRound(id) {
    switch(
nSelectedItem) {
        case 
1
        {        
            
give_item(id"item_assaultsuit");
            
set_user_armor(id100);
            
checkReceiveBonusHP[id] = false;
            
        }
        case 
2:
        {
            
give_item(id"weapon_hegrenade");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
checkReceiveBonusHP[id] = false;
        }
        case 
3:
        {
            
checkReceiveBonusHP[id] = true;
        }
    }
}



// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);        
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

}



public 
mcb_VIPMenu(idmenuitem) {
/* This is the callback-event, here you can set items enabled or disabled. */
/* If you want to enable an item, use: return ITEM_ENABLED */
/* If you want to disable an item, use: return ITEM_DISABLED */
return ITEM_DISABLED;
}


public 
add_bonus_hp()
{
    
// Save our info.
    
new iAttacker read_data(1);
    
    if(
checkReceiveBonusHP[iAttacker]) 
    {
        new 
iVictim read_data(2);
        
        if(
is_user_alive(iAttacker) && iAttacker != iVictim && iAttacker != && get_user_team(iAttacker) != get_user_team(iVictim))
        {
            new 
iMaxHp get_pcvar_num(pMaxHp);
            new 
iHeadShot read_data(3);
        
            if(
iHeadShot)
            {
                
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pHeadShot), 0iMaxHp));
            }
            else
            {
                
set_user_health(iAttackerclamp(get_user_health(iAttacker) + get_pcvar_num(pKill), 0iMaxHp));
            }
        }
    }
    

__________________

Last edited by Napoleon_be; 03-29-2020 at 10:18.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

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 09:47.


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