Raised This Month: $51 Target: $400
 12% 

client_print


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 01-03-2020 , 16:29   client_print
Reply With Quote #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_idplayer_id)
{
    if(!(
pev(entity_idpev_flags) & FL_ONGROUND) || !get_player_status(player_id))
        return 
PLUGIN_HANDLED;

    if(
pev(entity_idPEV_OWNER) != player_id)
    {
        static 
csw_idplus_bpammo;
        
        
csw_id     get_active_weapon_csw_id(player_id);
        if(
csw_id && csw_id != CSW_KNIFE)
        {
            if(
is_secondary(pev(entity_idPEV_CSW)) != is_secondary_csw(csw_id))
                        {
                                
client_print(player_idprint_center"Эти Патроны не подходят к Вашему Оружию");
                return 
PLUGIN_HANDLED;
                        }
            
            
plus_bpammo pev(entity_idPEV_PLUS_AMMO);

            
cs_set_user_bpammo(player_idcsw_idcs_get_user_bpammo(player_idcsw_id)+plus_bpammo);

            
client_cmd(player_id,"spk %s",ammo_sound)
            
screen_fade(player_id)

            
client_print(player_idprint_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_DEAGLECSW_FIVESEVENCSW_GLOCK18CSW_P228CSW_USPCSW_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(PLUGINVERSIONAUTHOR);
    
    new 
i,
        
count sizeof(WEAPONS_CLASSNAME);
    for(
0counti++)
        
RegisterHam(Ham_Weapon_ReloadWEAPONS_CLASSNAME[i], "ham_weapon_reload"true);
    for(
0counti++)
        
RegisterHam(Ham_Item_DeployWEAPONS_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(
133i++)
    {
        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_handleUC_Buttons);
    
old_buttons pev(player_idpev_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_ONEg_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_idplayer_id)
{
    if(!(
pev(entity_idpev_flags) & FL_ONGROUND) || !get_player_status(player_id))
        return 
PLUGIN_HANDLED;

    if(
pev(entity_idPEV_OWNER) != player_id)
    {
        static 
csw_idplus_bpammo;
        
        
csw_id     get_active_weapon_csw_id(player_id);
        if(
csw_id && csw_id != CSW_KNIFE)
        {
            if(
is_secondary(pev(entity_idPEV_CSW)) != is_secondary_csw(csw_id))
                        {
                                
client_print(player_idprint_center"Эти Патроны не подходят к Вашему Оружию");
                return 
PLUGIN_HANDLED;
                        }
            
            
plus_bpammo pev(entity_idPEV_PLUS_AMMO);

            
cs_set_user_bpammo(player_idcsw_idcs_get_user_bpammo(player_idcsw_id)+plus_bpammo);

            
client_cmd(player_id,"spk %s",ammo_sound)
            
screen_fade(player_id)

            
client_print(player_idprint_center"Вы взяли +%d патронов"plus_bpammo);

            
remove_entity(entity_id);
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
ThinkAmmo(entity)    {
    if (!
pev_valid(entity)) {
        return 
HAM_IGNORED;
    }
    
    switch(
pev(entitypev_impulse))    {
        case 
STATUS_NONE:{
            
set_pev(entitypev_movetypeMOVETYPE_FLY);
            
set_pev(entitypev_solidSOLID_NOT);
            
set_pev(entitypev_rendermodekRenderTransAlpha);
            
            
set_pev(entitypev_renderamt100.0);
            
set_pev(entitypev_velocityFloat:{0.00.0VERTICAL_SPEED});
            
set_pev(entitypev_avelocityFloat:{0.0HORISONTAL_SPEED0.0})
            
set_pev(entitypev_impulseSTATUS_EFFECT);        
        }
        case 
STATUS_EFFECT:    {
            if (
pev(entitypev_renderamt) > 0.0) {
                
set_pev(entitypev_renderamtfloatmax(0.0pev(entitypev_renderamt) - STEP));
            } else {
                
set_pev(entitypev_flagsFL_KILLME);
                
set_pev(entitypev_impulseSTATUS_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_idpev_owner);
    
    if(
get_player_status(player_id))
        
remove_task(player_id);
}

public 
ham_weapon_reload(const weapon_id)
{
    static 
player_idparam[5], iweapon_classname[64], Float:sec_next_attack;

    if(!
is_valid_ent(weapon_id))
        return;
    
    if(
get_pdata_int(weapon_idOFFSET_IN_RELOADOFFSET_LINUX_WEAPONS))
    {
        
arrayset(param, -15);

        
player_id pev(weapon_idpev_owner);
        
        
pev(weapon_idpev_classnameweapon_classname63);

        if(
get_player_status(player_id))
        {
            
sec_next_attack get_pdata_float(player_idOFFSET_NEXT_ATTACKOFFSET_LINUX);
            if(
sec_next_attack <= 0.0)
                return;
            for(
0sizeof(WEAPONS_CSW); i++)
            {
                if(
equali(WEAPONS_CLASSNAME[i], weapon_classname))
                {
                    
param[0] = i;
                    break;
                }
            }

            
param[1] = weapon_id;
            
param[2] = get_pdata_int(weapon_idOFFSET_CLIP_AMMOOFFSET_LINUX_WEAPONS);

            if(
param[0] != -&& param[2] < WEAPONS_CLIP[i] && param[2] > 0)
            {
                
param[4] = cs_get_user_bpammo(player_idWEAPONS_CSW[i]);
                
param[3] = ((param[4] < WEAPONS_CLIP[i]) ? param[4] : -1);
                
param[4] = ((param[4] <= WEAPONS_CLIP[i]) ? : (param[4]-WEAPONS_CLIP[i]));
                if(
param[4] >= 0)
                {
                    
param[4] = WEAPONS_CLIP[i];
                    
set_task(sec_next_attack+0.1"reload_task"player_idparam5);
                }
            }
        }
    }
}
public 
reload_task(param[], player_id)
{
    static 
weapon_idcsw_idclipsetclipminusbpammoentity_idFloat:player_origin[3];
    
    if(
param[0] == -|| param[1] == -|| param[2] == -|| 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_idOFFSET_CLIP_AMMOsetclipOFFSET_LINUX_WEAPONS);
    
    
minusbpammo -= (WEAPONS_CLIP[csw_id]-clip);
    
cs_set_user_bpammo(player_idWEAPONS_CSW[csw_id], cs_get_user_bpammo(player_idWEAPONS_CSW[csw_id])-minusbpammo);

    
entity_id 0;
    
entity_id create_entity("info_target");
    if(
entity_id)
    {
        
pev(player_idpev_originplayer_origin);

        
set_pev(entity_idPEV_OWNERplayer_id);
        
set_pev(entity_idpev_classnameclassname_entity);
        
        
engfunc(EngFunc_SetModelentity_id, (is_secondary(csw_id) ? model_secondary model_primary));
        
        
set_pev(entity_idpev_solidSOLID_TRIGGER);
        
set_pev(entity_idpev_movetypeMOVETYPE_TOSS);
        
        
engfunc(EngFunc_SetSizeentity_idFloat:{ -4.0, -4.0, -4.0 }, Float:{ 4.04.04.0 });
        
engfunc(EngFunc_SetOriginentity_idplayer_origin);

        
set_pev(entity_idPEV_CSWcsw_id);
        
set_pev(entity_idPEV_PLUS_AMMOclip);
        
set_pev(entity_idPEV_SLOT, (is_secondary(csw_id) ? 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_idpev_velocityvelocity);
                
set_pev(entity_idpev_rendermodekRenderFxNone);
                
set_pev(entity_idpev_nextthinkget_gametime() + LIFE_AMMO);
    }
}

get_player_status(const player_id)
{
    if(
player_id && 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(
0sizeof WEAPONS_SECONDARYi++)
    {
        if(
equali(WEAPONS_SECONDARY[i], WEAPONS_CLASSNAME[csw_id]))
            return 
true;
    }
    return 
false;
}
bool:is_secondary_csw(const csw_id)
{
    static 
i;
    
    for(
0sizeof WEAPONS_SECONDARY_CSWi++)
    {
        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_id3735);
    
    if(
pev_valid(find_ent_id) == 2)
        return 
get_pdata_int(find_ent_id434);
    return 
0;

MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode