Shadowless
Пользователь
- Регистрация
- 24 Фев 2019
- Сообщения
- 237
- Симпатии
- 4
- Пол
- Мужской
HELP
L 08/07/2018 - 06:25:17: [CSTRIKE] Invalid weapon id 29
L 08/07/2018 - 06:25:17: [AMXX] Displaying debug trace (plugin "ammo_on_the_ground.amxx", version "1.0")
L 08/07/2018 - 06:25:17: [AMXX] Run time error 10: native error (native "cs_get_user_bpammo")
L 08/07/2018 - 06:25:17: [AMXX] [0] ammo_on_the_ground.sma::ham_weapon_reload (line 186)
L 08/07/2018 - 06:25:17: [AMXX] Displaying debug trace (plugin "ammo_on_the_ground.amxx", version "1.0")
L 08/07/2018 - 06:25:17: [AMXX] Run time error 10: native error (native "cs_get_user_bpammo")
L 08/07/2018 - 06:25:17: [AMXX] [0] ammo_on_the_ground.sma::ham_weapon_reload (line 186)
C++:
#define VERSION "1.0"
//╔══╗─╔╗╔╗──╔══╗╔══╗╔╗─╔╗╔╗╔╗╔══╗
//║╔╗║─║║║║──║╔═╝║╔╗║║╚═╝║║║║║║╔╗║
//║╚╝╚╗║╚╝║──║╚═╗║╚╝║║╔╗─║║╚╝║║╚╝║
//║╔═╗║╚═╗║──╚═╗║║╔╗║║║╚╗║╚═╗║║╔╗║
//║╚═╝║─╔╝║──╔═╝║║║║║║║─║║─╔╝║║║║║
//╚═══╝─╚═╝──╚══╝╚╝╚╝╚╝─╚╝─╚═╝╚╝╚╝
//
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "AMMO ON THE GROUND"
#define AUTHOR "Sanya@ (Skype: admin-zombarik)"
#define PEV_CSW pev_iuser1
#define PEV_PLUS_AMMO pev_iuser2
#define OFFSET_PLAYER 41
#define OFFSET_CLIP_AMMO 51
#define OFFSET_NEXT_ATTACK 83
#define OFFSET_IN_RELOAD 54
#define OFFSET_LINUX 5 //offsets 5 higher in Linux builds
#define OFFSET_LINUX_WEAPONS 4 //weapon offsets are only 4 steps higher on Linux
new
const
WEAPONS_CLASSNAME[][] =
{
"weapon_p228","weapon_scout","weapon_mac10","weapon_aug","weapon_elite","weapon_fiveseven","weapon_ump45","weapon_sg550","weapon_galil","weapon_famas","weapon_usp","weapon_glock18","weapon_awp","weapon_mp5navy","weapon_m4a1","weapon_tmp","weapon_g3sg1","weapon_deagle","weapon_sg552","weapon_ak47","weapon_p90"
},
WEAPONS_CSW[] =
{
CSW_P228,CSW_SCOUT,CSW_MAC10,CSW_AUG,CSW_ELITE,CSW_FIVESEVEN,CSW_UMP45,CSW_SG550,CSW_GALIL,CSW_FAMAS,CSW_USP,CSW_GLOCK18,CSW_AWP,CSW_MP5NAVY,CSW_M4A1,CSW_TMP,CSW_G3SG1,CSW_DEAGLE,CSW_SG552,CSW_AK47,CSW_KNIFE,CSW_P90
},
WEAPONS_CLIP[] = {13,10,30,30,30,20,25,30,35,25,12,20,10,30,30,30,20,7,30,30,50},
WEAPONS_SECONDARY[][] = {"weapon_deagle", "weapon_fiveseven", "weapon_glock18", "weapon_p228", "weapon_usp"},
model_primary[] = "models/w_9mmarclip.mdl",
model_secondary[] = "models/w_9mmclip.mdl",
classname_entity[] = "groundclip";
new
bool:player_press_use[33];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
new i,
count = sizeof(WEAPONS_CLASSNAME);
for(i = 0; i < count; i++)
RegisterHam(Ham_Weapon_Reload, WEAPONS_CLASSNAME[i], "ham_weapon_reload", true);
for(i = 0; i < count; i++)
RegisterHam(Ham_Item_Deploy, WEAPONS_CLASSNAME[i], "ham_item_deploy", true);
register_touch(classname_entity, "player", "touch_player");
register_forward(FM_CmdStart, "forward_cmd_start");
register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
}
public event_new_round()
{
static i;
for(i = 1; i < 33; i++)
{
if(!get_player_status(i))
remove_values(i);
}
remove_entity_name(classname_entity);
}
public client_putinserver(player_id)
{
remove_values(player_id);
}
public client_disconnect(player_id)
{
remove_values(player_id);
}
public plugin_precache()
{
precache_model(model_primary);
precache_model(model_secondary);
}
public forward_cmd_start(const player_id, const uc_handle)
{
if(!get_player_status(player_id))
return;
static
buttons,
old_buttons;
buttons = get_uc(uc_handle, UC_Buttons);
old_buttons = pev(player_id, pev_oldbuttons);
if(buttons & IN_USE && !(old_buttons & IN_USE))
player_press_use[player_id] = true;
else
player_press_use[player_id] = false;
}
public touch_player(entity_id, player_id)
{
if(!get_player_status(player_id))
return;
if(player_press_use[player_id])
{
static csw_id, plus_bpammo;
csw_id = pev(entity_id, PEV_CSW);
plus_bpammo = pev(entity_id, PEV_PLUS_AMMO);
if(!(pev(player_id, pev_weapons) & (1<<WEAPONS_CSW[csw_id])))
{
client_print(0, print_chat, "У Вас нет подходящего оружия для этих патронов");
return;
}
cs_set_user_bpammo(player_id, WEAPONS_CSW[csw_id], cs_get_user_bpammo(player_id, WEAPONS_CSW[csw_id])+plus_bpammo);
client_print(player_id, print_center, (is_secondary(csw_id) ? "+%d к запасу патронов вторичного оружия" : "+%d к запасу патронов первичного оружия"), plus_bpammo);
remove_entity(entity_id);
}
}
public ham_item_deploy(const weapon_id)
{
static player_id;
if(!is_valid_ent(weapon_id))
return;
player_id = pev(weapon_id, pev_owner);
if(get_player_status(player_id))
remove_task(player_id);
}
public ham_weapon_reload(const weapon_id)
{
static player_id, param[5], i, weapon_classname[64], Float:sec_next_attack;
if(!is_valid_ent(weapon_id))
return;
if(get_pdata_int(weapon_id, OFFSET_IN_RELOAD, OFFSET_LINUX_WEAPONS))
{
arrayset(param, -1, 5);
player_id = pev(weapon_id, pev_owner);
pev(weapon_id, pev_classname, weapon_classname, 63);
if(get_player_status(player_id))
{
sec_next_attack = get_pdata_float(player_id, OFFSET_NEXT_ATTACK, OFFSET_LINUX);
if(sec_next_attack <= 0.0)
return;
for(i = 0; i < sizeof(WEAPONS_CSW); i++)
{
if(equali(WEAPONS_CLASSNAME[i], weapon_classname))
{
param[0] = i;
break;
}
}
param[1] = weapon_id;
param[2] = get_pdata_int(weapon_id, OFFSET_CLIP_AMMO, OFFSET_LINUX_WEAPONS);
if(param[0] != -1 && param[2] < WEAPONS_CLIP[i] && param[2] > 0)
{
param[4] = cs_get_user_bpammo(player_id, WEAPONS_CSW[i]);
param[3] = ((param[4] < WEAPONS_CLIP[i]) ? param[4] : -1);
param[4] = ((param[4] <= WEAPONS_CLIP[i]) ? 0 : (param[4]-WEAPONS_CLIP[i]));
if(param[4] >= 0)
{
param[4] = WEAPONS_CLIP[i];
set_task(sec_next_attack+0.1, "reload_task", player_id, param, 5);
}
}
}
}
}
public reload_task(param[], player_id)
{
static weapon_id, csw_id, clip, setclip, minusbpammo, entity_id, Float:player_origin[3];
if(param[0] == -1 || param[1] == -1 || param[2] == -1 || param[4] == -1)
return;
if(!get_player_status(player_id))
return;
csw_id = param[0];
weapon_id = param[1];
clip = param[2];
setclip = param[3];
minusbpammo = param[4];
if(setclip != -1)
set_pdata_int(weapon_id, OFFSET_CLIP_AMMO, setclip, OFFSET_LINUX_WEAPONS);
minusbpammo -= (WEAPONS_CLIP[csw_id]-clip);
cs_set_user_bpammo(player_id, WEAPONS_CSW[csw_id], cs_get_user_bpammo(player_id, WEAPONS_CSW[csw_id])-minusbpammo);
entity_id = 0;
entity_id = create_entity("info_target");
if(entity_id)
{
pev(player_id, pev_origin, player_origin);
set_pev(entity_id, pev_classname, classname_entity);
engfunc(EngFunc_SetModel, entity_id, (is_secondary(csw_id) ? model_secondary : model_primary));
set_pev(entity_id, pev_solid, SOLID_TRIGGER);
set_pev(entity_id, pev_movetype, MOVETYPE_TOSS);
engfunc(EngFunc_SetSize, entity_id, Float:{ -4.0, -4.0, -4.0 }, Float:{ 4.0, 4.0, 4.0 });
engfunc(EngFunc_SetOrigin, entity_id, player_origin);
set_pev(entity_id, PEV_CSW, csw_id);
set_pev(entity_id, PEV_PLUS_AMMO, clip);
static Float:velocity[3];
velocity[0] = random_float(50.0,100.0);
velocity[1] = random_float(50.0,100.0);
velocity[2] = random_float(100.0,300.0);
set_pev(entity_id, pev_velocity, velocity);
}
}
// 0 - нет такого игрока
// 1 - игрок на сервере
// 2 - игрок на сервере и жив
get_player_status(const player_id)
{
if(player_id > 0 && player_id <= 32)
{
if(is_user_connected(player_id) || is_user_bot(player_id))
{
if(is_user_alive(player_id))
return 2;
return 1;
}
}
return 0;
}
bool:is_secondary(const csw_id)
{
static i;
for(i = 0; i < sizeof(WEAPONS_SECONDARY); i++)
{
if(equali(WEAPONS_SECONDARY[i], WEAPONS_CLASSNAME[csw_id]))
return true;
}
return false;
}
remove_values(const player_id)
{
remove_task(player_id);
player_press_use[player_id] = false;
}
Последнее редактирование: