Crux Ansata

ev_sa

Пользователь
Лучшие ответы
8
Реакции
26
Ошибка такого рода. Что-то в 50 строке не так. Может помочь исправить кто-то? @SKAJIbnEJIb?

Код:
L 12/19/2020 - 05:00:49: Info (map "de_dust2_2x2") (file "addons/amxmodx/logs/error_20201219.log")
L 12/19/2020 - 05:00:49: [AMXX] Displaying debug trace (plugin "crux_ansata.amxx", version "1.0")
L 12/19/2020 - 05:00:49: [AMXX] Run time error 4: index out of bounds
L 12/19/2020 - 05:00:49: [AMXX]    [0] crux_ansata.sma::eRoundStart (line 50)
#include <amxmodx>
#include <engine>

#define MIN_PLAYERS 0
#define ROUND_ACCESS 4
#define GIVE_HEALTH 7
#define INTERVAL_REGENERATION 1.0

new const g_szModel[] = "models/crux_ansata.mdl";

new g_iPlayerId, g_iRoundCounter, szName[32];

public plugin_init()
{
register_plugin("Crux Ansata", "1.0", "DUKKHAZ0R");

register_touch("crux_ansata", "player", "fw_TouchEntity");

register_logevent("eRoundStart", 2, "1=Round_Start");
register_event("DeathMsg", "eDeathMsg", "a", "1>0");
register_event("TextMsg", "eRoundRestart", "a", "2&#Game_C", "2&#Game_w");

set_task(INTERVAL_REGENERATION, "RegenerationHealth", .flags="b");
}

public plugin_precache()
{
precache_model(g_szModel);
}

public client_disconnect(id)
if(g_iPlayerId == id) g_iPlayerId = 0;

public eRoundRestart()
g_iRoundCounter = 0;

public eRoundStart()
{
if(++g_iRoundCounter < ROUND_ACCESS || get_playersnum() < MIN_PLAYERS)
return;

static iEnt;

while((iEnt = find_ent_by_class(iEnt, "crux_ansata")))
remove_entity(iEnt);

static apPlayers[32], iPlayers;
get_players(apPlayers, iPlayers, "ach");

g_iPlayerId = apPlayers[random(iPlayers-1)];
get_user_name(g_iPlayerId, szName, charsmax(szName));

ChatColor(0, "^4[CA] Игроку ^3%s ^1выпал талисман жизни!", szName);
}

public eDeathMsg()
{
static pVictim, Float:flOrigin[3]; pVictim = read_data(2);

if(pVictim == g_iPlayerId)
{
new iEnt = create_entity("info_target");

if(!is_valid_ent(iEnt))
return;

entity_get_vector(pVictim, EV_VEC_origin, flOrigin);
entity_set_vector(iEnt, EV_VEC_origin, flOrigin);
entity_set_string(iEnt, EV_SZ_classname, "crux_ansata");
entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER);
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_NONE);
entity_set_int(iEnt, EV_INT_effects, 8);
entity_set_model(iEnt, g_szModel);
entity_set_size(iEnt, Float:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});
ChatColor(g_iPlayerId = 0, "^4[CA] Игрок ^3%s ^1потерял талисман жизни!", szName);
}
}

public fw_TouchEntity(iEnt, id)
{
if(!is_valid_ent(iEnt))
return;

get_user_name(g_iPlayerId = id, szName, charsmax(szName));
ChatColor(0,"^4[CA] Игрок ^3%s ^1поднял талисман жизни!",szName);

entity_set_int(iEnt, EV_INT_flags, FL_KILLME);
}

public RegenerationHealth()
{
if(!g_iPlayerId || get_playersnum() < MIN_PLAYERS)
return;

static Float:fHealth, MsgId_Health; fHealth = entity_get_float(g_iPlayerId, EV_FL_health);

if(!MsgId_Health) MsgId_Health = get_user_msgid("Health");

if(fHealth < 100 && is_user_alive(g_iPlayerId))
{
static Float:giveHealth; giveHealth = (fHealth + GIVE_HEALTH) < 100 ? float(GIVE_HEALTH) : (100 - fHealth);

entity_set_float(g_iPlayerId, EV_FL_health, fHealth + giveHealth);

message_begin(MSG_ONE_UNRELIABLE, MsgId_Health, _, g_iPlayerId);
write_byte(floatround(fHealth + giveHealth));
message_end();
}
}

stock ChatColor(const id, const szMessage[], any:...)
{
static szBuffer[191], apPlayers[32], iPlayers; iPlayers = 1;
vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
if(id)
{
if(!is_user_connected(id)) return;
apPlayers[0] = id;
iPlayers = 1;
}
else get_players(apPlayers, iPlayers, "ch");
for(new i;i < iPlayers; i++)
{
message_begin(MSG_ONE_UNRELIABLE, 76, .player = apPlayers);
write_byte(apPlayers);
write_string(szBuffer);
message_end();
}
}
 

ev_sa

Пользователь
Лучшие ответы
8
Реакции
26
@present, Можешь помочь подправить? Не получается. Ошибки при компиляции выходят.
 

present

Пользователь
Лучшие ответы
22
Реакции
39
@ev_sa, возьми с поста готовый, у тебя там что то вырезано да не верно, я не хочу туда лезть и проверять.
Код:
#include <amxmodx>
#include <engine>

#define SCREENFADE                    //Затемнять экран при регенерации здоровья
#define MIN_PLAYERS 1                //Минимальное кол-во игроков для работы плагина
#define ROUND_ACCESS 3                //С какого раунда доступен талисман
#define GIVE_HEALTH 5                //Кол-во выдаваемого здоровья
#define INTERVAL_REGENERATION 2.0    //Интервал между восстановлением

new const g_szModel[] = "models/crux_ansata.mdl";

new g_iPlayerId, g_iRoundCounter, szName[32];

#if defined SCREENFADE
new g_MsgScreenFade;
new Float:g_fTimeGlare[33];
#endif

public plugin_init()
{
    register_plugin("Crux Ansata", "1.0", "DUKKHAZ0R");
  
    register_touch("crux_ansata", "player", "fw_TouchEntity");
  
    register_logevent("eRoundStart", 2, "1=Round_Start");
    register_event("DeathMsg", "eDeathMsg", "a", "1>0");
    register_event("TextMsg", "eRoundRestart", "a", "2&#Game_C", "2&#Game_w");
  
    #if defined SCREENFADE
    register_event("ScreenFade", "EventScreenFade", "b", "4=255", "5=255", "6=255");
    g_MsgScreenFade = get_user_msgid("ScreenFade");
    #endif

    set_task(INTERVAL_REGENERATION, "RegenerationHealth", .flags="b");
}

#if defined SCREENFADE
public EventScreenFade(id)
    g_fTimeGlare[id] = read_data(1) / 4096.0 + get_gametime();
#endif

public plugin_precache()
{
    precache_model(g_szModel);
}

public client_disconnected(id)
{
    if(g_iPlayerId == id)
        SpawnAnsata(id);
}

public eRoundRestart()
    g_iRoundCounter = 0;

public eRoundStart()
{
    if(++g_iRoundCounter < ROUND_ACCESS || get_playersnum() < MIN_PLAYERS)
        return;
      
    static iEnt;
  
    while((iEnt = find_ent_by_class(iEnt, "crux_ansata")))
        remove_entity(iEnt);
      
    static apPlayers[32], iPlayers;
    get_players(apPlayers, iPlayers, "ach");
  
    if(!iPlayers) return;
    g_iPlayerId = apPlayers[random_num(0, iPlayers-1)];
    get_user_name(g_iPlayerId, szName, charsmax(szName));
  
    ChatColor(0, "^4[CA] ^3%s ^1выпал талисман жизни.", szName);
}

public eDeathMsg()
{
    if(read_data(2) == g_iPlayerId)
        SpawnAnsata(g_iPlayerId);
}

public fw_TouchEntity(iEnt, id)
{
    if(!is_valid_ent(iEnt) || g_iPlayerId)
        return 1;
      
    entity_set_int(iEnt, EV_INT_flags, FL_KILLME);
    get_user_name(g_iPlayerId = id, szName, charsmax(szName));
    ChatColor(0,"^4[CA] ^3%s ^1поднял талисман жизни.",szName);
    return 1;
}

public RegenerationHealth()
{
    if(!g_iPlayerId || get_playersnum() < MIN_PLAYERS)
        return;
  
    static Float:fHealth, MsgId_Health; fHealth = entity_get_float(g_iPlayerId, EV_FL_health);
  
    if(!MsgId_Health) MsgId_Health = get_user_msgid("Health");
  
    if(fHealth < 100 && is_user_alive(g_iPlayerId))
    {
        static Float:giveHealth; giveHealth = (fHealth + GIVE_HEALTH) < 100 ? float(GIVE_HEALTH) : (100 - fHealth);
      
        entity_set_float(g_iPlayerId, EV_FL_health, fHealth + giveHealth);
      
        message_begin(MSG_ONE_UNRELIABLE, MsgId_Health, _, g_iPlayerId);
        write_byte(floatround(fHealth + giveHealth));
        message_end();

        #if defined SCREENFADE
        if (get_gametime() >= g_fTimeGlare[g_iPlayerId])
        {
            message_begin(MSG_ONE_UNRELIABLE, g_MsgScreenFade, _, g_iPlayerId)
            write_short(1<<10); write_short(1<<10); write_short(0x0000); write_byte(0);
            write_byte(255); write_byte(0); write_byte(40); message_end();
        }
        #endif
    }
}

stock SpawnAnsata(id)
{
    static Float:fOrigin[3];
    entity_get_vector(id, EV_VEC_origin, fOrigin);
  
    new iEnt = create_entity("info_target");
  
    if(!is_valid_ent(iEnt))
        return;
  
    entity_set_vector(iEnt, EV_VEC_origin, fOrigin);
    entity_set_string(iEnt, EV_SZ_classname, "crux_ansata");
    entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER);
    entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_NONE);
    entity_set_int(iEnt, EV_INT_effects, 8);
    entity_set_model(iEnt, g_szModel);
    entity_set_size(iEnt, Float:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});
    ChatColor(g_iPlayerId = 0, "^4[CA] ^3%s ^1потерял талисман жизни.", szName);
}

stock ChatColor(const id, const szMessage[], any:...)
{
    static szBuffer[191], apPlayers[32], iPlayers; iPlayers = 1;
    vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
    if(id)
    {
        if(!is_user_connected(id)) return;
        apPlayers[0] = id;
        iPlayers = 1;
    }
    else get_players(apPlayers, iPlayers, "ch");
    for(new i;i < iPlayers; i++)
    {
        message_begin(MSG_ONE_UNRELIABLE, 76, .player = apPlayers[i]);
        write_byte(apPlayers[i]);
        write_string(szBuffer);
        message_end();
    }
}
я так понимаю SCREENFADE у тебя вырезан?
Это делается проще, #define SCREENFADE надо просто закоментировать
Код:
// #define SCREENFADE
 
Последнее редактирование:
Сверху