Raised This Month: $32 Target: $400
 8% 

Solved KnifeMenu Problems With Codes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-04-2020 , 23:38   KnifeMenu Problems With Codes
Reply With Quote #1

Hello Guys,
I made knife menu plugin before 10 min and i got 2 erorrs but i dont know the reason, so can someone exmple me the reason in this plugin ?

PHP Code:
#include <amxmodx>
#include <fakemeta_util>
#include <colorchat>
#include <basebuilder>

new const szKnifePrefix[] = { "^4[KnifeMenu]^1" };
new 
view[33]

enum _:mKnife {
    
m_vKnifeMenu[32],
    
m_pKnifeMenu[32]
};

new 
precache_list[][][mKnife] = 
{
    {
CSW_KNIFE,
    
"models/knifemenu/v_defaultknife.mdl","models/knifemenu/p_defaultknife.mdl",
    
"models/knifemenu/v_combataxe.mdl""models/knifemenu/p_combataxe.mdl",
    
"models/knifemenu/v_bluekatana.mdl""models/knifemenu/p_bluekatana.mdl",
    
"models/knifemenu/v_warhammer.mdl""models/knifemenu/p_warhammer.mdl"
    
}
};


public 
plugin_init()
{
    
register_plugin("Knife Menu""1.0","Supremache")
    
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
    
    
register_clcmd("say /knife","knifemenu")    
    
register_clcmd("say_team /knife","knifemenu")

}

public 
plugin_precache()
{
    for(new 
0<= charsmax(precache_list); i++)
        
precache_model(precache_list[i][mKnife]);

}

public 
client_putinserver(id)
{
    
view[id] = 1
    ColorChat
(0GREY"%s This server is using knife menu by ^3 Supremache^1."szKnifePrefix)
}

public 
knifemenu(id)
{
    new 
menuz;
    static 
amenu[512];
    
formatex(amenu,charsmax(amenu),"\yKnife Menu")
    
menuz menu_create(amenu,"KnifeMenu_Handler")
    new 
szPlayerId[32]
    
get_user_authid(idszPlayerId31)
    
    
formatex(amenu,charsmax(amenu),"\wDefultKnife")
    
menu_additem(menuz,amenu,"1")
    
    if(
get_user_flags(id) & ADMIN_LEVEL_C)
    {
        
formatex(amenu,charsmax(amenu),"\wMaster Combat")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dMaster Combat \r[V.I.P]")
    }        
    
menu_additem(menuz,amenu,"2")

    
    if(
get_user_flags(id) & ADMIN_BAN)
    {
        
formatex(amenu,charsmax(amenu),"\wMotosierra")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dMotosierra \r[ADMINS]")
    }        
    
menu_additem(menuz,amenu,"3")

    if (
equal(szPlayerId"STEAM_0:1:533468949"8))
    {
        
formatex(amenu,charsmax(amenu),"\wDual Axe")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dDual Axe \r[STEAM_0:1:533468949]")
    }        
    
menu_additem(menuz,amenu,"4")
    
    
menu_setprop(menuz,MPROP_EXIT,MEXIT_ALL)
    
menu_display(id,menuz,0)
    
    return 
PLUGIN_HANDLED
}

public 
KnifeMenu_Handler(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
access,callback,data[6],iname[64]
    
    
menu_item_getinfo(menu,item,access,data,5,iname,63,callback)
    
    new 
key str_to_num(data)
    
    if(
key == 1)
    {
        
view[id] = 1
    
}
    else if(
key == 3)
    {
        if(
get_user_flags(id) & ADMIN_LEVEL_C)
        {
            
view[id] = 2
            ColorChat
(0GREEN"%s You have selected^3 Master Combat^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to^3 V.I.P^1."szKnifePrefix)
            
knifemenu(id)
        }
    }

    else if(
key == 3)
    {
        if(
get_user_flags(id) & ADMIN_BAN)
        {
            
view[id] = 3
            ColorChat
(0GREEN"%s You have selected^3 Motosierra^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to^3 ADMINS^1."szKnifePrefix)
            
knifemenu(id)
        }
    }
    else if(
key == 4)
    {
        new 
szPlayerId[32]
        
get_user_authid(idszPlayerId31)
   
        if (
equal(szPlayerId"STEAM_0:1:533468949"8))
        {
            
view[id] = 4
            ColorChat
(0GREEN"%s You have selected^3 Dual Axe^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to this steamid^3 STEAM_0:1:533468949^1."szKnifePrefix)
            
knifemenu(id)
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}

public 
CurrentWeapon(id)
{
    
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    switch (
weaponid)
    {
        case 
CSW_KNIFE:
        {
            if(!
zp_get_user_zombie(id))
            {
                
set_pev(idpev_viewmodel2precache_list[view[id]][m_vKnifeMenu])
                
set_pev(idpev_weaponmodel2precache_list[view[id]][m_pKnifeMenu]);
            }
        }
    }

Erorrs
HTML Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Error: Array index out of bounds (variable "precache_list") on line 39
Error: Array index out of bounds (variable "precache_list") on line 176

2 Errors.
Could not locate output file C:\Users\mohamed\Desktop\NewMod\addons\amxmodx\plugins\ze_knife_menu3.amx (compile failed).

Last edited by HamletEagle; 08-05-2020 at 09:44. Reason: Restore to previous version.
Supremache is offline
thEsp
BANNED
Join Date: Aug 2017
Old 08-05-2020 , 04:39   Re: Remove this topic I have fixed it
Reply With Quote #2

We will surely remove each thread one by one.
thEsp is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-05-2020 , 08:02   Re: Remove this topic I have fixed it
Reply With Quote #3

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
If you solved it, why did you delete your post? It should stay as you posted and you also post the solution. If anyone has the same problem, may find your thread and solve it by himself without asking. That's how a dev community works.

Please revert your thread and post the solution.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2020 , 09:44   Re: KnifeMenu Problems With Codes
Reply With Quote #4

1.Don't empty your post
2.If you find the solution post it, it may help others. Expecting to get free help on the forum without contributing in any way is kinda selfish.
__________________

Last edited by HamletEagle; 08-05-2020 at 09:45.
HamletEagle is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-05-2020 , 14:28   Re: KnifeMenu Problems With Codes
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
1.Don't empty your post
2.If you find the solution post it, it may help others. Expecting to get free help on the forum without contributing in any way is kinda selfish.
No, I didn't mean that i was have 10 min until i made this plugin and i didn't focus to it so when i rechecked it i saw the problem and i fixed and all that after 5 min when i made this topic and i saw only 4 saw this topic so there's no problem if i removed it, i dont have access for remove the topic i have access only for remove the post.
Supremache is offline
thEsp
BANNED
Join Date: Aug 2017
Old 08-05-2020 , 17:12   Re: KnifeMenu Problems With Codes
Reply With Quote #6

Untrustworthy justifications. If you did something wrong it doesn't mean nobody will find this thread [along with its solution] useful in the future.

Last edited by thEsp; 08-05-2020 at 17:12.
thEsp is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-05-2020 , 23:40   Re: KnifeMenu Problems With Codes
Reply With Quote #7

Quote:
Originally Posted by thEsp View Post
Untrustworthy justifications. If you did something wrong it doesn't mean nobody will find this thread [along with its solution] useful in the future.
Why you saying that, There's nothing makes me lie.
Anyway what i can do now ?!
Supremache is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 08-05-2020 , 23:45   Re: KnifeMenu Problems With Codes
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
1.Don't empty your post
2.If you find the solution post it, it may help others. Expecting to get free help on the forum without contributing in any way is kinda selfish.
ZaX is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-05-2020 , 23:54   Re: KnifeMenu Problems With Codes
Reply With Quote #9

Okay, then this is the plugin after solve but i didn't tested it yet

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>
#include <colorchat>
#include <basebuilder>

#define OFFSET_WPN_WIN       41
#define OFFSET_WPN_LINUX  4

new const szKnifePrefix[] = { "^4[KnifeMenu]^1" };
new 
view[33]

enum _:mKnife {
    
m_vKnifeMenu[55],
    
m_pKnifeMenu[55]
};

new 
precache_list[][mKnife] = 
{
    
"models/knifemenu/v_defaultknife.mdl","models/knifemenu/p_defaultknife.mdl",
    
"models/knifemenu/v_combataxe.mdl""models/knifemenu/p_combataxe.mdl",
    
"models/knifemenu/v_bluekatana.mdl""models/knifemenu/p_bluekatana.mdl",
    
"models/knifemenu/v_warhammer.mdl""models/knifemenu/p_warhammer.mdl"
};


public 
plugin_init()
{
    
register_plugin("Knife Menu""1.0","Supremache")
    
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
    
RegisterHam(Ham_Item_Deploy"weapon_knife",  "Ham_Item_Deploy_Post"1);
    
    
register_clcmd("say /knife","knifemenu")    
    
register_clcmd("say_team /knife","knifemenu")

}

public 
plugin_precache()
{
    for(new 
0<= charsmax(precache_list); i++)
        
precache_model(precache_list[i]);
}

public 
client_putinserver(id)
{
    
view[id] = 1
    ColorChat
(0GREY"%s This server is using knife menu by ^3 Supremache^1."szKnifePrefix)
}

public 
Ham_Item_Deploy_Post(weapon_ent)
{
    static 
owner
    owner 
get_pdata_cbase(weapon_entOFFSET_WPN_WINOFFSET_WPN_LINUX);

    static 
weaponid
    weaponid 
cs_get_weapon_id(weapon_ent)
    
    
// Replace weapon models with custom ones
    
replace_weapon_models(ownerweaponid)

}


public 
knifemenu(id)
{
    new 
menuz;
    static 
amenu[512];
    
formatex(amenu,charsmax(amenu),"\yKnife Menu")
    
menuz menu_create(amenu,"KnifeMenu_Handler")
    new 
szPlayerId[32]
    
get_user_authid(idszPlayerId31)
    
    
formatex(amenu,charsmax(amenu),"\wDefultKnife")
    
menu_additem(menuz,amenu,"1")
    
    if(
get_user_flags(id) & ADMIN_LEVEL_C)
    {
        
formatex(amenu,charsmax(amenu),"\wMaster Combat")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dMaster Combat \r[V.I.P]")
    }        
    
menu_additem(menuz,amenu,"2")

    
    if(
get_user_flags(id) & ADMIN_BAN)
    {
        
formatex(amenu,charsmax(amenu),"\wMotosierra")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dMotosierra \r[ADMINS]")
    }        
    
menu_additem(menuz,amenu,"3")

    if (
equal(szPlayerId"STEAM_0:1:533468949"8))
    {
        
formatex(amenu,charsmax(amenu),"\wDual Axe")
    }
    else
    {
        
formatex(amenu,charsmax(amenu),"\dDual Axe \r[STEAM_0:1:533468949]")
    }        
    
menu_additem(menuz,amenu,"4")
    
    
menu_setprop(menuz,MPROP_EXIT,MEXIT_ALL)
    
menu_display(id,menuz,0)
    
    return 
PLUGIN_HANDLED
}

public 
KnifeMenu_Handler(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
access,callback,data[6],iname[64]
    
    
menu_item_getinfo(menu,item,access,data,5,iname,63,callback)
    
    new 
key str_to_num(data)
    
    if(
key == 1)
    {
        
view[id] = 1
    
}
    else if(
key == 2)
    {
        if(
get_user_flags(id) & ADMIN_LEVEL_C)
        {
            
view[id] = 2
            ColorChat
(0GREEN"%s You have selected^3 Master Combat^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to^3 V.I.P^1."szKnifePrefix)
            
knifemenu(id)
        }
    }

    else if(
key == 3)
    {
        if(
get_user_flags(id) & ADMIN_BAN)
        {
            
view[id] = 3
            ColorChat
(0GREEN"%s You have selected^3 Motosierra^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to^3 ADMINS^1."szKnifePrefix)
            
knifemenu(id)
        }
    }
    else if(
key == 4)
    {
        new 
szPlayerId[32]
        
get_user_authid(idszPlayerId31)
   
        if (
equal(szPlayerId"STEAM_0:1:533468949"8))
        {
            
view[id] = 4
            ColorChat
(0GREEN"%s You have selected^3 Dual Axe^1."szKnifePrefix)
        }
        else
        {
            
ColorChat(0GREY"%s This is only available to this steamid^3 STEAM_0:1:533468949^1."szKnifePrefix)
            
knifemenu(id)
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}

public 
CurrentWeapon(id)
{
    
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    switch (
weaponid)
    {
        case 
CSW_KNIFE:
        {
            if(!
zp_get_user_zombie(id))
            {
                
set_pev(idpev_viewmodel2precache_list[view[id]][m_vKnifeMenu])
                
set_pev(idpev_weaponmodel2precache_list[view[id]][m_pKnifeMenu]);
            }
        }
    }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang1055\\ f0\\ fs16 \n\\ par }
*/ 
Supremache is offline
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 21:23.


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