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

[HELP] Fix Compiling Errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 04-18-2014 , 02:01   [HELP] Fix Compiling Errors
Reply With Quote #1

Hello everyone, am not sure this the right section for this
when i compile this code
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define SKINS 11

new g_knife[33];
    
new const 
g_knifemodels[SKINS][64] = {
    
"models/v_knife.mdl"// The default model, don't touch
    
"models/KnifeMenu/v_GoldKnife.mdl",
    
"models/KnifeMenu/v_FadeKnife.mdl",
    
"models/KnifeMenu/v_GutKnife.mdl",
    
"models/KnifeMenu/v_FlipKnife.mdl"
    
"models/KnifeMenu/v_M9BayonetKnife.mdl",
    
"models/KnifeMenu/v_KarambitKnife.mdl"
}

new const 
g_knifenames [SKINS][32] = {
    
"Default Knife",
    
"Gold Knife",
    
"Fade Knife",
    
"Gut Knife",
    
"Flip Knife",
    
"M9 BayonetKnife",
    
"Karambit Knife"
}

new 
g_knifecosts[SKINS][] = {
    
"0",
    
"0",
    
"0",
    
"0",
    
"0",
    
"0",
    
"0"

}

new 
g_knifeflag[SKINS][] = {
    
"0",
    
"0",
    
"0",
    
"0",
    
"0",
    
"0",
    
"0"
}  

static const 
PORTAL    [ ] = "^1[ ^4Knife Menu ^1]"
static const DIE    [ ] = "You Cant Open The ^4Knife Menu ^1You Must Be Alive!"
static const MONEY    [ ] = "You dont have money for this knife skin !"
static const BUY    [ ] = "You Have Bought ^3"

#define PLUGIN "Knife Menu"
#define VERSION "1.0"
#define AUTHOR "SkillerkoS"

#define NAZEV_PORTALU "Knife Menu"
#define VIP_FLAG ADMIN_LEVEL_H


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /knifeshop""cmd_knife")
    
register_clcmd("say /knife""cmd_knife")
    
    
register_event("CurWeapon","Event_CurWeapon","be","1=1");
}

public 
plugin_precache(){
    for (new 
i<= sizeof g_knifemodelsi++)
        
precache_model(g_knifemodels[i]);
}
    
public 
client_putinserver(client)
    
g_knife[client] = 0;

public 
Event_CurWeapon(client){
    
    if (
read_data(2) == CSW_KNIFE)
        
set_pev(client,pev_viewmodel2,g_knifemodels[g_knife[client]]);
    
}

public 
cmd_knife(id){
    new 
szSome[256];
    if(
is_user_alive(id))
    {
        new 
knife menu_create("Knife Menu""cmd_knife_h");
        new 
cb menu_makecallback("knife_callback");
        
        for (new 
i<= SKINS 1i++)
        {
            
formatex(szSome,255,"%s",g_knifenames[i]);  
            
menu_additem(knife,szSome,g_knifeflag[i],.callback=cb);
        }    
        
        
menu_display(id,knife);
    }
    
    else
        
ChatColor(id"%s %s"PORTAL, DIE);
}

public 
knife_callback(client,knife,item){
    new 
access,callback,szInfo[8],szName[32];
    
menu_item_getinfo(knife,item,access,szInfo,8,szName,32,callback);
    
    if (
str_to_num(szInfo) == && !(get_user_flags(client) & VIP_FLAG))
        return 
ITEM_DISABLED;
        
    return 
ITEM_ENABLED;
}
    
public 
cmd_knife_h(clientknifeitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(knife);
        return;
    }
    
    if (
cs_get_user_money(client) < str_to_num(g_knifecosts[item]))
    {
        
ChatColor(client,"%s %s",PORTAL,MONEY);
        return;
    }
    
    
cs_set_user_money(client,(cs_get_user_money(client) - str_to_num(g_knifecosts[item])),1);
    
g_knife[client] = item;
    
ChatColor(client,"%s %s%s",PORTAL,BUY,g_knifenames[g_knife[client]]);
}
    
stock ChatColor(const id, const input[], any:...) {
    new 
count 1players32 ]
    static 
msg191 ]
    
vformatmsg190input)
    
    
replace_allmsg190"!g""^4" )
    
replace_allmsg190"!y""^1" )
    
replace_allmsg190"!t""^3" )

    
    if(
idplayers] = id
    else 
get_playersplayerscount"ch" )
    
    for(new 
0counti++)
    {
        if( 
is_user_connectedplayers] ) )
        {
            
message_beginMSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players] )  
            
write_byteplayers] )
            
write_stringmsg )
            
message_end( )
        }
    }

i got those errors :/

Help please
Thanks For Your Attention
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	142
Size:	32.6 KB
ID:	132769  
Attached Files
File Type: sma Get Plugin or Get Source (KnifeMenu.sma - 126 views - 3.8 KB)
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه

Last edited by 5aloOod; 04-18-2014 at 02:04.
5aloOod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2014 , 02:18   Re: [HELP] Fix Compiling Errors
Reply With Quote #2

When you declare an array and assign some values, you need to assign a value to every element of the array. In your code, you have all your arrays declared with "SKINS" as the first dimension. You must have that many elements in that array. You only have 7. "SKINS" is set at 11. You need to fix the disparity.

The only exception to this rule is when the dimension is the maximum cells for the string.
__________________

Last edited by fysiks; 07-27-2014 at 19:12. Reason: typos
fysiks is offline
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 04-18-2014 , 02:35   Re: [HELP] Fix Compiling Errors
Reply With Quote #3

ops
Thank you fysiks for your help
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
5aloOod is offline
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 07-25-2014 , 09:45   Re: [HELP] Fix Compiling Errors
Reply With Quote #4

Quote:
L 07/25/2014 - 1728: Start of error session.
L 07/25/2014 - 1728: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20140725.log")
L 07/25/2014 - 1728: [AMXX] Displaying debug trace (plugin "KnifeMenu.amxx", version "unknown")
L 07/25/2014 - 1728: [AMXX] Run time error 4: index out of bounds
L 07/25/2014 - 1728: [AMXX] [0] KnifeMenu.sma::plugin_precache (line 73)
line 73
Quote:
public plugin_precache(){
for (new i; i <= sizeof g_knifemodels; i++)
precache_model(g_knifemodels[i]);
}
whats the problem her?
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
5aloOod is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-25-2014 , 11:29   Re: [HELP] Fix Compiling Errors
Reply With Quote #5

Your problem is that you do i <= sizeof, it should be i < sizeof.

Last edited by HamletEagle; 07-25-2014 at 11:29.
HamletEagle is offline
Reply



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:56.


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