Weapon icon

Сообщения
21
Реакции
1
Ошибка
[ReAPI] get_member_s: invalid or uninitialized entity
[AMXX] Run time error 10 (plugin "wi_new.amxx") (native "get_member_s") - debug not enabled!
[AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
Даже попробовал написал возле плагина debug все ровно это вконсоле вылазит ?
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5294 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Dec 3 2021 15:54:56
Built from: https://github.com/alliedmodders/amxmodx/commit/363871a
Build ID: 5294:363871a
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.12.0.780-dev
Build date: 18:40:12 Oct 05 2022 (3098)
Build from: https://github.com/dreamstalker/rehlds/commit/d6ebe82
ReGamedll
ReGameDLL version: 5.21.0.577-dev
Build date: 19:56:51 Dec 21 2022
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/9dc5470
Версия Metamod
Metamod-r v1.3.0.131, API (5:13)
Metamod-r build: 18:51:02 Jul 11 2022
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/adc9414
Список метамодулей
SafeNameAndChat  RUN   -    SafeNameAndChat.  v1.2 Bet  ini   ANY   ANY  
[ 2] Reunion RUN - reunion_mm_i386. v0.1.92d ini Start Never
[ 3] VoiceTranscoder RUN - vtc.so v2017RC5 ini ANY ANY
[ 4] ReAuthCheck RUN - reauthcheck_mm_i v0.1.6 ini Start Never
[ 5] Rechecker RUN - rechecker_mm_i38 v2.7 ini Chlvl ANY
[ 6] WHBlocker RUN - whblocker.so v1.5.697 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip.so v2.3.9 ini Chlvl ANY
[ 8] AMX Mod X RUN - amxmodx_mm_i386. v1.9.0.5 ini Start ANY
[ 9] HitBox Fix RUN - hitbox_fix.so v1.1.2 ini Start ANY
[10] MySQL RUN - mysql_amxx_i386. v1.9.0.5 pl8 ANY ANY
[11] ReAimDetector RUN - reaimdetector_am v0.2.2 pl8 ANY Never
[12] ReAPI RUN - reapi_amxx_i386. v5.22.0. pl8 ANY Never
[13] GeoIP RUN - geoip_amxx_i386. v1.9.0.5 pl8 ANY ANY
[14] FakeMeta RUN - fakemeta_amxx_i3 v1.9.0.5 pl8 ANY ANY
[15] Ham Sandwich RUN - hamsandwich_amxx v1.9.0.5 pl8 ANY ANY
[16] Engine RUN - engine_amxx_i386 v1.9.0.5 pl8 ANY ANY
[17] CStrike RUN - cstrike_amxx_i38 v1.9.0.5 pl8 ANY ANY
[18] CSX RUN - csx_amxx_i386.so v1.9.0.5 pl8 ANY ANY
[19] SQLite RUN - sqlite_amxx_i386 v1.9.0.5 pl8 ANY ANY
[20] SxGeo RUN - sxgeo_amxx_i386. v2.2 pl8 ANY Never
20 plugins, 20 running
Список плагинов
amxx plugins
Currently loaded plugins:
name version author file status
[ 1] ScreenMaker 1.1 neygomon screen_maker.am running
[ 2] DopBan 3.0.8b kanagava dop_ban.amxx running
[ 3] Admin Loader 3.5 neygomon admin_loader.am running
[ 4] FreshBans 1.4.7b kanagava fresh_bans.amxx running
[ 5] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 6] Aliases checker 1.0.6 kanagava alias_detector. running
[ 7] Advanced Ultimate Weap 0.1.0b steelzzz advanced_ultima running
[ 8] [190] VIP RBS 20.07.20 SKAJIbnEJIb vip_rbs.amxx running
[ 9] unknown unknown unknown ultimate_weapon running
[ 10] [ReAPI] Custom Models 1.6.1 neugomon & fix custom_models_s debug
[ 11] Skins Key 1.0 6u3on skins_key.amxx debug
[ 12] [REAPI] Weapons Key 1.0 Update weapons_key.amx debug
[ 13] Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running
[ 14] Server AMXMODMENU [INI 1.1 unnamed amxmodmenu.amxx running
[ 15] Players Menu 1.7 neugomon players_menu.am running
[ 16] Items Restrict 1.0 ReHLDS Team items_restrict. running
[ 17] Auto Team Balancer 0.1 unnamed auto_balancer.a running
[ 18] Server Menu [INI] 1.1 unnamed server_menu.amx running
[ 19] AFK Control ReNew 1.2(a) neygomon afk_control.amx running
[ 20] Ping 0.1 unnamed ping_kicker.amx running
[ 21] Advanced Kill Assists 1.3c Xelson next21_kill_ass running
[ 22] [ReAPI] No Team Flash 0.0.3 Vaqtincha no_team_flash.a running
[ 23] Auto Demo 0.1 unnamed auto_demo.amxx running
[ 24] ResetScore 1.1 Leo_[BH] resetscore_reap running
[ 25] Parachute Lite [ReAPI] 11.0 Leo_[BH] parachute_lite. running
[ 26] C4 Timer 0.1 unnamed c4_timer.amxx running
[ 27] Advert Messages 1.23 unnamed adverts.amxx running
[ 28] [AMXX] Show Hud Messag 1.0.0 ImmortalAmxx amxx_hud.amxx running
[ 29] [ReAPI] Damager 1.1 mx?! damager.amxx running
[ 30] [190] Ultimate Flags 22.11.15 SKAJIbnEJIb ultimate_flags. running
[ 31] Top Awards 1.2.0 szawesome top_awards.amxx running
[ 32] [REAPI] Stimulation 1.0b Update stimulation.amx running
[ 33] Lite Admin ESP 1.0 neygomon lite_admin_esp. running
[ 34] [ReAPI] Healthnade 0.0.9f DEV-CS.RU Commun reapi_healthnad running
[ 35] Custom Smoke 1.2.1 (non medusa custom_smoke_no running
[ 36] Revive/Mined Die Playe 2.5.3 Emma Jule revive_teammate running
[ 37] Block Manager 1.1 maFFyoZZyk block_manager.a running
[ 38] Time for info 1.1 neugomon time_for_info.a running
[ 39] recoil_manager 0.1 fl0wer & Metodic recoil_manager. running
[ 40] GameName Changer 1.0 mx?! GameName.amxx running
[ 41] Injection Med-Kit 2.0.0 Emma Jule injection1.amxx running
[ 42] Mode 2x2 2.5re s1lent mode.amxx running
[ 43] AR: Vampire 1.0.0 Emma Jule ar_vampire.amxx running
[ 44] AWP Limiter 1.3.0 Beta Nordic Warrior awp_limiter.amx running
[ 45] AWPL: Disabled maps 1.0.0 Nordic Warrior awp_limiter_dis running
[ 46] [190] SlayLosers RBS 20.06.06 SKAJIbnEJIb & d3 slaylosers_rbs. running
[ 47] Connect Counter 1.0 mx?! connect_counter running
[ 48] Re: Weapon Icon 1.0 maFFyoZZyk wi_new.amxx debug
[ 49] Frags Counter 1.0 CHEL74 frags_counter.a running
[ 50] [SxGeo] Connect Info 1.0 s1lent sxgeo_connect_i running
[ 51] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 52] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike running
[ 53] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am running
[ 54] AES: Admin Tools 0.5.9 [REA serfreeman1337/s aes_exp_editor. running
[ 55] AES: Bonus System 0.5.9 Vega serfreeman1337/s aes_bonus_syste running
[ 56] AES: Bonus CSTRIKE 0.5.9.1 [R serfreeman1337/s aes_bonus_cstri running
[ 57] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am running
[ 58] AES: StatsX 0.5+1 serfreeman1337 aes_statsx_cstr running
[ 59] Stats Configuration 1.9.0.5294 AMXX Dev Team statscfg.amxx running
[ 60] Say me and Say hp 1.4 neygomon sayme_reapi.amx running
[ 61] Map Manager: Core 3.1.5 Mistrick map_manager_cor running
[ 62] Map Manager: Scheduler 0.1.10 Mistrick map_manager_sch running
[ 63] Admin Mapmenu 0.5.3 d3m37r4 admin_mapmenu.a running
[ 64] Map Manager: Rtv 0.1.1 Mistrick map_manager_rtv running
[ 65] Map Manager: Nominatio 0.2.1 Mistrick map_manager_nom running
[ 66] Map Manager: BlockList 0.0.4 Mistrick map_manager_blo running
[ 67] Map Manager: Online so 0.0.4 Mistrick map_manager_onl running
[ 68] Map Manager: Effects 0.1.1 Mistrick map_manager_eff running
[ 69] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
[ 70] Map Manager: Sounds 0.0.2 Mistrick map_manager_sou running
[ 71] [Fork] Lite NightMode 1.1 neygomon & NoNaM lite_nightmode. running
[ 72] ChatAdditions: Core %CA_VERSIO Sergey Shorokhov ChatAdditions_C debug
[ 73] ChatAdditions: SQLite %CA_VERSIO Sergey Shorokhov CA_Storage_SQLi debug
[ 74] CA: Mute %CA_VERSIO Sergey Shorokhov CA_Mute.amxx debug
[ 75] CA: Gag %CA_VERSIO Sergey Shorokhov CA_Gag.amxx debug
[ 76] Chat Manager 1.1.2-16 Mistrick chatmanager.amx running
[ 77] Warmup Modular: API 1.2 mx?! wm_api.amxx running
[ 78] Warmup Modular: Timer 1.0 mx?! wm_timer_inform debug
[ 79] Warmup Modular: Kill E 1.0 mx?! wm_kill_effects debug
[ 80] Warmup Modular: Reward 1.3 mx?! wm_rewards.amxx debug
[ 81] Warmup Modular: Random 1.4 mx?! wm_random_spawn debug
[ 82] GameCMS Emulator 1.0 mx?! wm_gamecms_emul debug
[ 83] Warmup Modular: Paintb 1.1 mx?! wm_paintball.am debug
83 plugins, 83 running
Автор плагина
maFFyoZZyk
Версия плагина
1.0
Исходный код
#include <amxmodx>
#include <reapi>

#define parseColors(%1,%2) parse(%1, %2[RED], charsmax(%2[]), %2[GREEN], charsmax(%2[]), %2[BLUE], charsmax(%2[]))

enum any:CVARS
{
WI_MP_SPRITE,
WI_MP_SPRITE_COLOR[32]
};
new g_Cvar[CVARS];

enum _:COLORS
{
RED,
GREEN,
BLUE
};
new g_AllColor[COLORS];
new bool:g_RandomColor;

enum any:
{
STATUS_HIDE, // 0
STATUS_SHOW, // 1
STATUS_FLASH, // 2
}

const TASK_INDEX = 0xA6123;
new Trie:g_tWeapons;
new g_iLastIcon[MAX_PLAYERS+1][MAX_NAME_LENGTH];
new g_iMsgIconLoc;

public plugin_init()
{
register_plugin("Re: Weapon Icon", "1.0", "maFFyoZZyk");

RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Post", .post = true);
RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
RegisterHookChain(RG_CBasePlayerWeapon_DefaultReload, "CBasePlayerWeapon_DefaultReload_Post", .post = true);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", .post = true);
// register_event("AmmoX", "draw_icon", "be")

RegisterCvars();
AutoExecConfig(true, "weapon_icon");
}

public plugin_cfg()
{
switch(g_Cvar[WI_MP_SPRITE])
{
case 2: g_iMsgIconLoc = get_user_msgid("Scenario");
case 1: g_iMsgIconLoc = get_user_msgid("StatusIcon");
case 0: g_iMsgIconLoc = 0;
}

g_tWeapons = TrieCreate();

TrieSetString(g_tWeapons, "weapon_p228", "d_p228");
TrieSetString(g_tWeapons, "weapon_scout", "d_scout");
TrieSetString(g_tWeapons, "weapon_hegrenade", "d_grenade");
TrieSetString(g_tWeapons, "weapon_xm1014", "d_xm1014");
TrieSetString(g_tWeapons, "weapon_mac10", "d_mac10");
TrieSetString(g_tWeapons, "weapon_aug", "d_aug");
TrieSetString(g_tWeapons, "weapon_smokegrenade", "d_grenade");
TrieSetString(g_tWeapons, "weapon_elite", "d_elite");
TrieSetString(g_tWeapons, "weapon_fiveseven", "d_fiveseven");
TrieSetString(g_tWeapons, "weapon_ump45", "d_ump45");
TrieSetString(g_tWeapons, "weapon_sg550", "d_sg550");
TrieSetString(g_tWeapons, "weapon_galil", "d_galil");
TrieSetString(g_tWeapons, "weapon_famas", "d_famas");
TrieSetString(g_tWeapons, "weapon_usp", "d_usp");
TrieSetString(g_tWeapons, "weapon_glock18", "d_glock18");
TrieSetString(g_tWeapons, "weapon_awp", "d_awp");
TrieSetString(g_tWeapons, "weapon_mp5navy", "d_mp5navy");
TrieSetString(g_tWeapons, "weapon_m249", "d_m249");
TrieSetString(g_tWeapons, "weapon_m3", "d_m3");
TrieSetString(g_tWeapons, "weapon_m4a1", "d_m4a1");
TrieSetString(g_tWeapons, "weapon_tmp", "d_tmp");
TrieSetString(g_tWeapons, "weapon_g3sg1", "d_g3sg1");
TrieSetString(g_tWeapons, "weapon_flashbang", "d_grenade");
TrieSetString(g_tWeapons, "weapon_deagle", "d_deagle");
TrieSetString(g_tWeapons, "weapon_sg552", "d_sg552");
TrieSetString(g_tWeapons, "weapon_ak47", "d_ak47");
TrieSetString(g_tWeapons, "weapon_knife", "d_knife");
TrieSetString(g_tWeapons, "weapon_p90", "d_p90");
}

public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
if(!is_user_alive(pPlayer))
return;

new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH];
rg_get_weapon_info(get_member(get_member(pPlayer, m_pActiveItem), m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));
if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
{
set_msg_status_icon(pPlayer, STATUS_HIDE, szIconName[pPlayer]);
g_iLastIcon[pPlayer] = szIconName[pPlayer];
set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);

if(g_Cvar[WI_MP_SPRITE] == 1)
parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
}
}

public CBasePlayerWeapon_DefaultDeploy_Post(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem;
new pPlayer = get_member(pEntity, m_pPlayer);

if(!is_user_alive(pPlayer))
return;

if(ActiveItem == NULLENT)
return;

ActiveItem = get_member(pPlayer, m_pActiveItem);
rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
{
set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
g_iLastIcon[pPlayer] = szIconName[pPlayer];
set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);

if(g_Cvar[WI_MP_SPRITE] == 1)
parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
}
}

public CBasePlayerWeapon_DefaultReload_Post(const this, iClipSize, iAnim, Float:fDelay)
{
new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, pPlayer;

pPlayer = get_member(this, m_pPlayer);

if(!is_user_alive(pPlayer))
return;

if(ActiveItem == NULLENT)
return;

ActiveItem = get_member(pPlayer, m_pActiveItem);
rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
{
set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
g_iLastIcon[pPlayer] = szIconName[pPlayer];
set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);

if(g_Cvar[WI_MP_SPRITE] == 1)
parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
}
}

public CBasePlayer_Killed_Post(pVictim, pAttacker, pGib)
{
if(!is_user_connected(pVictim) || !is_user_connected(pAttacker))
return HC_CONTINUE;

new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem;

if(ActiveItem == NULLENT)
return HC_CONTINUE;

ActiveItem = get_member(pVictim, m_pActiveItem);

rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pVictim], charsmax(szIconName)))
set_msg_status_icon(pVictim, STATUS_HIDE, szIconName[pVictim]);

return HC_CONTINUE;
}

stock parseColorValue(const value[])
{
new color[COLORS][4];
if(value[0] == EOS || parseColors(value, color) < 3)
{
g_RandomColor = true;
}
else
{
g_RandomColor = false;
for(new i; i < sizeof g_AllColor; i++)
g_AllColor[i] = str_to_num(color[i]);
}
}

stock set_msg_status_icon(pPlayer, iStatus, const sSprite[])
{
message_begin(MSG_ONE, g_iMsgIconLoc, .player = pPlayer);
write_byte(iStatus);
write_string(sSprite);

if(iStatus != STATUS_HIDE)
{
if(g_RandomColor)
{
write_byte(random(255));
write_byte(random(255));
write_byte(random(255));
}
else
{
write_byte(g_AllColor[RED]);
write_byte(g_AllColor[GREEN]);
write_byte(g_AllColor[BLUE]);
}
}

message_end();
}

RegisterCvars()
{
bind_pcvar_num(
create_cvar(
.name = "wi_mp_sprite",
.string = "1",
.flags = FCVAR_SERVER,
.description = "Где будет отображена иконка ^n 0 - выключить. ^n 1 - Там где корзина. ^n 2 - Там где часы",
.has_min = true,
.min_val = 0.0
), g_Cvar[WI_MP_SPRITE]
);
bind_pcvar_string(
create_cvar(
.name = "wi_mp_sprite_color",
.string = "255 063 000",
.flags = FCVAR_SERVER,
.description = fmt("Цвет иконки оружия [rrrgggbbb], если она находится там, где корзина. ^n Оставьте поле пустым, если хотите рандомный цвет ^n 000128000 - 000 красный; 128 зеленый; 000 синий")
), g_Cvar[WI_MP_SPRITE_COLOR], charsmax(g_Cvar[WI_MP_SPRITE_COLOR])
);
}
Код:
#include <amxmodx>
#include <reapi>

#define parseColors(%1,%2) parse(%1, %2[RED], charsmax(%2[]), %2[GREEN], charsmax(%2[]), %2[BLUE], charsmax(%2[]))

enum any:CVARS
{
    WI_MP_SPRITE,
    WI_MP_SPRITE_COLOR[32]
};
new g_Cvar[CVARS];

enum _:COLORS
{
    RED,
    GREEN,
    BLUE
};
new g_AllColor[COLORS];
new bool:g_RandomColor;

enum any:
{
    STATUS_HIDE, // 0
    STATUS_SHOW, // 1
    STATUS_FLASH, // 2
}

const TASK_INDEX = 0xA6123;
new Trie:g_tWeapons;
new g_iLastIcon[MAX_PLAYERS+1][MAX_NAME_LENGTH];
new g_iMsgIconLoc;

public plugin_init()
{
    register_plugin("Re: Weapon Icon", "1.0", "maFFyoZZyk");

    RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Post", .post = true);
    RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
    RegisterHookChain(RG_CBasePlayerWeapon_DefaultReload, "CBasePlayerWeapon_DefaultReload_Post", .post = true);
    RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", .post = true);   
    // register_event("AmmoX", "draw_icon", "be")

    RegisterCvars();
    AutoExecConfig(true, "weapon_icon");   
}

public plugin_cfg()
{
    switch(g_Cvar[WI_MP_SPRITE])
    {
        case 2:    g_iMsgIconLoc = get_user_msgid("Scenario");
        case 1:    g_iMsgIconLoc = get_user_msgid("StatusIcon");
        case 0:    g_iMsgIconLoc = 0;
    }

    g_tWeapons = TrieCreate();

    TrieSetString(g_tWeapons, "weapon_p228",            "d_p228");
    TrieSetString(g_tWeapons, "weapon_scout",            "d_scout");
    TrieSetString(g_tWeapons, "weapon_hegrenade",        "d_grenade");
    TrieSetString(g_tWeapons, "weapon_xm1014",            "d_xm1014");
    TrieSetString(g_tWeapons, "weapon_mac10",            "d_mac10");
    TrieSetString(g_tWeapons, "weapon_aug",                "d_aug");
    TrieSetString(g_tWeapons, "weapon_smokegrenade",    "d_grenade");
    TrieSetString(g_tWeapons, "weapon_elite",            "d_elite");
    TrieSetString(g_tWeapons, "weapon_fiveseven",        "d_fiveseven");
    TrieSetString(g_tWeapons, "weapon_ump45",            "d_ump45");
    TrieSetString(g_tWeapons, "weapon_sg550",            "d_sg550");
    TrieSetString(g_tWeapons, "weapon_galil",            "d_galil");
    TrieSetString(g_tWeapons, "weapon_famas",            "d_famas");
    TrieSetString(g_tWeapons, "weapon_usp",                "d_usp");
    TrieSetString(g_tWeapons, "weapon_glock18",            "d_glock18");
    TrieSetString(g_tWeapons, "weapon_awp",                "d_awp");
    TrieSetString(g_tWeapons, "weapon_mp5navy",            "d_mp5navy");
    TrieSetString(g_tWeapons, "weapon_m249",            "d_m249");
    TrieSetString(g_tWeapons, "weapon_m3",                "d_m3");
    TrieSetString(g_tWeapons, "weapon_m4a1",            "d_m4a1");
    TrieSetString(g_tWeapons, "weapon_tmp",                "d_tmp");
    TrieSetString(g_tWeapons, "weapon_g3sg1",            "d_g3sg1");
    TrieSetString(g_tWeapons, "weapon_flashbang",        "d_grenade");
    TrieSetString(g_tWeapons, "weapon_deagle",            "d_deagle");
    TrieSetString(g_tWeapons, "weapon_sg552",            "d_sg552");
    TrieSetString(g_tWeapons, "weapon_ak47",            "d_ak47");
    TrieSetString(g_tWeapons, "weapon_knife",            "d_knife");
    TrieSetString(g_tWeapons, "weapon_p90",                "d_p90");
}

public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
    if(!is_user_alive(pPlayer))
        return;

    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH];
    rg_get_weapon_info(get_member(get_member(pPlayer, m_pActiveItem), m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));
    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, szIconName[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayerWeapon_DefaultDeploy_Post(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem;
    new pPlayer = get_member(pEntity, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    if(ActiveItem == NULLENT)
        return;   

    ActiveItem = get_member(pPlayer, m_pActiveItem);
    rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayerWeapon_DefaultReload_Post(const this, iClipSize, iAnim, Float:fDelay)
{
    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, pPlayer;

    pPlayer = get_member(this, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    if(ActiveItem == NULLENT)
        return;   

    ActiveItem = get_member(pPlayer, m_pActiveItem);
    rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayer_Killed_Post(pVictim, pAttacker, pGib)
{
    if(!is_user_connected(pVictim) || !is_user_connected(pAttacker))
        return    HC_CONTINUE;

    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem;

    if(ActiveItem == NULLENT)
        return HC_CONTINUE;

    ActiveItem = get_member(pVictim, m_pActiveItem);

    rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pVictim], charsmax(szIconName)))
        set_msg_status_icon(pVictim, STATUS_HIDE, szIconName[pVictim]);

    return    HC_CONTINUE;   
}

stock parseColorValue(const value[])
{
    new color[COLORS][4];
    if(value[0] == EOS || parseColors(value, color) < 3)
    {
        g_RandomColor = true;
    }
    else
    {
        g_RandomColor = false;
        for(new i; i < sizeof g_AllColor; i++)
            g_AllColor[i] = str_to_num(color[i]);
    }   
}

stock set_msg_status_icon(pPlayer, iStatus, const sSprite[])
{   
    message_begin(MSG_ONE, g_iMsgIconLoc, .player = pPlayer);
    write_byte(iStatus);
    write_string(sSprite);

    if(iStatus != STATUS_HIDE)
    {
        if(g_RandomColor)
        {
            write_byte(random(255));
            write_byte(random(255));
            write_byte(random(255));
        }
        else
        {
            write_byte(g_AllColor[RED]);
            write_byte(g_AllColor[GREEN]);
            write_byte(g_AllColor[BLUE]);
        }
    }

    message_end();
}

RegisterCvars()
{
    bind_pcvar_num(
        create_cvar(
            .name = "wi_mp_sprite",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = "Где будет отображена иконка ^n 0 - выключить. ^n 1 - Там где корзина. ^n 2 - Там где часы",
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[WI_MP_SPRITE]
    );
    bind_pcvar_string(
        create_cvar(
            .name = "wi_mp_sprite_color",
            .string = "255 063 000",
            .flags = FCVAR_SERVER,
            .description = fmt("Цвет иконки оружия [rrrgggbbb], если она находится там, где корзина. ^n Оставьте поле пустым, если хотите рандомный цвет ^n 000128000 - 000 красный; 128 зеленый; 000 синий")
        ), g_Cvar[WI_MP_SPRITE_COLOR], charsmax(g_Cvar[WI_MP_SPRITE_COLOR])
    );
}
 

Вложения

Сообщения
657
Реакции
562
Предупреждения
8
Помог
9 раз(а)
rg_get_weapon_info(get_member(get_member(pPlayer, m_pActiveItem), m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));
Проверки делать надо по-человечески.
Наверное автор пытался сэкономить строки кода (аптимизации?) 😂
 
Последнее редактирование модератором:
Сообщения
775
Реакции
293
Помог
11 раз(а)
Vaqtincha, ну это было сделано не по этому, а потому что используется 1 раз, в данной функции.

Во вторых, я ему скидывал попытки устранить баг
Код:
public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
  if(!is_user_connected(pPlayer))
    return;
 
  if(!is_user_alive(pPlayer))
    return;

  new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem;
 
  if(ActiveItem == NULLENT)
    return; 
 
  ActiveItem = get_member(pPlayer, m_pActiveItem);
  rg_get_weapon_info(get_member(ActiveItem, m_iId), WI_NAME, szWeaponName, charsmax(szWeaponName));

  if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
  {
    set_msg_status_icon(pPlayer, STATUS_HIDE, szIconName[pPlayer]);
    g_iLastIcon[pPlayer] = szIconName[pPlayer];
    set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
    
    if(g_Cvar[WI_MP_SPRITE] == 1)
      parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
  }
}
Даже уже проверку на Коннект добавил, как многие советуют, хотя я слышал , что в проверке на живой уже присутствует проверка на Коннект, но чем черт не шутит.

P.S. Вместо токсичности, начни помогать. А не показывать какой ты умный.
 
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
maFFyoZZyk, и где ты ошибку исправил? Сначала надо выставить activeitem, потом уже проверять
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
steelzzz, я же говорю "пытался", а не "исправил"
20 Апр 2023
steelzzz, соглашусь, мой косяк... Почему сделал так, не знаю. Дома буду, посмотрю
20 Апр 2023
И не нужно так бурно реагировать. Я предложил человеку создать, тему потому как сам зашел в тупик. И да этой проверки раньше не было в принципе, я в дальнейшем ее добавил, потому как решил, что дело именно в ней
 
Последнее редактирование:

AUF

Сообщения
91
Реакции
8
maFFyoZZyk,
C++:
public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
  if(!is_user_connected(pPlayer))
    return;
 
  if(!is_user_alive(pPlayer))
    return;
is_user_alive уже содержит проверку на connect игрока вроде. достаточно просто юзать is_user_alive
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
AUF, серьезно?
20 Апр 2023
А читать тему вы не пробовали?
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
Сначала надо выставить activeitem, потом уже проверять
Если дело в этом, то вот

Код:
#include <amxmodx>
#include <reapi>

#define parseColors(%1,%2) parse(%1, %2[RED], charsmax(%2[]), %2[GREEN], charsmax(%2[]), %2[BLUE], charsmax(%2[]))

enum any:CVARS
{
    WI_MP_SPRITE,
    WI_MP_SPRITE_COLOR[32]
};
new g_Cvar[CVARS];

enum _:COLORS
{
    RED,
    GREEN,
    BLUE
};
new g_AllColor[COLORS];
new bool:g_RandomColor;

enum any:
{
    STATUS_HIDE, // 0
    STATUS_SHOW, // 1
    STATUS_FLASH, // 2
}

const TASK_INDEX = 0xA6123;
new Trie:g_tWeapons;
new g_iLastIcon[MAX_PLAYERS+1][MAX_NAME_LENGTH];
new g_iMsgIconLoc;

public plugin_init()
{
    register_plugin("Re: Weapon Icon", "1.0", "maFFyoZZyk");

    RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Post", .post = true);
    RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
    RegisterHookChain(RG_CBasePlayerWeapon_DefaultReload, "CBasePlayerWeapon_DefaultReload_Post", .post = true);
    RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", .post = true);   
    // register_event("AmmoX", "draw_icon", "be")

    RegisterCvars();
    AutoExecConfig(true, "weapon_icon");   
}

public plugin_cfg()
{
    switch(g_Cvar[WI_MP_SPRITE])
    {
        case 2:    g_iMsgIconLoc = get_user_msgid("Scenario");
        case 1:    g_iMsgIconLoc = get_user_msgid("StatusIcon");
        case 0:    g_iMsgIconLoc = 0;
    }

    g_tWeapons = TrieCreate();

    TrieSetString(g_tWeapons, "weapon_p228",            "d_p228");
    TrieSetString(g_tWeapons, "weapon_scout",            "d_scout");
    TrieSetString(g_tWeapons, "weapon_hegrenade",        "d_grenade");
    TrieSetString(g_tWeapons, "weapon_xm1014",            "d_xm1014");
    TrieSetString(g_tWeapons, "weapon_mac10",            "d_mac10");
    TrieSetString(g_tWeapons, "weapon_aug",                "d_aug");
    TrieSetString(g_tWeapons, "weapon_smokegrenade",    "d_grenade");
    TrieSetString(g_tWeapons, "weapon_elite",            "d_elite");
    TrieSetString(g_tWeapons, "weapon_fiveseven",        "d_fiveseven");
    TrieSetString(g_tWeapons, "weapon_ump45",            "d_ump45");
    TrieSetString(g_tWeapons, "weapon_sg550",            "d_sg550");
    TrieSetString(g_tWeapons, "weapon_galil",            "d_galil");
    TrieSetString(g_tWeapons, "weapon_famas",            "d_famas");
    TrieSetString(g_tWeapons, "weapon_usp",                "d_usp");
    TrieSetString(g_tWeapons, "weapon_glock18",            "d_glock18");
    TrieSetString(g_tWeapons, "weapon_awp",                "d_awp");
    TrieSetString(g_tWeapons, "weapon_mp5navy",            "d_mp5navy");
    TrieSetString(g_tWeapons, "weapon_m249",            "d_m249");
    TrieSetString(g_tWeapons, "weapon_m3",                "d_m3");
    TrieSetString(g_tWeapons, "weapon_m4a1",            "d_m4a1");
    TrieSetString(g_tWeapons, "weapon_tmp",                "d_tmp");
    TrieSetString(g_tWeapons, "weapon_g3sg1",            "d_g3sg1");
    TrieSetString(g_tWeapons, "weapon_flashbang",        "d_grenade");
    TrieSetString(g_tWeapons, "weapon_deagle",            "d_deagle");
    TrieSetString(g_tWeapons, "weapon_sg552",            "d_sg552");
    TrieSetString(g_tWeapons, "weapon_ak47",            "d_ak47");
    TrieSetString(g_tWeapons, "weapon_knife",            "d_knife");
    TrieSetString(g_tWeapons, "weapon_p90",                "d_p90");
}

public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
    if(!is_user_alive(pPlayer))
        return;

    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, WeaponID;

    ActiveItem = get_member(pPlayer, m_pActiveItem);

    if(ActiveItem == NULLENT)
        return;   
    
    WeaponID = get_member(ActiveItem, m_iId);
    rg_get_weapon_info(WeaponID, WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, szIconName[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayerWeapon_DefaultDeploy_Post(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, WeaponID;
    new pPlayer = get_member(pEntity, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    ActiveItem = get_member(pPlayer, m_pActiveItem);
    
    if(ActiveItem == NULLENT)
        return;   

    WeaponID = get_member(ActiveItem, m_iId);
    rg_get_weapon_info(WeaponID, WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayerWeapon_DefaultReload_Post(const this, iClipSize, iAnim, Float:fDelay)
{
    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, WeaponID, pPlayer;

    pPlayer = get_member(this, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    ActiveItem = get_member(pPlayer, m_pActiveItem);
    
    if(ActiveItem == NULLENT)
        return;   

    WeaponID = get_member(ActiveItem, m_iId);
    rg_get_weapon_info(WeaponID, WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pPlayer], charsmax(szIconName)))
    {
        set_msg_status_icon(pPlayer, STATUS_HIDE, g_iLastIcon[pPlayer]);
        g_iLastIcon[pPlayer] = szIconName[pPlayer];
        set_msg_status_icon(pPlayer, STATUS_SHOW, szIconName[pPlayer]);
        
        if(g_Cvar[WI_MP_SPRITE] == 1)
            parseColorValue(g_Cvar[WI_MP_SPRITE_COLOR]);
    }
}

public CBasePlayer_Killed_Post(pVictim, pAttacker, pGib)
{
    if(!is_user_connected(pVictim) || !is_user_connected(pAttacker))
        return    HC_CONTINUE;

    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, WeaponID;

    ActiveItem = get_member(pVictim, m_pActiveItem);
    
    if(ActiveItem == NULLENT)
        return HC_CONTINUE;

    WeaponID = get_member(ActiveItem, m_iId);
    rg_get_weapon_info(WeaponID, WI_NAME, szWeaponName, charsmax(szWeaponName));

    if(TrieGetString(g_tWeapons, szWeaponName, szIconName[pVictim], charsmax(szIconName)))
        set_msg_status_icon(pVictim, STATUS_HIDE, szIconName[pVictim]);

    return    HC_CONTINUE;   
}

stock parseColorValue(const value[])
{
    new color[COLORS][4];
    if(value[0] == EOS || parseColors(value, color) < 3)
    {
        g_RandomColor = true;
    }
    else
    {
        g_RandomColor = false;
        for(new i; i < sizeof g_AllColor; i++)
            g_AllColor[i] = str_to_num(color[i]);
    }   
}

stock set_msg_status_icon(pPlayer, iStatus, const sSprite[])
{   
    message_begin(MSG_ONE, g_iMsgIconLoc, .player = pPlayer);
    write_byte(iStatus);
    write_string(sSprite);

    if(iStatus != STATUS_HIDE)
    {
        if(g_RandomColor)
        {
            write_byte(random(255));
            write_byte(random(255));
            write_byte(random(255));
        }
        else
        {
            write_byte(g_AllColor[RED]);
            write_byte(g_AllColor[GREEN]);
            write_byte(g_AllColor[BLUE]);
        }
    }

    message_end();
}

RegisterCvars()
{
    bind_pcvar_num(
        create_cvar(
            .name = "wi_mp_sprite",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = "Где будет отображена иконка ^n 0 - выключить. ^n 1 - Там где корзина. ^n 2 - Там где часы",
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[WI_MP_SPRITE]
    );
    bind_pcvar_string(
        create_cvar(
            .name = "wi_mp_sprite_color",
            .string = "255 063 000",
            .flags = FCVAR_SERVER,
            .description = fmt("Цвет иконки оружия [rrrgggbbb], если она находится там, где корзина. ^n Оставьте поле пустым, если хотите рандомный цвет ^n 000128000 - 000 красный; 128 зеленый; 000 синий")
        ), g_Cvar[WI_MP_SPRITE_COLOR], charsmax(g_Cvar[WI_MP_SPRITE_COLOR])
    );
}
 
Сообщения
657
Реакции
562
Предупреждения
8
Помог
9 раз(а)
maFFyoZZyk, опять мимо. Проверку id оружие упустил (тк rg_get_weapon_info любит не все idы и ошику слёт)

Ps: создай сток если везде используешь одинаковый код.
 
Сообщения
75
Реакции
82
Помог
6 раз(а)
1. Для чего это?:
Код:
    RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
    RegisterHookChain(RG_CBasePlayerWeapon_DefaultReload, "CBasePlayerWeapon_DefaultReload_Post", .post = true);
В оригинале, это используется что бы менять цвет в зависимости от количества патронов оставшихся
2.
Код:
public CBasePlayerWeapon_DefaultDeploy_Post(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
    new szWeaponName[MAX_NAME_LENGTH], szIconName[MAX_PLAYERS+1][MAX_NAME_LENGTH], ActiveItem, WeaponID;
    new pPlayer = get_member(pEntity, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    ActiveItem = get_member(pPlayer, m_pActiveItem);
  
    if(ActiveItem == NULLENT)
        return;
pEntity - это же и есть id Item используемый, для чего его находить повторно ActiveItem = get_member(pPlayer, m_pActiveItem); ?
3. В событии смерти раз уже кешируешь отображаемый спрайт, то достаточно его использовать, а не получать по новой
4. Парсить цвета можно один раз сразу при создании квара, а если хочешь добавить возможность менять цвета "на лету"
есть hook_cvar_change
5.
Код:
    switch(g_Cvar[WI_MP_SPRITE])
    {
        case 2:    g_iMsgIconLoc = get_user_msgid("Scenario");
        case 1:    g_iMsgIconLoc = get_user_msgid("StatusIcon");
        case 0:    g_iMsgIconLoc = 0;
    }
Интересно что будет если во время игры кто то выключит квар в 0? Сколько ошибок понасыпет при попытке отослать мессагу с 0м id
6. Как ранее верно заметили rg_get_weapon_info(WeaponID, WI_NAME, szWeaponName, charsmax(szWeaponName));
не все weapon ID любит, можешь использовать get_weaponname(iWeaponID, weaponname, charsmax(weaponname));
7.
123.PNG
234.PNG
 
Последнее редактирование:
Сообщения
775
Реакции
293
Помог
11 раз(а)
В оригинале, это используется что бы менять цвет в зависимости от количества патронов оставшихся
Ну эта идея меня не бросила, но реализацию не придумал.
не все weapon ID любит
можно подробнее, что конкретно он не любит
22 Апр 2023
RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
пока не сменишь оружие, иконки не будет, так как ResetHud сотрет все
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу