Raised This Month: $32 Target: $400
 8% 

Supplybox bugging into players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 01-10-2021 , 05:16   Supplybox bugging into players
Reply With Quote #1

hey, the supplybox plugin has a little bug, well... the first round works fine as it should, but after the first round it bugges into players and doesn't spawn the supplyboxes, you can see players on map and the icon above them, especially to zombies. So awkward.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <xs>
#include <zombie_theheroex>

#define PLUGIN "[ZBHeroEX] Addon: Supplybox"
#define VERSION "1.0"
#define AUTHOR "Dias Leon"

#define GAME_LANG LANG_SERVER
#define LANG_FILE "zombie_theheroex.txt"

#define SUPPLY_CLASSNAME "tasukete"
#define SUPPLYBOX_TEAM CS_TEAM_CT
#define TASK_SUPPLYBOX 61296

// Spawn Points
#define MAX_SPAWN_POINT 64
new Float:g_SpawnPoint[MAX_SPAWN_POINT][3], g_SpawnPoint_Count
new const SpawnPoint_URL[] = "%s/supplybox/%s.sb"

new const Ar2_S_SupplyModel[] = "models/zombie_thehero/supplybox.mdl"
new const Ar2_S_Supplybox_Drop[] = "zombie_thehero/supplybox_drop.wav"
new const Ar2_S_Supplybox_Pick[] = "zombie_thehero/supplybox_pickup.wav"
new const g_Supplybox_IconSpr[] = "sprites/zombie_thehero/supplybox_icon.spr"

new g_SupplyIcon
new g_SupplyBox_Countg_RoundEnt[64], g_RoundEnt_CountFloat:g_PlayerIcon[33], Float:g_PlayerIcon2[33]
new 
Float:g_PlayerSpawn_Point[64][3], g_PlayerSpawn_Countg_Supplybox_IconSprID
new g_Cvar_SupplyOng_Cvar_SupplyDropTimeg_Cvar_SupplyPerg_Cvar_SupplyMaxg_Cvar_SupplyIcon
new g_Cvar_OriSource
new g_MsgHostageAddg_MsgHostageDel

// Random Origin Generator
#define SS_VERSION    "1.0"
#define SS_MIN_DISTANCE    500.0
#define SS_MAX_LOOPS    100000

new Array:g_vecSsOrigins
new Array:g_vecSsSpawns
new Array:g_vecSsUsed
new Float:g_flSsMinDist
new g_iSsTime

new const g_szStarts[][] = { "info_player_start""info_player_deathmatch" }
new const 
Float:g_flOffsets[] = { 3500.03500.01500.0 }

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_dictionary(LANG_FILE)
    
    
// R.O.G
    
ROG_SsInit(3500.0);
    
ROG_SsScan(); 
    
ROG_SsDump();
    
    
register_touch(SUPPLY_CLASSNAME"player""fw_SupplyTouch")
    
    
// Collect Spawns Point
    
collect_spawns_ent("info_player_start")
    
collect_spawns_ent("info_player_deathmatch")
    
    
// Supplybox
    
g_Cvar_OriSource register_cvar("zth_supplybox_origin""2"// 0 - Player SPawn | 1 -Auto Detect | 2 - Select Point
    
g_Cvar_SupplyOn register_cvar("zth_supplybox_enable""1")
    
g_Cvar_SupplyDropTime register_cvar("zth_supplybox_droptime""30")
    
g_Cvar_SupplyPer register_cvar("zth_supplybox_droponce""3")
    
g_Cvar_SupplyMax register_cvar("zth_supplybox_max""12")
    
g_Cvar_SupplyIcon register_cvar("zth_supplybox_icon""0")
    
    
// MSG
    
g_MsgHostageAdd get_user_msgid("HostagePos")
    
g_MsgHostageDel get_user_msgid("HostageK")
    
    
register_clcmd("SB_Panel""Open_SpawnMenu"ADMIN_ADMIN)
}

public 
plugin_precache()
{
    
Load_SpawnPoint()
    
    
precache_model(Ar2_S_SupplyModel)
    
precache_sound(Ar2_S_Supplybox_Drop)
    
precache_sound(Ar2_S_Supplybox_Pick)
    
    
g_Supplybox_IconSprID precache_model(g_Supplybox_IconSpr)
}

public 
zbheroex_round_new() 
{
    
remove_task(TASK_SUPPLYBOX)
    
remove_entity_name(SUPPLY_CLASSNAME)
    
g_SupplyIcon get_pcvar_num(g_Cvar_SupplyIcon)
}

public 
zbheroex_game_start()
{
    
remove_task(TASK_SUPPLYBOX)
    
set_task(get_pcvar_float(g_Cvar_SupplyDropTime), "SupplyBox_Drop"TASK_SUPPLYBOX__"b")
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id))
        return
    if(!
zbheroex_get_user_zombie(id))
    {
        if(
g_SupplyIcon)
        {
            if((
g_PlayerIcon[id] + 0.05) < get_gametime())
            {
                if(
g_SupplyBox_Count)
                {
                    for(new 
0g_RoundEnt_Counti++)
                        
Show_OriginIcon(idg_RoundEnt[i], g_Supplybox_IconSprID)
                }
                
                
g_PlayerIcon[id] = get_gametime()
            }
            
            if(
get_gametime() - 1.0 g_PlayerIcon2[id])
            {
                if(
g_SupplyBox_Count)
                {
                    static 
iNext1Next 0
                    
while(<= g_RoundEnt_Count)
                    {
                        
Next g_RoundEnt[i]
                        if(
pev_valid(Next))
                        {
                            static 
Float:Origin[3]
                            
pev(Nextpev_originOrigin)
                            
                            
message_begin(MSG_ONE_UNRELIABLEg_MsgHostageAdd, {0,0,0}, id)
                            
write_byte(id)
                            
write_byte(i)        
                            
write_coord(FloatToNum(Origin[0]))
                            
write_coord(FloatToNum(Origin[1]))
                            
write_coord(FloatToNum(Origin[2]))
                            
message_end()
                        
                            
message_begin(MSG_ONE_UNRELIABLEg_MsgHostageDel, {0,0,0}, id)
                            
write_byte(i)
                            
message_end()
                        }
                    
                        
i++
                    }
    
                }
                
                
g_PlayerIcon2[id] = get_gametime()
            }
        }
    }
}

public 
Show_OriginIcon(idEntSpriteID// By sontung0
{
    if (!
pev_valid(Ent)) 
        return
    
    static 
Float:fMyOrigin[3]; pev(idpev_originfMyOrigin)
    
    static 
TargetTarget Ent
    
static Float:fTargetOrigin[3]; pev(Targetpev_originfTargetOrigin)
    
fTargetOrigin[2] += 40.0
    
    
if(!is_in_viewcone(idfTargetOrigin)) 
        return

    static 
Float:fMiddle[3], Float:fHitPoint[3]
    
xs_vec_sub(fTargetOriginfMyOriginfMiddle)
    
trace_line(-1fMyOriginfTargetOriginfHitPoint)
                            
    static 
Float:fWallOffset[3], Float:fDistanceToWall
    fDistanceToWall 
vector_distance(fMyOriginfHitPoint) - 10.0
    normalize
(fMiddlefWallOffsetfDistanceToWall)
    
    static 
Float:fSpriteOffset[3]; xs_vec_add(fWallOffsetfMyOriginfSpriteOffset)
    static 
Float:fScalefScale 0.01 fDistanceToWall
    
    
static scalescale floatround(fScale)
    
scale max(scale1)
    
scale min(scale2// SIZE = 2
    
scale max(scale1)

    
message_begin(MSG_ONE_UNRELIABLESVC_TEMPENTITY_id)
    
write_byte(TE_SPRITE)
    
engfunc(EngFunc_WriteCoordfSpriteOffset[0])
    
engfunc(EngFunc_WriteCoordfSpriteOffset[1])
    
engfunc(EngFunc_WriteCoordfSpriteOffset[2])
    
write_short(SpriteID)
    
write_byte(scale
    
write_byte(250)
    
message_end()
}

public 
SupplyBox_Drop()
{
    if(!
get_pcvar_num(g_Cvar_SupplyOn))
    {
        
remove_task(TASK_SUPPLYBOX)
        return
    }
    
    for(new 
0get_pcvar_num(g_Cvar_SupplyPer); i++)
    {
        if(
g_SupplyBox_Count >= get_pcvar_num(g_Cvar_SupplyMax))
            return
        
        
SupplyBox_Create()
    }
    
    
// Play Sound
    
for(new id 0id get_maxplayers(); id++)
    {
        if(!
is_user_alive(id))
            continue
        if(!(
cs_get_user_team(id) & SUPPLYBOX_TEAM))
            continue
            
        
PlaySound(idAr2_S_Supplybox_Drop)
        
client_print(idprint_center"Supplies have been dropped!")
    }
}

public 
SupplyBox_Create()
{
    static 
Float:Origin[3]

    switch(
get_pcvar_num(g_Cvar_OriSource))
    {
        case 
1:
        {
            if(
ROG_SsGetOrigin(Origin))
            {
                static 
SupplySupply create_entity("info_target")
                
                
set_pev(Supplypev_classnameSUPPLY_CLASSNAME)
                
engfunc(EngFunc_SetModelSupplyAr2_S_SupplyModel)
            
                
engfunc(EngFunc_SetSizeSupplyFloat:{-10.0,-10.0,0.0}, Float:{10.0,10.0,6.0})
                
                
set_pev(Supplypev_solidSOLID_TRIGGER)
                
set_pev(Supplypev_movetypeMOVETYPE_TOSS)
            
                
Origin[2] += 8.0
                engfunc
(EngFunc_SetOriginSupplyOrigin)
                
                
g_SupplyBox_Count++
                
g_RoundEnt[g_RoundEnt_Count] = Supply
                g_RoundEnt_Count
++
            }
        }
        case 
2:
        {
            static 
SupplySupply create_entity("info_target")
            
            
set_pev(Supplypev_classnameSUPPLY_CLASSNAME)
            
engfunc(EngFunc_SetModelSupplyAr2_S_SupplyModel)
        
            
engfunc(EngFunc_SetSizeSupplyFloat:{-10.0,-10.0,0.0}, Float:{10.0,10.0,6.0})
            
            
set_pev(Supplypev_solidSOLID_TRIGGER)
            
set_pev(Supplypev_movetypeMOVETYPE_TOSS)
        
            static RETURN; RETURN = 
Do_Random_Spawn(Supply)
            if(!RETURN)
            {
                
remove_entity(Supply)
                return
            }
        
            
pev(Supplypev_originOrigin)
            
Origin[2] += 8.0
            engfunc
(EngFunc_SetOriginSupplyOrigin)
            
            
g_SupplyBox_Count++
            
g_RoundEnt[g_RoundEnt_Count] = Supply
            g_RoundEnt_Count
++
        }
        default:
        {
            static 
SupplySupply create_entity("info_target")
            
            
set_pev(Supplypev_classnameSUPPLY_CLASSNAME)
            
engfunc(EngFunc_SetModelSupplyAr2_S_SupplyModel)
        
            
engfunc(EngFunc_SetSizeSupplyFloat:{-10.0,-10.0,0.0}, Float:{10.0,10.0,6.0})
            
            
set_pev(Supplypev_solidSOLID_TRIGGER)
            
set_pev(Supplypev_movetypeMOVETYPE_TOSS)
        
            
Origin[2] += 8.0
            engfunc
(EngFunc_SetOriginSupplyOrigin)
            
            
g_SupplyBox_Count++
            
g_RoundEnt[g_RoundEnt_Count] = Supply
            g_RoundEnt_Count
++
            
            
Ent_SpawnRandom(Supply)
        }
    }
}

public 
Ent_SpawnRandom(id)
{
    if (!
g_PlayerSpawn_Count)
        return;    
    
    static 
hullsp_indexi
    
    hull 
HULL_HUMAN
    sp_index 
random_num(0g_PlayerSpawn_Count 1)
    
    for (
sp_index 1/*no condition*/i++)
    {
        if(
>= g_PlayerSpawn_Count0
        
        
if(is_hull_vacant(g_PlayerSpawn_Point[i], hull))
        {
            
engfunc(EngFunc_SetOriginidg_PlayerSpawn_Point[i])
            break
        }

        if (
== sp_index) break
    }
}

public 
fw_SupplyTouch(Entid)
{
    if(!
pev_valid(Ent))
        return
    if(!
is_user_alive(id))
        return
    if(
zbheroex_get_user_zombie(id) || zbheroex_get_user_hero(id))
        return

    if(
get_user_button(id) & IN_USE)
    {
        
// Effect & Sound
        
emit_sound(idCHAN_ITEMAr2_S_Supplybox_PickVOL_NORMATTN_NORM0PITCH_NORM)
        
        
zbheroex_open_weaponmenu(id)
            
        for(new 
0g_RoundEnt_Counti++)
        {
            if(
g_RoundEnt[i] == Ent)
                
g_RoundEnt[i] = -1
        
}
            
        
g_SupplyBox_Count--
        
set_pev(Entpev_flagsFL_KILLME)
        
set_pev(Entpev_nextthinkget_gametime() + 0.01)
    }
    else 
client_print(idprint_center"Press E while on Supplybox to open it.")
}

stock normalize(Float:fIn[3], Float:fOut[3], Float:fMul// By sontung0
{
    static 
Float:fLenfLen xs_vec_len(fIn)
    
xs_vec_copy(fInfOut)
    
    
fOut[0] /= fLenfOut[1] /= fLenfOut[2] /= fLen
    fOut
[0] *= fMulfOut[1] *= fMulfOut[2] *= fMul
}

stock collect_spawns_ent(const classname[])
{
    static 
entent = -1
    
while ((ent engfunc(EngFunc_FindEntityByStringent"classname"classname)) != 0)
    {
        
// get origin
        
static Float:originF[3]
        
pev(entpev_originoriginF)
        
        
g_PlayerSpawn_Point[g_PlayerSpawn_Count][0] = originF[0]
        
g_PlayerSpawn_Point[g_PlayerSpawn_Count][1] = originF[1]
        
g_PlayerSpawn_Point[g_PlayerSpawn_Count][2] = originF[2]
        
        
// increase spawn count
        
g_PlayerSpawn_Count++
        if(
g_PlayerSpawn_Count >= sizeof g_PlayerSpawn_Point) break;
    }
}

stock PlaySound(id, const sound[])
{
    if(
equal(sound[strlen(sound)-4], ".mp3")) client_cmd(id"mp3 play ^"sound/%s^""sound)
    else 
client_cmd(id"spk ^"%s^""sound)
}

stock is_hull_vacant(Float:Origin[3], hull)
{
    
engfunc(EngFunc_TraceHullOriginOrigin0hull00)
    
    if (!
get_tr2(0TR_StartSolid) && !get_tr2(0TR_AllSolid) && get_tr2(0TR_InOpen))
        return 
true
    
    
return false
}

stock FloatToNum(Float:floatn)
{
    new 
str[64], num
    float_to_str
(floatnstr63)
    
num str_to_num(str)
    
    return 
num
}

// =========================== Random Origin Generator =============================
// =================================================================================
public ROG_SsInit(Float:mindist)
{
    new 
cmd[32]
    
format(cmd15"_ss_dump%c%c%c%c"random_num('A''Z'), random_num('A''Z'), random_num('A''Z'), random_num('A''Z'))
    
register_cvar("sv_rog"SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY))
    
register_concmd(cmd"ROG_SsDump")

    
g_flSsMinDist mindist
    g_vecSsOrigins 
ArrayCreate(31)
    
g_vecSsSpawns ArrayCreate(31)
    
g_vecSsUsed ArrayCreate(31)
}

stock ROG_SsClean()
{
    
g_flSsMinDist 0.0
    ArrayClear
(g_vecSsOrigins)
    
ArrayClear(g_vecSsSpawns)
    
ArrayClear(g_vecSsUsed)
}

stock ROG_SsGetOrigin(Float:origin[3])
{
    new 
Float:data[3], size
    
new ok 1

    
while((size ArraySize(g_vecSsOrigins)))
    {
        new 
idx random_num(0size 1)

        
ArrayGetArray(g_vecSsOriginsidxorigin)

        new 
used ArraySize(g_vecSsUsed)
        for(new 
0usedi++)
        {
            
ok 0
            ArrayGetArray
(g_vecSsUsedidata)
            if(
get_distance_f(dataorigin) >= g_flSsMinDist)
            {
                
ok 1
                
break
            }
        }

        
ArrayDeleteItem(g_vecSsOriginsidx)
        if(
ok)
        {
            
ArrayPushArray(g_vecSsUsedorigin)
            return 
true
        
}
    }
    return 
false
}

public 
ROG_SsDump()
{
    new 
count ArraySize(g_vecSsOrigins)
    
server_print("Thanatos System: Found %i Origin(s)!"count)
    
server_print("Thanatos System: Scanning Time %i"g_iSsTime)
}

public 
ROG_SsScan()
{
    new 
startFloat:origin[3], starttime
    starttime 
get_systime()
    for(
start 0start sizeof(g_szStarts); start++)
    {
        
server_print("Thanatos System: Searching for %s"g_szStarts[start])
        new 
ent
        
if((ent engfunc(EngFunc_FindEntityByStringent"classname"g_szStarts[start])))
        {
            new 
counter
            pev
(entpev_originorigin)
            
ArrayPushArray(g_vecSsSpawnsorigin)
            while(
counter SS_MAX_LOOPS)
            {
                
counter ROG_GetLocation(origincounter)
            }
        }
    }
    
g_iSsTime get_systime()
    
g_iSsTime -= starttime
}

ROG_GetLocation(Float:start[3], &counter)
{
    new 
Float:end[3]
    for(new 
03i++)
    {
        
end[i] += random_float(0.0 g_flOffsets[i], g_flOffsets[i])
    }

    if(
ROG_IsValid(startend))
    {
        
start[0] = end[0]
        
start[1] = end[1]
        
start[2] = end[2]
        
ArrayPushArray(g_vecSsOriginsend)
    }
    
counter++
    return 
counter
}

ROG_IsValid(Float:start[3], Float:end[3])
{
    
ROG_SetFloor(end)
    
end[2] += 36.0
    
new point engfunc(EngFunc_PointContentsend)
    if(
point == CONTENTS_EMPTY)
    {
        if(
ROG_CheckPoints(end) && ROG_CheckDistance(end) && ROG_CheckVisibility(startend))
        {
            if(!
trace_hull(endHULL_LARGE, -1))
            {
                return 
true
            
}
        }
    }
    return 
false
}

ROG_CheckVisibility(Float:start[3], Float:end[3])
{
    new 
tr
    engfunc
(EngFunc_TraceLinestartendIGNORE_GLASS, -1tr)
    return (
get_tr2(trTR_pHit) < 0)
}

ROG_SetFloor(Float:start[3])
{
    new 
trFloat:end[3]
    
end[0] = start[0]
    
end[1] = start[1]
    
end[2] = -99999.9
    engfunc
(EngFunc_TraceLinestartendDONT_IGNORE_MONSTERS, -1tr)
    
get_tr2(trTR_vecEndPosstart)
}

ROG_CheckPoints(Float:origin[3])
{
    new 
Float:data[3], trpoint
    data
[0] = origin[0]
    
data[1] = origin[1]
    
data[2] = 99999.9
    engfunc
(EngFunc_TraceLineorigindataDONT_IGNORE_MONSTERS, -1tr)
    
get_tr2(trTR_vecEndPosdata)
    
point engfunc(EngFunc_PointContentsdata)
    if(
point == CONTENTS_SKY && get_distance_f(origindata) < 250.0)
    {
        return 
false
    
}
    
data[2] = -99999.9
    engfunc
(EngFunc_TraceLineorigindataDONT_IGNORE_MONSTERS, -1tr)
    
get_tr2(trTR_vecEndPosdata)
    
point engfunc(EngFunc_PointContentsdata)
    if(
point CONTENTS_SOLID)
        return 
false
    
    
return true
}

ROG_CheckDistance(Float:origin[3])
{
    new 
Float:distFloat:data[3]
    new 
count ArraySize(g_vecSsSpawns)
    for(new 
0counti++)
    {
        
ArrayGetArray(g_vecSsSpawnsidata)
        
dist get_distance_f(origindata)
        if(
dist SS_MIN_DISTANCE)
            return 
false
    
}

    
count ArraySize(g_vecSsOrigins)
    for(new 
0counti++)
    {
        
ArrayGetArray(g_vecSsOriginsidata)
        
dist get_distance_f(origindata)
        if(
dist SS_MIN_DISTANCE)
            return 
false
    
}

    return 
true
}


// =================== Make SpawnPoint =========================
// =============================================================
public Do_Random_Spawn(id)
{
    if (!
g_SpawnPoint_Count)
        return 
0    
    
    
//static Spawn; Spawn = random_num(0, g_SpawnPoint_Count - 1)
    //engfunc(EngFunc_SetOrigin, id, g_SpawnPoint[Spawn])

    
static sp_indexiFloat:Origin[3], YesYes 0
    sp_index 
random_num(0g_SpawnPoint_Count 1)
    
    for (
sp_index 1/*no condition*/i++)
    {
        if(
>= g_SpawnPoint_Count0
        Origin 
g_SpawnPoint[i]
    
        
Origin[2] += 36.0
        
        
if(is_hull_vacant(OriginHULL_HUMAN))
        {
            
engfunc(EngFunc_SetOriginidOrigin)
            
Yes 1
            
break
        }

        if (
== sp_index) break
    }
    
    
    return 
Yes
}

public 
Open_SpawnMenu(id)
{
    if(!
is_user_connected(id))
        return
        
    
// create menu
    
static MenuMenu menu_create("[Supplybox] Spawn Point""MenuHandle_ZSConfig")
    
    
menu_additem(Menu"Add""Add"0)
    
menu_additem(Menu"Save""Save"0)
    
    
menu_display(idMenu0)
}

public 
MenuHandle_ZSConfig(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return
    }
    
    static 
itemid[32], itemname[32], Access
    menu_item_getinfo
(MenuItemAccessitemidcharsmax(itemid), itemnamecharsmax(itemname), Access)
    
    if(
equal(itemid"Add"))
    {
        if(
g_SpawnPoint_Count >= MAX_SPAWN_POINT)
        {
            
client_print(idprint_chat"[RZ] Error: Max Trader Point")
            
Open_SpawnMenu(id)
            return;
        }
        
        static 
Float:Origin[3]; pev(idpev_originOrigin)
        
        
g_SpawnPoint[g_SpawnPoint_Count] = Origin
        g_SpawnPoint_Count
++
        
        
client_print(idprint_chat"[RL] Notice: Added !!!")
    } else if (
equal(itemid"Save")) {
        if (!
g_SpawnPoint_Count)
        {
            
client_print(idprint_chat"[RL] Error: There is no SpawnPoint")
            
Open_SpawnMenu(id)
            return;
        }
    
        
// get url file
        
static cfgdir[32], mapname[32], urlfile[128]
        
        
get_configsdir(cfgdircharsmax(cfgdir))
        
get_mapname(mapnamecharsmax(mapname))
        
formatex(urlfilecharsmax(urlfile), SpawnPoint_URLcfgdirmapname)
    
        
// save file
        
if(file_exists(urlfile)) delete_file(urlfile)
        static 
lineset[128]
        
        for(new 
0g_SpawnPoint_Counti++)
        {
            if(!
g_SpawnPoint[i][0] && !g_SpawnPoint[i][1] && !g_SpawnPoint[i][2]) break;
            
            
format(linesetcharsmax(lineset), "%f %f %f"g_SpawnPoint[i][0], g_SpawnPoint[i][1], g_SpawnPoint[i][2])
            
write_file(urlfilelineseti)
        }
        
        
client_print(idprint_chat"[RL] Notice: Saved !!!")
    }
    
    
// show main menu
    
Open_SpawnMenu(id)
}

public 
Load_SpawnPoint()
{
    
// Check for spawns points of the current map
    
static cfgdir[32], mapname[32], filepath[100], linedata[64], Float:point[3]
    
get_configsdir(cfgdircharsmax(cfgdir))
    
get_mapname(mapnamecharsmax(mapname))
    
formatex(filepathcharsmax(filepath), SpawnPoint_URLcfgdirmapname)
    
    
// check file exit
    
if (!file_exists(filepath))
    {
        
server_print("[RL] Warning: Spawn File Not Found (%s)..."filepath)
        return;
    }
    
    
g_SpawnPoint_Count 0
    
    
// Load spawns points
    
static filerow[3][6]; file fopen(filepath,"rt")
    while (
file && !feof(file))
    {
        
fgets(filelinedatacharsmax(linedata))
        
        
// invalid spawn
        
if(!linedata[0] || str_count(linedata,' ') < 2) continue;
        
        
// get spawn point data
        
parse(linedata,row[0],5,row[1],5,row[2])
        
        
// set spawnst
        
point[0] = str_to_float(row[0])
        
point[1] = str_to_float(row[1])
        
point[2] = str_to_float(row[2])
        
        if(
is_point(point))
        {
            
g_SpawnPoint[g_SpawnPoint_Count][0] = point[0]
            
g_SpawnPoint[g_SpawnPoint_Count][1] = point[1]
            
g_SpawnPoint[g_SpawnPoint_Count][2] = point[2]

            
// increase spawn count
            
g_SpawnPoint_Count ++
            
            if(
g_SpawnPoint_Count >= MAX_SPAWN_POINT) break;
        }
    }
    if (
filefclose(file)
}

str_count(const str[], searchchar)
{
    new 
countilen strlen(str)
    
    for (
0<= leni++)
    {
        if(
str[i] == searchchar)
            
count++
    }
    
    return 
count;
}

is_point(Float:point[3])
{
    if (!
point[0] && !point[1] && !point[2]) return 0
    
return 1
}

stock get_can_see(Float:start[3], Float:end[3])
{
    static 
ptrptr create_tr2()
    
engfunc(EngFunc_TraceLinestartendIGNORE_GLASS IGNORE_MONSTERS IGNORE_MISSILE, -1ptr)
        
    static 
fraction
    get_tr2
(ptrTR_flFractionfraction)
        
    
// Free the trace handle (don't forget to do this!)
    
free_tr2(ptr)
        
    
// If = 1.0 then it didn't hit anything!
    
return (fraction != 1.0


Last edited by AnimalMonster; 01-10-2021 at 05:18.
AnimalMonster is offline
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 08:09.


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