Senior Member
Join Date: Aug 2017
Location: Kyiv
|
01-03-2020
, 16:29
client_print
|
#1
|
Help correctly put client_print, when you approach your ammo (thrown out), the player wrote in the center of the screen - client_print " You can not take your ammo"
PHP Code:
public touch_player(entity_id, player_id)
{
if(!(pev(entity_id, pev_flags) & FL_ONGROUND) || !get_player_status(player_id))
return PLUGIN_HANDLED;
if(pev(entity_id, PEV_OWNER) != player_id)
{
static csw_id, plus_bpammo;
csw_id = get_active_weapon_csw_id(player_id);
if(csw_id && csw_id != CSW_KNIFE)
{
if(is_secondary(pev(entity_id, PEV_CSW)) != is_secondary_csw(csw_id))
{
client_print(player_id, print_center, "Эти Патроны не подходят к Вашему Оружию");
return PLUGIN_HANDLED;
}
plus_bpammo = pev(entity_id, PEV_PLUS_AMMO);
cs_set_user_bpammo(player_id, csw_id, cs_get_user_bpammo(player_id, csw_id)+plus_bpammo);
client_cmd(player_id,"spk %s",ammo_sound)
screen_fade(player_id)
client_print(player_id, print_center, "Вы взяли +%d патронов", plus_bpammo);
remove_entity(entity_id);
}
}
return PLUGIN_HANDLED;
}
PHP Code:
#define VERSION "1.3"
#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 PEV_OWNER pev_iuser3
#define PEV_SLOT pev_iuser4
#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
#define STEP 10.0
#define VERTICAL_SPEED 20.0
#define HORISONTAL_SPEED 60.0
#define LIFE_AMMO 25.0 // Сколько секунд до исчезновения Патронов
enum (+= 1) {
STATUS_NONE = 0,
STATUS_EFFECT,
STATUS_KILL
}
new g_msgScreenFade
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","weapon_m249"
},
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_P90,CSW_M249
},
WEAPONS_CLIP[] = {13,10,30,30,30,20,25,30,35,25,12,20,10,30,30,30,20,7,30,30,50,100},
WEAPONS_SECONDARY[][] = {"weapon_deagle", "weapon_fiveseven", "weapon_glock18", "weapon_p228", "weapon_usp", "weapon_elite"},
WEAPONS_SECONDARY_CSW[] = {CSW_DEAGLE, CSW_FIVESEVEN, CSW_GLOCK18, CSW_P228, CSW_USP, CSW_ELITE},
model_primary[] = "models/ammo_hd/ammo_primary.mdl",
model_secondary[] = "models/ammo_hd/ammo_secondary.mdl",
ammo_sound[] = "ammo_sound/ammo_sound.wav",
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_think(classname_entity, "ThinkAmmo");
register_forward(FM_CmdStart, "forward_cmd_start");
register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
g_msgScreenFade = get_user_msgid("ScreenFade");
}
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);
precache_sound(ammo_sound);
}
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 screen_fade(id) {
message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, id)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(75)
message_end()
}
public touch_player(entity_id, player_id)
{
if(!(pev(entity_id, pev_flags) & FL_ONGROUND) || !get_player_status(player_id))
return PLUGIN_HANDLED;
if(pev(entity_id, PEV_OWNER) != player_id)
{
static csw_id, plus_bpammo;
csw_id = get_active_weapon_csw_id(player_id);
if(csw_id && csw_id != CSW_KNIFE)
{
if(is_secondary(pev(entity_id, PEV_CSW)) != is_secondary_csw(csw_id))
{
client_print(player_id, print_center, "Эти Патроны не подходят к Вашему Оружию");
return PLUGIN_HANDLED;
}
plus_bpammo = pev(entity_id, PEV_PLUS_AMMO);
cs_set_user_bpammo(player_id, csw_id, cs_get_user_bpammo(player_id, csw_id)+plus_bpammo);
client_cmd(player_id,"spk %s",ammo_sound)
screen_fade(player_id)
client_print(player_id, print_center, "Вы взяли +%d патронов", plus_bpammo);
remove_entity(entity_id);
}
}
return PLUGIN_HANDLED;
}
public ThinkAmmo(entity) {
if (!pev_valid(entity)) {
return HAM_IGNORED;
}
switch(pev(entity, pev_impulse)) {
case STATUS_NONE:{
set_pev(entity, pev_movetype, MOVETYPE_FLY);
set_pev(entity, pev_solid, SOLID_NOT);
set_pev(entity, pev_rendermode, kRenderTransAlpha);
set_pev(entity, pev_renderamt, 100.0);
set_pev(entity, pev_velocity, Float:{0.0, 0.0, VERTICAL_SPEED});
set_pev(entity, pev_avelocity, Float:{0.0, HORISONTAL_SPEED, 0.0})
set_pev(entity, pev_impulse, STATUS_EFFECT);
}
case STATUS_EFFECT: {
if (pev(entity, pev_renderamt) > 0.0) {
set_pev(entity, pev_renderamt, floatmax(0.0, pev(entity, pev_renderamt) - STEP));
} else {
set_pev(entity, pev_flags, FL_KILLME);
set_pev(entity, pev_impulse, STATUS_KILL);
}
}
}
set_pev(entity,pev_nextthink,get_gametime() + 0.1)
return HAM_SUPERCEDE;
}
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_OWNER, player_id);
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);
set_pev(entity_id, PEV_SLOT, (is_secondary(csw_id) ? 2 : 1));
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);
set_pev(entity_id, pev_rendermode, kRenderFxNone);
set_pev(entity_id, pev_nextthink, get_gametime() + LIFE_AMMO);
}
}
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;
}
bool:is_secondary_csw(const csw_id)
{
static i;
for(i = 0; i < sizeof WEAPONS_SECONDARY_CSW; i++)
{
if(WEAPONS_SECONDARY_CSW[i] == csw_id)
return true;
}
return false;
}
remove_values(const player_id)
{
remove_task(player_id);
player_press_use[player_id] = false;
}
get_active_weapon_csw_id(const player_id)
{
static find_ent_id;
find_ent_id = get_pdata_cbase(player_id, 373, 5);
if(pev_valid(find_ent_id) == 2)
return get_pdata_int(find_ent_id, 43, 4);
return 0;
}
|
|