Need help to fix vipmenu for knife Server

General Support & Discussion related to Half Life 1 games including Counter Strike 1.6, Condition Zero, Day of Defeat, Team Fortress Classic, and Natural Selection.
Post Reply
Infamous2017
GameServers.com Forum Newb
Posts: 5
Joined: Tue Oct 18, 2016 4:21 am

Need help to fix vipmenu for knife Server

Post by Infamous2017 » Tue Oct 18, 2016 4:24 am

Hello i am new here - i want ask maybe someone can help me with my vipplugin. The Problem is that the Knifemenu dont open when i use it. Anyone have an idea about that and how to fix that?

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
 
#pragma semicolon 1
 
#define VIP_ACCESS ADMIN_CHAT /* flag "i" */
 
#define BEACON_TASKID 420
 
#define MAX_PLAYERS 32
 
#define MAX_KNIVES 6
 
#define XO_CBASEPLAYERITEM 4
 
const m_pPlayer = 41;
 
new g_iMenu;
 
new g_beacon_sprite;
 
new const g_beacon_sound[] = "buttons/blip1.wav";
new const g_beacon_model[] = "sprites/laserbeam.spr";
 
new bool:g_beacon[MAX_PLAYERS + 1];
new g_iKnives[MAX_PLAYERS + 1] = { -1, -1, ... };
 
enum _:KnifeData
{
    NAME[16],
    VMODEL[64]
};
 
new const g_KnivesData[MAX_KNIVES][KnifeData] = {
    { "Default Knife", "models/v_knife.mdl" },
    { "Knife #1", "models/newknives1234/v_knife1.mdl" },
    { "Knife #2", "models/newknives1234/v_knife2.mdl" },
    { "Knife #3", "models/newknives1234/v_knife3.mdl" },
    { "Knife #4", "models/newknives1234/v_knife4.mdl" },
    { "Knife #5", "models/newknives1234/v_knife5.mdl" }
};
 
public plugin_init() {
    register_plugin("VIP Stuff","v1.0","Hyuna");
    
    create_thevip_menu();
    register_clcmd("say !vip","cmdVips",VIP_ACCESS,"Shows VIP Menu");
    
    RegisterHam(Ham_Killed,"player","fwdHamKilledPost",1);
    RegisterHam(Ham_Item_Deploy,"weapon_knife","fwdHamItemDeployPost",1);
}

public create_thevip_menu()
{
    g_iMenu = menu_create("[AMXX] VIP Menu","mHandler");
    
    menu_additem(g_iMenu,"Add 120HP");
    menu_additem(g_iMenu,"Active/Deactive Beacon");
    menu_additem(g_iMenu,"Drug me");
    menu_additem(g_iMenu,"75% Gravity");
    menu_addblank(g_iMenu,1);
    menu_additem(g_iMenu,"Knife Menu");
}
 
public plugin_precache() {
    g_beacon_sprite = precache_model(g_beacon_model);
    precache_sound(g_beacon_sound);
    
    for (new i = 1; i < MAX_KNIVES; i++)
    {
        if(!file_exists(g_KnivesData[i][VMODEL])) // Safe fail check
        {
            new ****[128];
            formatex(****,charsmax(****),"Error! Model ^"%s^" not found!",g_KnivesData[i][VMODEL]);
            set_fail_state(****);
        }
            
        precache_model(g_KnivesData[i][VMODEL]);
    }
}
 
public client_connect(client) {
    g_beacon[client] = false;
    g_iKnives[client] = -1;
}
 
public client_disconnect(client) {
    g_beacon[client] = false;
    g_iKnives[client] = -1;
}
 
public fwdHamKilledPost(client, idattacker, shouldgib) {
    g_beacon[client] = false;
}
 
public fwdHamItemDeployPost(ent) {
    new client = get_pdata_cbase(ent,m_pPlayer,XO_CBASEPLAYERITEM);
 
    set_pev(client,pev_viewmodel2,g_KnivesData[g_iKnives[client]][VMODEL]);
}
 
public cmdVips(client,level,cid) {
    if (!cmd_access(client,level,cid,1))
    {
        client_print(client,print_chat,"[AMXX] You have no access!");
        return PLUGIN_HANDLED;
    }
    
    if (!is_user_alive(client))
    {
        client_print(client,print_chat,"[AMXX] You need to be alive to use this menu!");
        return PLUGIN_HANDLED;
    }
    
    menu_display(client, g_iMenu);
    
    return PLUGIN_HANDLED;
}
 
public mHandler(client,menu,item) {
    if (!is_user_alive(client))
        return PLUGIN_HANDLED;
        
    switch (item)
    {
        case 0:
        {
            set_user_health(client,max(get_user_health(client) + 120,255));
            client_print(client,print_chat,"[AMXX] You have got 120HP!");
        }
        
        case 1:
        {
            g_beacon[client] = !g_beacon[client];
            
            client_print(client,print_chat,"[AMXX] You have %sabled beacon!",(g_beacon[client] ? "en":"dis"));
            
            if (g_beacon[client])
                set_task(1.0,"create_beacon",BEACON_TASKID + client,.flags="b");
        }
        case 2:
        {
            makeMeDrugged(client);
            client_print(client,print_chat,"[AMXX] You have smoked some weed!");
        }
        
        case 3:
        {
            set_user_gravity(client,0.75);
            client_print(client,print_chat,"[AMXX] You have got 25% less gravity!");
        }
        
        case 4: showKnifeMenu(client);
    }
    
    return PLUGIN_HANDLED;
}
 
public showKnifeMenu(client) {
    static ****[128], iKnivesMenu, i,cb;
    
    iKnivesMenu = menu_create("[AMXX] Vip's Knife Menu","mKnifeHandler");
    cb = menu_makecallback("mKnifeCallback");
    
    for (i = 0; i < MAX_KNIVES; i++)
    {
        formatex(****,charsmax(****),"%s %s",g_KnivesData[i][NAME],(g_iKnives[client] == i ? "- Current Knife":""));
        menu_additem(iKnivesMenu,****,.callback=cb);
    }
    menu_display(client, iKnivesMenu);
}
 
public mKnifeCallback(client,menu,item) {
    return (g_iKnives[client] == item) ? ITEM_DISABLED:ITEM_ENABLED;
}
 
public mKnifeHandler(client,menu,item) {    
    if (item != MENU_EXIT)
    {
        g_iKnives[client] = item;
        
        client_print(client,print_chat,"[AMXX] You have choosed %s as your current knife.",g_KnivesData[item][NAME]);   
    }
    
    menu_destroy(menu);
    return PLUGIN_HANDLED;
}
 
public create_beacon(player) {
    player -= BEACON_TASKID;
    
    if (!is_user_alive(player) || !g_beacon[player])
    {
        remove_task(player + BEACON_TASKID);
        return;
    }
    
    static origin[3];
    emit_sound(player,CHAN_ITEM,g_beacon_sound,1.0,ATTN_NORM,0,PITCH_NORM);
    
    get_user_origin(player,origin);
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_BEAMCYLINDER);
    write_coord(origin[0]); //position.x
    write_coord(origin[1]); //position.y
    write_coord(origin[2] - (pev(player,pev_button) & IN_DUCK ? 7:25)); //position.z
    write_coord(origin[0]);    //axis.x
    write_coord(origin[1]);    //axis.y
    write_coord(origin[2]+200); //axis.z
    write_short(g_beacon_sprite); //sprite index
    write_byte(0);       //starting frame
    write_byte(1);        //frame rate in 0.1's
    write_byte(6);        //life in 0.1's
    write_byte(2);        //line width in 0.1's
    write_byte(1);        //noise amplitude in 0.01's
    
    new bool:is_terrorist = (cs_get_user_team(player) == CS_TEAM_T) ? true:false;
    
    write_byte(is_terrorist ? 255:0);   //red
    write_byte(0);          //green
    write_byte(is_terrorist ? 0:255);   //blue
    
    write_byte(255);     //brightness
    write_byte(6);       //scroll speed in 0.1's
    message_end();
}
 
stock makeMeDrugged(client) {
    static msgSetFOV;
    
    if (!msgSetFOV)
        msgSetFOV = get_user_msgid("SetFOV");
        
    message_begin(MSG_ONE,msgSetFOV,{ 0, 0, 0 },client);
    write_byte(180);
    message_end();
}

Post Reply