Участник
Пользователь
- Сообщения
- 42
- Реакции
- 32
Пытаюсь реализовать выдачу кастомного оружия на основе этого плагина от Фантома. В отличии от оригинала хочу чтобы все оружия обрабатывались одним плагином, а не так что одно оружие = отдельный плагин. Всё получилось, кроме учёта урона для М4А1/USP с глушителем и для фамас burst режима.
Подскажите как исправить эту ошибку, чтобы условие правильно срабатывало.
Также, был бы благодарен если укажете на ошибки в целом по коду или какие-то best practices, я только учусь)
Подскажите как исправить эту ошибку, чтобы условие правильно срабатывало.
L 02/06/2021 - 18:43:10: [ReAPI] get_member_s: 'm_M4A1_flBaseDamageSil' has no refs to the base class of an entity 'weapon_ak47'
L 02/06/2021 - 18:43:10: [AMXX] Displaying debug trace (plugin "comp.amxx", version "1.0")
L 02/06/2021 - 18:43:10: [AMXX] Run time error 10: native error (native "get_member_s")
L 02/06/2021 - 18:43:10: [AMXX] [0] comp.sma::GiveCustomWeapon (line 162)
L 02/06/2021 - 18:43:10: [AMXX] [1] comp.sma::testAk (line 75)
L 02/06/2021 - 18:43:29: [ReAPI] get_member_s: 'm_USP_flBaseDamageSil' has no refs to the base class of an entity 'weapon_m4a1'
L 02/06/2021 - 18:43:29: [AMXX] Displaying debug trace (plugin "comp.amxx", version "1.0")
L 02/06/2021 - 18:43:29: [AMXX] Run time error 10: native error (native "get_member_s")
L 02/06/2021 - 18:43:29: [AMXX] [0] comp.sma::GiveCustomWeapon (line 164)
L 02/06/2021 - 18:43:29: [AMXX] [1] comp.sma::testMa (line 78)
L 02/06/2021 - 18:43:10: [AMXX] Displaying debug trace (plugin "comp.amxx", version "1.0")
L 02/06/2021 - 18:43:10: [AMXX] Run time error 10: native error (native "get_member_s")
L 02/06/2021 - 18:43:10: [AMXX] [0] comp.sma::GiveCustomWeapon (line 162)
L 02/06/2021 - 18:43:10: [AMXX] [1] comp.sma::testAk (line 75)
L 02/06/2021 - 18:43:29: [ReAPI] get_member_s: 'm_USP_flBaseDamageSil' has no refs to the base class of an entity 'weapon_m4a1'
L 02/06/2021 - 18:43:29: [AMXX] Displaying debug trace (plugin "comp.amxx", version "1.0")
L 02/06/2021 - 18:43:29: [AMXX] Run time error 10: native error (native "get_member_s")
L 02/06/2021 - 18:43:29: [AMXX] [0] comp.sma::GiveCustomWeapon (line 164)
L 02/06/2021 - 18:43:29: [AMXX] [1] comp.sma::testMa (line 78)
Код:
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
#define DAMAGE_AK47 1.2
#define DAMAGE_M4A1 1.2
#define DAMAGE_AWP 1.1
#define DAMAGE_DEAGLE 1.3
enum _:cwModelList {
goldenDeagle = 0,
goldenAwp,
goldenAk47,
goldenM4A1
};
new customModelsV[cwModelList][32] = {
"models/gold/v_deagle.mdl",
"models/gold/v_awp.mdl",
"models/gold/v_ak47.mdl",
"models/gold/v_m4a1.mdl"
};
new customModelsP[cwModelList][32] = {
"models/gold/p_deagle.mdl",
"models/gold/p_awp.mdl",
"models/gold/p_ak47.mdl",
"models/gold/p_m4a1.mdl"
};
new customModelsW[cwModelList][32] = {
"models/gold/w_deagle.mdl",
"models/gold/w_awp.mdl",
"models/gold/w_ak47.mdl",
"models/gold/w_m4a1.mdl"
};
public plugin_precache() {
for(new i = 0; i < sizeof(customModelsV); i++) if (customModelsV[i][0]) precache_model(customModelsV[i]);
for(new i = 0; i < sizeof(customModelsP); i++) if (customModelsP[i][0]) precache_model(customModelsP[i]);
for(new i = 0; i < sizeof(customModelsW); i++) if (customModelsW[i][0]) precache_model(customModelsW[i]);
}
enum _:cwUid{
_goldenDeagle = 2387,
_goldenAwp,
_goldenAk47,
_goldenM4A1
};
stock isCustomWeapon(iWeapon) {
switch(get_entvar(iWeapon, var_impulse)) {
case _goldenDeagle.._goldenM4A1: return true;
default: return false;
}
return false;
}
#define GetWeponID(%1) WeaponIdType:get_member(%1, m_iId)
public plugin_init() {
// MODELS
RegisterHam(Ham_Item_Deploy, "weapon_ak47", "Item_Deploy_Post", true);
RegisterHam(Ham_Item_Deploy, "weapon_m4a1", "Item_Deploy_Post", true);
RegisterHam(Ham_Item_Deploy, "weapon_awp", "Item_Deploy_Post", true);
RegisterHam(Ham_Item_Deploy, "weapon_deagle", "Item_Deploy_Post", true);
// W_ MODEL
RegisterHookChain(RG_CWeaponBox_SetModel, "CWeaponBox_SetModel_Pre", false);
register_clcmd("akk", "testAk");
register_clcmd("mmm", "testMa");
}
public testAk(id) {
GiveCustomWeapon(id, "weapon_ak47", 90, _goldenAk47);
}
public testMa(id) {
GiveCustomWeapon(id, "weapon_m4a1", 90, _goldenM4A1);
}
public Item_Deploy_Post(weapon) {
if (!isCustomWeapon(weapon)) {
return HAM_IGNORED;
}
new cwIndex = 0;
switch(get_entvar(weapon, var_impulse)) {
case _goldenAk47: cwIndex = goldenAk47;
case _goldenAwp: cwIndex = goldenAwp;
case _goldenM4A1: cwIndex = goldenM4A1;
case _goldenDeagle: cwIndex = goldenDeagle;
default: return HAM_IGNORED;
}
if (cwIndex) {
new iPlayer = get_member(weapon, m_pPlayer);
set_entvar(iPlayer, var_viewmodel, customModelsV[cwIndex]);
set_entvar(iPlayer, var_weaponmodel, customModelsP[cwIndex]);
}
return HAM_IGNORED;
}
public CWeaponBox_SetModel_Pre(const weaponbox, const model[]) {
new weapon = getWeaponBoxWeapon(weaponbox);
new cwIndex = 0;
switch(get_entvar(weapon, var_impulse)) {
case _goldenAk47: cwIndex = goldenAk47;
case _goldenAwp: cwIndex = goldenAwp;
case _goldenM4A1: cwIndex = goldenM4A1;
case _goldenDeagle: cwIndex = goldenDeagle;
default: return PLUGIN_CONTINUE;
}
if (weapon != NULLENT && isCustomWeapon(weapon)) {
SetHookChainArg(2, ATYPE_STRING, customModelsW[cwIndex]);
}
return PLUGIN_CONTINUE;
}
stock getWeaponBoxWeapon(const weaponbox) {
for (new i = 0, weapon; i < MAX_ITEM_TYPES; i++) {
weapon = get_member(weaponbox, m_WeaponBox_rgpPlayerItems, i);
if (!is_nullent(weapon)) {
return weapon;
}
}
return NULLENT;
}
GiveCustomWeapon(iPlayer, weaponName[], iAmmo = 0, weaponId = 0) {
if (!equal(weaponName, "weapon_", 7))
return PLUGIN_HANDLED;
if (!is_user_alive(iPlayer))
return PLUGIN_HANDLED;
new weapon = rg_give_custom_item(iPlayer, weaponName, GT_DROP_AND_REPLACE, weaponId);
if (is_nullent(weapon)) {
return PLUGIN_HANDLED;
}
if (iAmmo > 0) rg_set_user_bpammo(iPlayer, GetWeponID(weapon), iAmmo);
new Float:iDmgIndex;
switch(weaponId) {
case _goldenDeagle: iDmgIndex = DAMAGE_DEAGLE;
case _goldenAwp: iDmgIndex = DAMAGE_AWP;
case _goldenAk47: iDmgIndex = DAMAGE_AK47;
case _goldenM4A1: iDmgIndex = DAMAGE_M4A1;
default: iDmgIndex = 1.0;
}
set_member(weapon, m_Weapon_flBaseDamage, Float:get_member(weapon, m_Weapon_flBaseDamage) * iDmgIndex);
if (strcmp(weaponName, "weapon_m4a1")) {
set_member(weapon, m_M4A1_flBaseDamageSil, Float:get_member(weapon, m_M4A1_flBaseDamageSil) * iDmgIndex);
} else if (strcmp(weaponName, "weapon_usp")) {
set_member(weapon, m_USP_flBaseDamageSil, Float:get_member(weapon, m_USP_flBaseDamageSil) * iDmgIndex);
} else if (strcmp(weaponName, "weapon_famas")) {
set_member(weapon, m_Famas_flBaseDamageBurst, Float:get_member(weapon, m_Famas_flBaseDamageBurst) * iDmgIndex);
}
return PLUGIN_HANDLED;
}
Также, был бы благодарен если укажете на ошибки в целом по коду или какие-то best practices, я только учусь)
Последнее редактирование: