Junior Member
|
03-28-2020
, 10:29
VIP Menu Plugin problems with compiling
|
#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_add, health_hs_add, health_max;
new nKiller, nKiller_hp, nHp_add, nHp_max;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
//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(id, level)
{
if( !( get_user_flags( id ) & level ) )
{
console_print( id, "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_H, 0);
menu_additem(mVIPmenu, "Grenade Pack", "2", ADMIN_LEVEL_H, 0);
menu_additem(mVIPmenu, "HP Bonus on Kill", "3", ADMIN_LEVEL_H, 0);
}
case 1:
{
menu_additem(mVIPmenu, "Kevler + Helm \r*", "1", ADMIN_LEVEL_H, mcbVIPMenu);
menu_additem(mVIPmenu, "Grenade Pack", "2", ADMIN_LEVEL_H, 0);
menu_additem(mVIPmenu, "HP Bonus on Kill", "3", ADMIN_LEVEL_H, 0);
}
case 2:
{
menu_additem(mVIPmenu, "Kevler + Helm", "1", ADMIN_LEVEL_H, 0);
menu_additem(mVIPmenu, "Grenade Pack \r*", "2", ADMIN_LEVEL_H, mcbVIPMenu);
menu_additem(mVIPmenu, "HP Bonus on Kill", "3", ADMIN_LEVEL_H, 0);
}
case 3:
{
menu_additem(mVIPmenu, "Kevler + Helm", "1", ADMIN_LEVEL_H, 0);
menu_additem(mVIPmenu, "Grenade Pack", "2", ADMIN_LEVEL_H, 0);
menu_additem(mVIPmenu, "HP Bonus on Kill \r*", "3", ADMIN_LEVEL_H, mcbVIPMenu);
}
}
menu_setprop(mVIPmenu, MPROP_EXIT, MEXIT_ALL);
/* Menu End */
menu_display(id, mVIPmenu, 0);
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(id, menu, item) {
if( item == MENU_EXIT ) {
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
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(id, 100);
}
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 = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!n", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
public mcb_VIPMenu(id, menu, item) {
/* 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_max) nKiller_hp = nHp_max;
set_user_health(nKiller, nKiller_hp);
// Screen fading
message_begin(MSG_ONE, get_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!
|
|