Bom estou com os seguintes erros no meu código
no caso as duas linhas estão situadas nessa parte do código :
só que não consegui identificar o por quê de estar ocorrendo esse erro, pois esse erro só ocorre quando ultrapassa algum valor definido de alguma variavel ou algo do tipoAgradeço quem puder me ajudar a resolver este erro no código e também se possível fazer um tutorial ou ensinar como que faz pra se evitar este erro presente no código acima!Agradeço desde já!
Última edição por Slayer. em 3/2/2014, 5:48 pm, editado 2 vez(es)
Código:
L 02/03/2014 - 15:20:56: [AMXX] Displaying debug trace (plugin "rank.amxx")
L 02/03/2014 - 15:20:56: [AMXX] Run time error 4: index out of bounds
L 02/03/2014 - 15:20:56: [AMXX] [0] exp_mod.sma::ShowHud (line 217)
L 02/03/2014 - 15:24:58: [AMXX] Displaying debug trace (plugin "rank.amxx")
L 02/03/2014 - 15:24:58: [AMXX] Run time error 4: index out of bounds
L 02/03/2014 - 15:24:58: [AMXX] [0] rank.sma::ShowHud (line 225)
no caso as duas linhas estão situadas nessa parte do código :
Spoiler :
Código:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Artilhery of Briggs MOD"
#define VERSION "1.0"
#define AUTHOR "Slayer."
#define XP_BASE 100 // We define our base variables here, means with which |factor gets price / health increased| /
#define XP_MULTI 3.75 // |base value we start|
#define MAXLEVEL 16 // Setting the MAX Level the player can reach
#define MAXKS 10
#define TASK_SHOWHUD 100
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
const Float:HUD_STATS_X = 0.02;
const Float:HUD_STATS_Y = 0.8825;
const Float:HUD_SPECT_X = -1.0;
const Float:HUD_SPECT_Y = 0.8;
const PEV_SPEC_TARGET = pev_iuser2
new g_MsgSync
new g_vault;
new g_level[33], g_xp[33], XP2Calc[33]
new const Specs[][] =
{
"Recruta",
"Soldado",
"Soldado P. Classe",
"Cabo",
"S. Major",
"Subtenente",
"S.Tenente",
"P.Tenente",
"Capitao",
"Major",
"T.Coronel",
"G. de Brigada",
"G. Major",
"T. General",
"General",
"Fuhrer"
}
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event( "DeathMsg", "Event_DeathMsg", "a" );
RegisterHam(Ham_TakeDamage, "player", "fw_takedamage");
g_vault = nvault_open("Mod");
}
public plugin_precache()
{
g_MsgSync = CreateHudSyncObj();
}
public plugin_natives()
{
register_library("artilherymod")
register_native("ab_exp_get", "native_exp_get")
register_native("ab_exp_set", "native_exp_set")
register_native("ab_level_get", "native_level_get")
register_native("ab_level_set", "native_level_set")
}
public native_exp_get(plugin_id, num_params)
{
new id = get_param(1)
return g_xp[id];
}
public native_exp_set(plugin_id, num_params)
{
new id = get_param(1)
new amount = get_param(2)
g_xp[id] = amount
return true;
}
public native_level_get(plugin_id, num_params)
{
new id = get_param(1)
return g_level[id];
}
public native_level_set(plugin_id, num_params)
{
new id = get_param(1)
new amount = get_param(2)
g_level[id] = amount
return true;
}
public client_putinserver(id){
LoadXP(id)
Recalc(id)
if(!is_user_bot(id))
{
set_task(1.0, "ShowHud", id+TASK_SHOWHUD, _, _, "b")
}
}
public client_disconnect(id){
SaveXP(id)
remove_task(id+TASK_SHOWHUD)
}
public plugin_end()
{
nvault_close( g_vault );
}
public fw_takedamage(victim, inflictor, attacker, Float:damage, dmgtype)
{
if(!is_user_connected(attacker) || !is_user_alive(attacker) || !is_user_connected(victim) || !is_user_alive(victim) )
return
if(g_level[attacker] >= 3 && get_user_weapon(attacker) == CSW_KNIFE && is_user_connected(victim))
{
SetHamParamFloat(4, damage*2.0)
}
if(g_level[attacker] >= 2 && get_user_weapon(attacker) == CSW_MP5NAVY && is_user_connected(victim))
{
SetHamParamFloat(4, damage*2.0)
}
}
public Event_DeathMsg()
{
new attacker = read_data( 1 );
new victim = read_data( 2 );
new headshot = read_data( 3 );
new clip, ammo, weapon = get_user_weapon(attacker,clip,ammo);
if( !is_user_connected( victim ) )
return;
if( attacker == victim || !attacker )
return;
g_xp[attacker] += 10
if(headshot)
g_xp[attacker] += 15
if(weapon == CSW_KNIFE)
g_xp[attacker] += 20
if(weapon == CSW_HEGRENADE)
g_xp[attacker] +=30
if(g_xp[attacker] >= XP2Calc[attacker] && g_level[attacker] < MAXLEVEL)
{
g_level[attacker] ++
g_xp[attacker] -= XP2Calc[attacker]
Recalc(attacker)
}
}
public ShowHud(taskid)
{
new iPlayer = ID_SHOWHUD;
if (!is_user_alive( iPlayer ) )
{
iPlayer = pev(iPlayer, PEV_SPEC_TARGET)
// Target not alive
if (!is_user_alive(iPlayer) )
return;
}
if (iPlayer == ID_SHOWHUD)
{
set_hudmessage( 110, 255, 110, HUD_STATS_X, HUD_STATS_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
//linha 217
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level %i | Exp: %i / %i |Patente : %s", g_level[ ID_SHOWHUD ] , g_xp[ ID_SHOWHUD ] , XP2Calc[ ID_SHOWHUD ], Specs[g_level[ ID_SHOWHUD ]]);
}
else
{
static player_name[33]
get_user_name(iPlayer, player_name, charsmax(player_name))
set_hudmessage( 100, 100, 100, HUD_SPECT_X, HUD_SPECT_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
//linha 225
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Spectando: %s ^nHP: %i | Level: %i | Exp : %i / %i | Patente : %s", player_name[ iPlayer ] , get_user_health(iPlayer), g_level[ iPlayer ] , g_xp[ iPlayer ] , XP2Calc[ iPlayer ], Specs[g_level[ iPlayer ]]);
}
}
public SaveXP(id)
{
if (!is_user_connected(id) || is_user_hltv(id))
return;
new Name[32];
get_user_name(id, Name, 32);
new vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s",Name);
format(vaultdata,255," ^"%i^" ^"%i^"",g_level[id],g_xp[id]);
nvault_set(g_vault,vaultkey,vaultdata);
}
public LoadXP(id)
{
if (!is_user_connected(id) || is_user_hltv(id))
return;
new Name[32];
get_user_name(id, Name, 32);
new vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s",Name);
format(vaultdata,255," ^"%i^" ^"%i^"",g_level[id],g_xp[id]);
nvault_get(g_vault, vaultkey, vaultdata, 255);
new pxp[32], plevel[32] ;
parse(vaultdata, pxp, sizeof(pxp) - 1, plevel, sizeof(plevel) - 1);
g_xp[id] = str_to_num(pxp);
g_level[id] = str_to_num(plevel)
}
stock Recalc(id)
{
XP2Calc[id] = floatround(XP_BASE * XP_MULTI * g_level[id]) // With the vars. defined in the top the Calc would be : 100 * 3.75 * Player Level
// We have to use floatround because we are using numbers like 0.6, 0.4 etc.
}
Última edição por Slayer. em 3/2/2014, 5:48 pm, editado 2 vez(es)