Christmas_grenades

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
86
Реакции
-7
Ошибка
ошибок нет
ОС
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-mpatch
Build date: 18:48:11 Oct 05 2022 (3098)
Build from: https://github.com/dreamstalker/rehlds/commit/d6ebe82
ReGamedll
ReGameDLL version: 5.21.0.556-dev
Build date: 08:43:58 Jul 22 2022
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/1081301
Версия 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
Список метамодулей
[ 1] Rechecker        RUN   -    rechecker_mm_i386.so      v2.7             ini  Chlvl ANY  
[ 2] Reunion RUN - reunion_mm_i386.so v0.1.92d ini Start Never
[ 3] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 4] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 5] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[ 6] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5294 ini Start ANY
[ 7] HitBox Fix RUN - hitbox_fix_mm_i386.so v1.1.1 ini Start ANY
[ 8] Admins Kit RUN - adminskit_amxx_i386.so v2.1.0 pl6 ANY ANY
[ 9] ReAPI RUN - reapi_amxx_i386.so v5.22.0.254-dev pl6 ANY Never
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5294 pl6 ANY ANY
[11] MySQL RUN - mysql_amxx_i386.so v1.9.0.5294 pl6 ANY ANY
[12] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5294 pl6 ANY ANY
[13] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5294 pl6 ANY ANY
[14] Fun RUN - fun_amxx_i386.so v1.9.0.5294 pl6 ANY ANY
14 plugins, 14 running
Список плагинов
[  1] Only Test Plugins       0.1         b0t.              PluginForTests.  running  
[ 2] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql_l. running
[ 3] Stimulation 2.0 b0t. Stimulation.amx debug
[ 4] Cristmas grenades 1.0 OverGame cristmas-grenad running
[ 5] NY Kill Sprite 1.0 BadMandarin NYKillEffect.am running
5 plugins, 5 running
Автор плагина
OverGame
Версия плагина
1.0
Исходный код
#include amxmodx
#include fakemeta
#include hamsandwich

#define OFFSET_WEAPON 41
#define OFFSET_LINUX 4

new g_iResourceSprite, g_iResource[][] =
{
"models/v_snowballll_f.mdl", //Flashbang (view) index: 0
"models/p_snowballll_f.mdl", //Flashbang (weapon) index: 1
"models/v_snowballll_h.mdl", //Hegrenade (view) index: 2
"models/p_snowballll_h.mdl", //Hegrenade (weapon) index: 3
"models/v_snowballll_s.mdl", //Smokegrenade (view) index: 4
"models/p_snowballll_s.mdl", //Smokegrenade (weapon) index: 5
"models/w_snowballll.mdl" //All (world) index 6
};

public plugin_precache()
{
for(new i; i < sizeof(g_iResource); i++)
{
if(file_exists(g_iResource[i]))
{
engfunc(EngFunc_PrecacheModel, g_iResource[i]);
}
else {
log_amx("File ^"%s^" not found!", g_iResource[i]);
}
}

g_iResourceSprite = engfunc(EngFunc_PrecacheModel, "sprites/frostgib.spr");
}

public plugin_init()
{
register_plugin("Cristmas grenades", "1.0", "OverGame");

register_forward(FM_SetModel, "Fakemeta_SetModel");
RegisterHam(Ham_Think, "grenade", "Ham_ThinkGrenade_Pre", false);

RegisterHam(Ham_Item_Deploy, "weapon_hegrenade", "Ham_DeployHegrenade_Post", true);
RegisterHam(Ham_Item_Deploy, "weapon_flashbang", "Ham_DeployFlashbang_Post", true);
RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "Ham_DeploySmokegrenade_Post", true);
}

public Fakemeta_SetModel(iEntity, const szModel[])
{
if(!pev_valid(iEntity)) return FMRES_IGNORED;

new szClassname[33];
pev(iEntity, pev_classname, szClassname, charsmax(szClassname));

if(equal(szClassname, "grenade"))
{
engfunc(EngFunc_SetModel, iEntity, g_iResource[6]);

if(equali(szModel, "models/w_hegrenade.mdl"))
{
set_pev(iEntity, pev_skin, 0);
}
else if(equali(szModel, "models/w_flashbang.mdl"))
{
set_pev(iEntity, pev_skin, 1);
}
else if(equali(szModel, "models/w_smokegrenade.mdl"))
{
set_pev(iEntity, pev_skin, 2);
}

return FMRES_SUPERCEDE;
}

return FMRES_IGNORED;
}

public Ham_ThinkGrenade_Pre(iEntity)
{
if(pev_valid(iEntity))
{
new Float:fOrigin[3];
pev(iEntity, pev_origin, fOrigin);

message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITETRAIL);
engfunc(EngFunc_WriteCoord, fOrigin[0]);
engfunc(EngFunc_WriteCoord, fOrigin[1]);
engfunc(EngFunc_WriteCoord, fOrigin[2]);
engfunc(EngFunc_WriteCoord, fOrigin[0]);
engfunc(EngFunc_WriteCoord, fOrigin[1]);
engfunc(EngFunc_WriteCoord, fOrigin[2]);
write_short(g_iResourceSprite);
write_byte(9);
write_byte(random_num(27, 30));
write_byte(2);
write_byte(10);
write_byte(10);
message_end();
}

return HAM_IGNORED;
}

public Ham_DeployHegrenade_Post(iWeapon)
{
new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);

if(is_user_alive(iPlayer))
{
set_pev(iPlayer, pev_viewmodel2, g_iResource[2]);
set_pev(iPlayer, pev_weaponmodel2, g_iResource[3]);
}

return HAM_IGNORED;
}

public Ham_DeployFlashbang_Post(iWeapon)
{
new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);

if(is_user_alive(iPlayer))
{
set_pev(iPlayer, pev_viewmodel2, g_iResource[0]);
set_pev(iPlayer, pev_weaponmodel2, g_iResource[1]);
}

return HAM_IGNORED;
}

public Ham_DeploySmokegrenade_Post(iWeapon)
{
new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);

if(is_user_alive(iPlayer))
{
set_pev(iPlayer, pev_viewmodel2, g_iResource[4]);
set_pev(iPlayer, pev_weaponmodel2, g_iResource[5]);
}

return HAM_IGNORED;
}
Парини помогите, при закладке бомбы заменяет модель и добавляет спрайты, на скрине видно
 
В этой теме было размещено решение! Перейти к решению.

Вложения

Сообщения
893
Реакции
149
Помог
25 раз(а)
Если актуально, через минут 5 накидаю вариант.
 
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
Надо проверить на m_Grenade_bIsC4 в setmodel
 
Сообщения
893
Реакции
149
Помог
25 раз(а)
C++:
#include amxmodx
#include fakemeta
#include reapi
#include hamsandwich

#define OFFSET_WEAPON        41
#define OFFSET_LINUX        4

new g_iResourceSprite, g_iResource[][] =
{
    "models/v_snowballll_f.mdl",            //Flashbang (view) index: 0
    "models/p_snowballll_f.mdl",            //Flashbang (weapon) index: 1
    "models/v_snowballll_h.mdl",            //Hegrenade (view) index: 2
    "models/p_snowballll_h.mdl",            //Hegrenade (weapon) index: 3
    "models/v_snowballll_s.mdl",            //Smokegrenade (view) index: 4
    "models/p_snowballll_s.mdl",            //Smokegrenade (weapon) index: 5
    "models/w_snowballll.mdl"                //All (world) index 6
};

public plugin_precache()
{
    for(new i; i < sizeof(g_iResource); i++)
    {
        if(file_exists(g_iResource[i]))
        {
            engfunc(EngFunc_PrecacheModel, g_iResource[i]);
        }
        else {
            log_amx("File ^"%s^" not found!", g_iResource[i]);
        }
    }
  
    g_iResourceSprite = engfunc(EngFunc_PrecacheModel, "sprites/frostgib.spr");
}

public plugin_init()
{
    register_plugin("Cristmas grenades", "1.0", "OverGame");
  
    register_forward(FM_SetModel, "Fakemeta_SetModel");
    RegisterHam(Ham_Think, "grenade", "Ham_ThinkGrenade_Pre", false);
  
    RegisterHam(Ham_Item_Deploy, "weapon_hegrenade", "Ham_DeployHegrenade_Post", true);
    RegisterHam(Ham_Item_Deploy, "weapon_flashbang", "Ham_DeployFlashbang_Post", true);
    RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "Ham_DeploySmokegrenade_Post", true);
}

public Fakemeta_SetModel(iEntity, const szModel[])
{
    if(!pev_valid(iEntity)) return FMRES_IGNORED;
  
    new szClassname[33];
    pev(iEntity, pev_classname, szClassname, charsmax(szClassname));
  
    if(get_member(iEntity,  m_Grenade_bIsC4) {
        if(equal(szClassname, "grenade"))
        {
            engfunc(EngFunc_SetModel, iEntity, g_iResource[6]);
      
            if(equali(szModel, "models/w_hegrenade.mdl"))
            {
                set_pev(iEntity, pev_skin, 0);
            }
            else if(equali(szModel, "models/w_flashbang.mdl"))
            {
                set_pev(iEntity, pev_skin, 1);
            }
            else if(equali(szModel, "models/w_smokegrenade.mdl"))
            {
                set_pev(iEntity, pev_skin, 2);
            }
      
            return FMRES_SUPERCEDE;
        }
    }
  
    return FMRES_IGNORED;
}

public Ham_ThinkGrenade_Pre(iEntity)
{
    if(pev_valid(iEntity))
    {
        new Float:fOrigin[3];
        pev(iEntity, pev_origin, fOrigin);
      
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        write_byte(TE_SPRITETRAIL);
        engfunc(EngFunc_WriteCoord, fOrigin[0]);
        engfunc(EngFunc_WriteCoord, fOrigin[1]);
        engfunc(EngFunc_WriteCoord, fOrigin[2]);
        engfunc(EngFunc_WriteCoord, fOrigin[0]);
        engfunc(EngFunc_WriteCoord, fOrigin[1]);
        engfunc(EngFunc_WriteCoord, fOrigin[2]);
        write_short(g_iResourceSprite);
        write_byte(9);
        write_byte(random_num(27, 30));
        write_byte(2);
        write_byte(10);
        write_byte(10);
        message_end();
    }
  
    return HAM_IGNORED;
}

public Ham_DeployHegrenade_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
  
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[2]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[3]);
    }
  
    return HAM_IGNORED;
}

public Ham_DeployFlashbang_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
  
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[0]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[1]);
    }
  
    return HAM_IGNORED;
}

public Ham_DeploySmokegrenade_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
  
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[4]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[5]);
    }
  
    return HAM_IGNORED;
}
10 Дек 2022
Попробуй вариант, который steelzzz подсказал (выше кинул, но нужен реапи)
 
Сообщения
86
Реакции
-7
ImmortalAmxx, grenades.sma(55) : error 001: expected token: ")", but found "{" ощибку выдает
10 Дек 2022
понял, скобки не хватает
 
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
@ImmortalAmxx,ты сам понял, что сделал? Надо что бы проверка была в отрицании
 
Сообщения
86
Реакции
-7
бомба появилась, но остались спрайты
10 Дек 2022
ImmortalAmxx,

L 12/10/2022 - 17:24:48: [AMXX] Run time error 10: native error (native "get_member_s")
L 12/10/2022 - 17:24:48: [AMXX] [0] cristmas-grenades.sma::Fakemeta_SetModel (line 55)
L 12/10/2022 - 17:24:48: [ReAPI] get_member_s: 'm_Grenade_bIsC4' has no refs to the base class of an entity 'func_breakable'
L 12/10/2022 - 17:24:48: [AMXX] Displaying debug trace (plugin "cristmas-grenades.amxx", version "1.0")
L 12/10/2022 - 17:24:48: [AMXX] Run time error 10: native error (native "get_member_s")
L 12/10/2022 - 17:24:48: [AMXX] [0] cristmas-grenades.sma::Fakemeta_SetModel (line 55)
 
Сообщения
494
Реакции
341
Помог
11 раз(а)
Можно обойтись тут и без reapi, потому как с ним стоит переписать почти весь плагин.

Код:
#include amxmodx
#include fakemeta
#include hamsandwich

#define OFFSET_WEAPON        41
#define OFFSET_LINUX        4

new g_iResourceSprite, g_iResource[][] =
{
    "models/v_snowballll_f.mdl",            //Flashbang (view) index: 0
    "models/p_snowballll_f.mdl",            //Flashbang (weapon) index: 1
    "models/v_snowballll_h.mdl",            //Hegrenade (view) index: 2
    "models/p_snowballll_h.mdl",            //Hegrenade (weapon) index: 3
    "models/v_snowballll_s.mdl",            //Smokegrenade (view) index: 4
    "models/p_snowballll_s.mdl",            //Smokegrenade (weapon) index: 5
    "models/w_snowballll.mdl"                //All (world) index 6
};

public plugin_precache()
{
    for(new i; i < sizeof(g_iResource); i++)
    {
        if(file_exists(g_iResource[i]))
            engfunc(EngFunc_PrecacheModel, g_iResource[i]);
        else
            log_amx("File ^"%s^" not found!", g_iResource[i]);
    }

    g_iResourceSprite = engfunc(EngFunc_PrecacheModel, "sprites/frostgib.spr");
}

public plugin_init()
{
    register_plugin("Cristmas grenades", "1.0", "OverGame");
 
    register_forward(FM_SetModel, "Fakemeta_SetModel");
    RegisterHam(Ham_Think, "grenade", "Ham_ThinkGrenade_Pre", false);
 
    RegisterHam(Ham_Item_Deploy, "weapon_hegrenade", "Ham_DeployHegrenade_Post", true);
    RegisterHam(Ham_Item_Deploy, "weapon_flashbang", "Ham_DeployFlashbang_Post", true);
    RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "Ham_DeploySmokegrenade_Post", true);
}

public Fakemeta_SetModel(iEntity, const szModel[])
{
    if(!pev_valid(iEntity)) return FMRES_IGNORED;
 
    new szClassname[33];
    pev(iEntity, pev_classname, szClassname, charsmax(szClassname));
 
    if(equal(szClassname, "grenade"))
    {
        if(equali(szModel, "models/w_hegrenade.mdl"))
        {
            engfunc(EngFunc_SetModel, iEntity, g_iResource[6]);
            set_pev(iEntity, pev_skin, 0);
            set_pev(iEntity, pev_iuser4, 1);

            return FMRES_SUPERCEDE;
        }
        else if(equali(szModel, "models/w_flashbang.mdl"))
        {
            engfunc(EngFunc_SetModel, iEntity, g_iResource[6]);
            set_pev(iEntity, pev_skin, 1);
            set_pev(iEntity, pev_iuser4, 1);

            return FMRES_SUPERCEDE;
        }
        else if(equali(szModel, "models/w_smokegrenade.mdl"))
        {
            engfunc(EngFunc_SetModel, iEntity, g_iResource[6]);
            set_pev(iEntity, pev_skin, 2);
            set_pev(iEntity, pev_iuser4, 1);

            return FMRES_SUPERCEDE;
        }
    }
 
    return FMRES_IGNORED;
}

public Ham_ThinkGrenade_Pre(iEntity)
{
    if(pev_valid(iEntity) && pev(iEntity, pev_iuser4))
    {
        new Float:fOrigin[3];
        pev(iEntity, pev_origin, fOrigin);
      
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        write_byte(TE_SPRITETRAIL);
        engfunc(EngFunc_WriteCoord, fOrigin[0]);
        engfunc(EngFunc_WriteCoord, fOrigin[1]);
        engfunc(EngFunc_WriteCoord, fOrigin[2]);
        engfunc(EngFunc_WriteCoord, fOrigin[0]);
        engfunc(EngFunc_WriteCoord, fOrigin[1]);
        engfunc(EngFunc_WriteCoord, fOrigin[2]);
        write_short(g_iResourceSprite);
        write_byte(9);
        write_byte(random_num(27, 30));
        write_byte(2);
        write_byte(10);
        write_byte(10);
        message_end();
    }
 
    return HAM_IGNORED;
}

public Ham_DeployHegrenade_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
 
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[2]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[3]);
    }
 
    return HAM_IGNORED;
}

public Ham_DeployFlashbang_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
 
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[0]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[1]);
    }
 
    return HAM_IGNORED;
}

public Ham_DeploySmokegrenade_Post(iWeapon)
{
    new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPON, OFFSET_LINUX);
 
    if(is_user_alive(iPlayer))
    {
        set_pev(iPlayer, pev_viewmodel2, g_iResource[4]);
        set_pev(iPlayer, pev_weaponmodel2, g_iResource[5]);
    }
 
    return HAM_IGNORED;
}
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
Блин.... как же сложно штудировать форум, вот тут я уже выкладывал вариант замены гранат на reapi
10 Дек 2022
Код:
new const models[][] =
{
    "models/grenades/v_he.mdl",
    "models/grenades/p_he.mdl",
    "models/grenades/v_fl.mdl",
    "models/grenades/p_fl.mdl",
    "models/grenades/v_sg.mdl",
    "models/grenades/p_sg.mdl"   
};
Код:
new const models_w[][] =
{
    "models/grenades/w_he.mdl",
    "models/grenades/w_fl.mdl",
    "models/grenades/w_sg.mdl"
};
тут меняются названия
 
Статус
В этой теме нельзя размещать новые ответы.

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

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