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

Plugin compile error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rago12
Junior Member
Join Date: Jul 2016
Old 07-24-2016 , 16:58   Plugin compile error
Reply With Quote #1

Heyp, i get an error while trying to compile uno specific plugin :

Code:
#include <amxmodx>
#include <amxmisc>  
#include <cstrike>
#include <chatcolor>
#include <fvault>

#define MaxLevels 19
#define IsPlayer(%1) (1 <= %1 <=  g_iMaxPlayers)

new gMaxPlayers, gMsgSayText, syncObj, Level[33], eXP[33]
new ranks_hud, knife_xp, he_xp, hs_xp, kill_xp, kill_msg

new const g_vault_name[] = "levelsz";

new const Levels[MaxLevels] = 
{
    200,
    500, 
    800, 
    1050, 
    1500, 
    2000, 
    2500, 
    3000,
    3800,
    4500, 
    6000,
    8000,
    11000,
    15000,
    20000,
    30000,
    38000,
    45000,
    50000
}

new const Prefix[MaxLevels +1][] =
{
    "Newbie",
    "Player",
    "Pro",
    "Matrix",
    "TimeKiller",
    "Destroyer",
    "Elvis",
    "Speedline",
    "Veteran",
    "Killer",
    "Stopper",
    "Tesla",
    "Vader",
    "General",
    "Alpha",
    "Beta",
    "Gama",
    "Muhammad Ali",
    "Chuk Norris"
}

public plugin_init() 
{
    register_plugin("Ranks & XP mod", "1.0", "alt.nick")
    
    register_event("DeathMsg","client_death","a") 
    register_clcmd("say", "hook_say")
    register_clcmd("say_team", "hook_say")
    
    register_clcmd("say /rank", "cmdRank")
    register_clcmd("say_team /rank", "cmdRank")
    
    register_clcmd("say /reset", "reset_xp")
    register_clcmd("say_team /reset", "reset_xp")
    
    ranks_hud = register_cvar("ranks_hud", "1")     // Дали да се появява хъд при влизане в сървъра. Включено 1/0 Изключено
    knife_xp = register_cvar("knife_xp", "4")     // Колко ХР да дава за убийство с нож.
    he_xp = register_cvar("he_xp", "1")        // Колко ХР да дава за убийство с Granata (HE).
    hs_xp = register_cvar("hs_xp", "3")        // Колко ХР да дава за убийство с Headshot.
    kill_xp = register_cvar("kill_xp", "1")        // Колко ХР да дава за нормално убийство.    
    kill_msg = register_cvar("kill_msg", "1")    // Дали да показва кой сте убили и колко ХР сте получили. Включено 1/0 Изключено
    
    register_concmd ("amx_give_xp", "CmdAddXP", ADMIN_LEVEL_A, "<nick | ct | t | @all> <xp>")
    
    gMaxPlayers = get_maxplayers()
    gMsgSayText = get_user_msgid("SayText")

    syncObj     = CreateHudSyncObj()
    
    fvault_load(g_vault_name)
}

public ShowHud(id) 
{
    set_hudmessage(142, 239, 39, -1.0, 0.01, 0, 6.0, 1.0, 0.0, 0.0, -1)
    ShowSyncHudMsg(id, syncObj,"Rank: %s ^nXP: %i ^nLevel: %i", Prefix[Level[id]], eXP[id], Level[id])
}

public client_putinserver(id)
{
    if(get_pcvar_num(ranks_hud) == 1)
        set_task(1.0, "ShowHud", id, _, _, "b")
        
    if(Level[id] < MaxLevels-1)
        while(eXP[id] >= Levels[Level[id]])
            Level[id] += 1 
}

public client_death(killer, victim, weapon, hitgroup, TK)
{        
    if(killer == victim)
        return PLUGIN_HANDLED
        
    new Name[20]
    get_user_name(victim, Name, 19)
    new headshot = (hitgroup == HIT_HEAD) ? 1 : 0
    
    if(get_user_team(killer) == 2 && killer != victim)
    {
        switch(weapon) 
        {
            case CSW_HEGRENADE:
            {
                eXP[killer] += get_pcvar_num(he_xp)
                CheckLevel(killer)
                SaveData(killer)
                if(get_pcvar_num(kill_msg) == 1)
                    client_print_color(killer, print_chat, "^4[Ranks]^1 poluchihte^4 %d XP^1 poradi ubiistwoto s^4 HE^1 na ^3%s^1.", get_pcvar_num(he_xp), Name)
            } 
            
            case CSW_KNIFE:
            {
                eXP[killer] += get_pcvar_num(knife_xp)
                CheckLevel(killer)
                SaveData(killer)
                if(get_pcvar_num(kill_msg) == 1)
                    client_print_color(killer, print_chat, "^4[Ranks]^1 poluchihte^4 %d XP^1 poradi ubiistwoto s^4 noj^1 na ^3%s^1.", get_pcvar_num(knife_xp) , Name)
            } 
        }
        
        if(headshot)
        {
            eXP[killer] += get_pcvar_num(hs_xp)
            CheckLevel(killer)
            SaveData(killer)
            if(get_pcvar_num(kill_msg) == 1)
                client_print_color(killer, print_chat, "^4[Ranks]^1 poluchihte^4 2 XP^1 poradi ubiistwoto s^4 HS^1 na ^3%s^1.",get_pcvar_num(hs_xp),  Name)
        }
        else
        {
            eXP[killer] += get_pcvar_num(kill_xp)
            CheckLevel(killer)
            SaveData(killer)
            if(get_pcvar_num(kill_msg) == 1)
                client_print_color(killer, print_chat, "^4[Ranks]^1 poluchihte^4 1 XP^1 poradi ubiistwoto na ^3%s^1.", get_pcvar_num(kill_xp), Name)
        }
    }
    CheckLevel(killer)
    SaveData(killer)
    return PLUGIN_CONTINUE
}

public CheckLevel(id)
{
    if(Level[id] < MaxLevels-1)
        while(eXP[id] >= Levels[Level[id]])
            Level[id] += 1 
}

public client_connect(id)
{
    LoadData(id)
}


public client_disconnect(id)
{
    SaveData(id)
    eXP[id] = 0
    Level[id] = 0
    remove_task(id)
}
        
public reset_xp(id)
{
    if(eXP[id] != 0)
    {
        Level[id] = 0
        eXP[id] = 0
        CheckLevel(id)
        client_print_color(id, print_chat, "^4[Ranks]^1 Yspeshno nulirani washite^4 XP^1 i ^4Level^1.")
    }
    else
        client_print_color(id, print_chat, "^4[Ranks]^1 Washite^4 XP^1 i ^4Level^1 weche sa nulirani.")
}
        
public cmdRank(id)
{
    if(is_user_connected(id))
        client_print_color(id, print_chat, "^4[Ranks]^1 Rank:^4 %s^1 | XP:^4 %d^1 | Level:^4 %d^1.", Prefix[Level[id]], eXP[id], Level[id])
}
        
public CmdAddXP (iPlayer, level, cid)
{
    if(!cmd_access(iPlayer, level, cid, 3)) return PLUGIN_HANDLED;
        
    new arg [32]
    read_argv (1, arg, 31) 
 
    new AddXP [32]
    read_argv (2, AddXP, charsmax (AddXP))
 
    new XPtoGive = str_to_num (AddXP)
        
    new AdminName [32]
    new TargetName [32]
    get_user_name (iPlayer, AdminName, charsmax (AdminName))
        
    if(arg[0]=='@')
    { 
        if(equali(arg[1],"All") || equali(arg[1],"ALL"))
        {
            new players[32], totalplayers, All
            get_players(players, totalplayers)
             
            for (new i = 0; i < totalplayers; i++)
            {
                All = players[i]
                        
                eXP[All] += XPtoGive
            }
            
            CheckLevel(All)
            client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na vsichki ^3igrachi^1!", AdminName, XPtoGive)
        }
        else if(equali(arg[1],"T") || equali(arg[1],"t"))
        {
            new players[32], totalplayers, T
            get_players(players, totalplayers)
             
            for (new i = 0; i < totalplayers; i++)
            {
                if (get_user_team(players[i]) == 1)
                {
                    T = players[i]
                            
                    eXP[T] += XPtoGive
                }
            }
            
            CheckLevel(T)
            client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na vsichki ^3 Teroristi^1.", AdminName, XPtoGive)
        }
        else if(equali(arg[1],"CT") || equali(arg[1],"ct"))
        {
            new players[32], totalplayers, CT
            get_players(players, totalplayers)
             
            for(new i = 0; i < totalplayers; i++)
            {
                if(get_user_team(players[i]) == 2)
                {
                    CT = players[i]
                            
                    eXP[CT] += XPtoGive
                }
            }
            
            CheckLevel(CT)
            client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na wsichki ^3 Kontra-Teroristi^1!", AdminName, XPtoGive)
        }
    }
    else
    {
        new iTarget = cmd_target(iPlayer, arg, 3)
        get_user_name (iTarget, TargetName, charsmax (TargetName))
        
        if(iTarget)
        {
            eXP[iTarget] += XPtoGive
            
            CheckLevel(iTarget)
            client_print_color(0, print_chat, "^4[Ranks]^1 ^3%s^1 dade^3 %i^1 XP na^3 %s^1.", AdminName, XPtoGive, TargetName)
        }
    }
    return PLUGIN_HANDLED
}

bool:IsValidMessage( szMessage[ ], iLen )
{
    read_args( szMessage, iLen )
    remove_quotes( szMessage )
   
    new iPos, cChar
    while( 0 <= ( cChar = szMessage[ iPos++ ] ) <= 255 )
    {
        if( cChar != ' ' && cChar != '%' )
        {
            return true
        }
    }
   
    return false
}

public hook_say(id)
{
    if(!is_user_connected(id)) 
        return PLUGIN_HANDLED_MAIN
    
    new szArgs[192]
    
    if( !IsValidMessage(szArgs, charsmax(szArgs))) 
        return PLUGIN_HANDLED_MAIN

    if(equal(szArgs,"")) return PLUGIN_HANDLED_MAIN

    
    new szName[32]
    get_user_name(id, szName, sizeof szName-1)

    new alive = is_user_alive(id)

    if(contain(szArgs,"@") >= 0) 
    return  PLUGIN_HANDLED_MAIN
 
    format(szArgs, 191, "^x04[^x03%s^x04] ^x03%s^x01 :  %s",  Prefix[Level[id]], szName, szArgs)

    for(new i = 1; i <= gMaxPlayers; i++)
    {
        if(!is_user_connected(i))
            continue
    
        if(alive && is_user_alive(i))
        {
            message_begin(MSG_ONE, gMsgSayText, {0, 0, 0}, i)
            write_byte(id)
            write_string(szArgs)
            message_end()
        } 
        else if(!alive && !is_user_alive(i)) 
        {
            new format[192]
            formatex(format,191,"^x01* DEAD %s",szArgs)
            message_begin(MSG_ONE, gMsgSayText, {0, 0, 0}, i)
            write_byte(id)
            write_string(format)
            message_end()
        }
    }
        
    return PLUGIN_HANDLED_MAIN
}

public SaveData(id)
{
    new name[32];
    get_user_name(id,name,31);
    new vaultkey[64],vaultdata[256];
    
    format(vaultkey,63,"%s", name);
    format(vaultdata,255,"%i#%i#",eXP[id],Level[id]);
    fvault_set_data(g_vault_name,vaultkey,vaultdata);
    
    return PLUGIN_CONTINUE;
}
public LoadData(id)
{
    new name[32];
    get_user_name(id,name,31);
    new vaultkey[64],vaultdata[256];
    
    format(vaultkey,63,"%s",name);
    format(vaultdata,255,"%i#%i#",eXP[id],Level[id]);
    fvault_get_data(g_vault_name,vaultkey,vaultdata,charsmax(vaultdata));
    
    replace_all(vaultdata, 255, "#", " ");
    new playerxp[32], playerlevel[32];
    parse(vaultdata, playerxp, 31, playerlevel, 31);
    
    eXP[id] = str_to_num(playerxp);
    Level[id] = str_to_num(playerlevel);
    
    return PLUGIN_CONTINUE;
} 
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1251\\ deff0\\ deflang1026{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/


Code:
Error: Multi-dimensional arrays must be fully initialized on line <>
1 Error.
If someone has the solution for this i'll be really thankfull

Last edited by rago12; 07-25-2016 at 05:03. Reason: UPDATE: Added the full code
rago12 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-24-2016 , 17:46   Re: Plugin compile error
Reply With Quote #2

Show full code error doesnt seem to Be there.
siriusmd99 is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 07-24-2016 , 18:50   Re: Plugin compile error
Reply With Quote #3

Quote:
Originally Posted by rago12 View Post
Code:
new const Prefix[MaxLevels +1][] =
-->
Code:
new const Prefix[][] =
It should do the trick. If not, to attach the full code.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
rago12
Junior Member
Join Date: Jul 2016
Old 07-25-2016 , 05:05   Re: Plugin compile error
Reply With Quote #4

@addons zz

I've tryed that, the compile is working but the whole plugin didn't..





Also i added the full code
rago12 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-25-2016 , 06:49   Re: Plugin compile error
Reply With Quote #5

remove + 1 after maxlevels
siriusmd99 is offline
rago12
Junior Member
Join Date: Jul 2016
Old 07-25-2016 , 08:56   Re: Plugin compile error
Reply With Quote #6

The plugin doesn't work when i remove the [+1]


i get <Bad load> from it in amx_plugins
rago12 is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 07-25-2016 , 09:59   Re: Plugin compile error
Reply With Quote #7

Quote:
Originally Posted by rago12 View Post
The plugin doesn't work when i remove the [+1]


i get <Bad load> from it in amx_plugins
Code:
[AMXX] Plugin "new.amxx" failed to load: Module/Library "chatcolor" required for plugin.  Check modules.ini.
Install this thing.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 07-25-2016 , 11:38   Re: Plugin compile error
Reply With Quote #8

Looking at your plugin and creating a logic for myself, you using Non-steam because you save per Name when you can Save per steam and avoid a LOT OF BUGS wich now you don't know them.
Craxor is offline
Send a message via ICQ to Craxor
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 04:43.


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