AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Ent has null Private Data | Array not being read (https://forums.alliedmods.net/showthread.php?t=309727)

edon1337 08-05-2018 08:36

Ent has null Private Data | Array not being read
 
I'm getting
PHP Code:

[HAMSANDWICHEntity has null private data 

Everytime on this line
PHP Code:

ExecuteHamBHam_SpawnWeaponEntity ); 

I tried everything, made sure every weapon name is being parsed into the array correctly, made sure to use pev_valid == 2 (entity valid + entity valid for private data usage), BUT STILL, I keep getting this... What is this error ?

PHP Code:

#include <     amxmodx                          >
#include <     amxmisc                          >
#include <     cstrike                          >
#include <     hamsandwich                      >
#include <     fakemeta                         >
#include <     fun                              >
#include <     rog                              >
#include <     stripweapons                     >
#include <     cs_battleroyale_faketeams        >
#include <     cs_battleroyale_roundmanager     >
#include <     orpheu                           >
#include <     orpheu_advanced                  >

#define VERSION "1.2"

#if AMXX_VERSION_NUM >= 182
#define CSW_GLOCK 2
#endif

//#define DUMP_ORIGIN_DATA

#define DEFAULT_MAXSPEED   250.0
#define DEFAULT_GRAVITY    1.0

#define MAX_ORIGINS 100

#define AIRDROP_CLASSNAME  "ent_airdrop"
#define AIRPLANE_CLASSNAME "ent_airplane"

enum
{
    
VIEW_NONE,
    
VIEW_3RDPERSON
};

enum ( += 8764 )
{
    
TASK_PARACHUTE_DEPLOY 6436,
    
TASK_AIRDROP,
    
TASK_AIRDROP_AFK
};

enum 
{
    
deploy,
    
idle,
    
detach
};

enum _:AirDropData
{
    
AirDrop_Model_Flying128 ],
    
AirDrop_Model_Ground128 ]
};

enum _:AirPlaneData
{
    
AirPlane_Model128 ]
};

enum
{
    
RARITY_GREY 1,
    
RARITY_GREEN,
    
RARITY_BLUE,
    
RARITY_PURPLE,
    
RARITY_GOLD
};

enum _:WeaponData
{
    
Weapon_Name32 ],
    
Weapon_Rarity
};

enum _:SoundEffects
{
    
Parachute_Deploy_Sound128 ],
    
Landing_Sound128 ],
    
AirDrop_Appear_Sound128 ],
    
AirDrop_Land_Sound128 ]
};

enum _:AmmoIndexData
{
    
AmmoIndex,
    
AmmoCount
};

new 
g_iSprite;
new 
g_iAirDrops;
new 
g_iSpriteIndexExplosion;
new 
g_iAirPlaneEnt;
new 
g_iDummyResult;

new 
g_iFwOpenAirDrop;
new 
g_iFwJumpPlane;
new 
g_iFwUrgentJumpPlane;
new 
g_iFwDeployParachute;

new 
Float:g_fCachedParachuteVelocity;
new 
Float:g_fCachedAirDropVelocity;

new 
IntClassNameString;
new 
OrpheuFunction:HandleCreateNamedEntityFunc;
new 
OrpheuFunction:HandlePackWeaponFunc;
new 
CWeaponBoxKill_Address;

new 
g_iDataAirDropAirDropData ];
new 
g_iDataAirPlaneAirPlaneData ];
new 
g_iSoundsSoundEffects ];
new 
g_eAmmoIndex31 ][ AmmoIndexData ];

new 
g_iPlayerView33 ];
new 
g_iCvars10 ];
new 
g_IntAmmoNames16 ];

new 
bool:g_bPlayerInPlane33 ];
new 
bool:g_bIsPlayerInParachute33 ];
new 
bool:g_bLandedPlayer33 ];

new const 
g_szGameSounds[ ]  = "GameSounds.ini";
new const 
g_szGameModels[ ]  = "GameModels.ini";
new const 
g_szGameWeapons[ ] = "GameWeapons.ini";

new const 
g_szValues[ ][ ] =
{
    
"RARITY_GREY",
    
"RARITY_GREEN",
    
"RARITY_BLUE",
    
"RARITY_PURPLE",
    
"RARITY_GOLD"
};

new const 
g_iValues[ ] =
{
    
RARITY_GREY,
    
RARITY_GREEN,
    
RARITY_BLUE,
    
RARITY_PURPLE,
    
RARITY_GOLD
};

new const 
g_szPossibleAirDropWeapons[ ] =
{
    
CSW_M249,
    
CSW_AWP,
    
CSW_G3SG1,
    
CSW_SG550
}

new Array:
g_aWeaponData;
new 
Trie:g_tRarityTrie;

new const 
g_szMaxBpAmmo[ ] =
{ -
152, -1901321100901120100100909090100120,
    
301202003290120902359090, -1100
};

new const 
g_szAmmoType[ ][ ] =
"""357sig""""762nato""""buckshot""""45acp""556nato""""9mm""57mm""45acp",
    
"556nato""556nato""556nato""45acp""9mm""338magnum""9mm""556natobox""buckshot",
    
"556nato""9mm""762nato""""50ae""556nato""762nato""""57mm"
};

new const 
WeaponBoxModels[ ][ ] = 

    
"""models/w_p228.mdl",  ""
    
"models/w_scout.mdl",  "models/w_hegrenade.mdl""models/w_xm1014.mdl"
    
"""models/w_mac10.mdl""models/w_aug.mdl""models/w_smokegrenade.mdl"
    
"models/w_elite.mdl""models/w_fiveseven.mdl",  "models/w_ump45.mdl",  
    
"models/w_sg550.mdl""models/w_galil.mdl",  "models/w_famas.mdl",  
    
"models/w_usp.mdl""models/w_glock18.mdl""models/w_awp.mdl",  
    
"models/w_mp5.mdl""models/w_m249.mdl",  "models/w_m3.mdl"
    
"models/w_m4a1.mdl""models/w_tmp.mdl""models/w_g3sg1.mdl",  
    
"models/w_flashbang.mdl""models/w_deagle.mdl""models/w_sg552.mdl""models/w_ak47.mdl"
    
"""models/w_p90.mdl",  """" 
};

new const 
g_szForbiddenWeapons[ ][ ] =
{
    
"weapon_c4",
    
"weapon_knife",
    
"weapon_kevlar"
};

new const 
m_rgpPlayerItems_CWeaponBox] = { 3435, ... }; 

new const 
g_szStringAmmoNames[ ][ ] = 
{
    
""
    
"338Magnum"
    
"762Nato",
    
"556NatoBox"
    
"556Nato",
    
"buckshot"
    
"45ACP"
    
"57mm"
    
"50AE"
    
"357SIG",
    
"9mm"
    
"Flashbang",
    
"HEGrenade"
    
"SmokeGrenade"
    
"C4"
};

new 
OrpheuFunction:HandlePackAmmoFunc;

const 
XO_CWEAPONBOX 4;
const 
m_iId 43;
const 
m_pfnThink =  4;
const 
m_iType 34;
const 
m_iCount 35;
const 
m_bHasPrimary 116;
const 
m_pActiveItem  373;

new const 
SKIP_THESE_WEAPONS = ( ( << CSW_KNIFE ) | ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) | ( << CSW_GLOCK ) );

public 
plugin_init( )
{
    
register_plugin"CS Battle Royale Core"VERSION"DoNii" );
    
    
register_dictionary"cs_battleroyale.txt" );
    
    
register_cvar"cs_battleroyale_version"VERSIONFCVAR_SERVER FCVAR_SPONLY FCVAR_UNLOGGED );
    
    
ROGInitialize500.0"CheckOrigin" );
    
    
#if defined DUMP_ORIGIN_DATA
    
ROGDumpOriginData( );
    
#endif
    
    
register_messageget_user_msgid"StatusIcon" ), "OnMessageStatusIcon" ); // Hook StatusIcon
    
    
set_msg_blockget_user_msgid"Radar" ), BLOCK_SET ); // Block radar, we don't want players cheating
    
    // Orpheu
    
IntClassNameString engfuncEngFunc_AllocString"weaponbox" ); // Allocate weaponbox ent
    
    
HandleCreateNamedEntityFunc OrpheuGetFunction"CREATE_NAMED_ENTITY" );
    
HandlePackWeaponFunc OrpheuGetFunction"PackWeapon""CWeaponBox" );
    
    
CWeaponBoxKill_Address OrpheuGetFunctionAddressOrpheuGetFunction"Kill""CWeaponBox" ) );
    
HandlePackAmmoFunc OrpheuGetFunction"PackAmmo""CWeaponBox" );
    
    
// cvars
    
g_iCvars]  =  register_cvar"csbr_parachute_deploy_time""1.0" );      // time to deploy parachute after spawning ( seconds)
    
g_iCvars]  =  register_cvar"csbr_parachute_fall_speed""-250.0" );     // player parachute fall speed
    
g_iCvars]  =  register_cvar"csbr_camera_switch""1" );                // allow camera switch
    
g_iCvars]  =  register_cvar"csbr_airdrop_freq_min""15.0" );          // minimum time of an airdrop
    
g_iCvars]  =  register_cvar"csbr_airdrop_freq_max""30.0" );          // maximum time of an airdrop, ex: 180.0, 360.0 --> random_float(  180.0, 360.0 )
    
g_iCvars]  =  register_cvar"csbr_airdrop_count""3" );                // number of airdrops in 1 round
    
g_iCvars]  =  register_cvar"csbr_airdrop_velocity""-50.0" );         // airdrop fall velocity
    
g_iCvars]  =  register_cvar"csbr_airdrop_open_distance""100.0" );    // distance to allow opening of airdrop
    
g_iCvars]  =  register_cvar"csbr_airplane_disappear_time""20.0" );   // time task for the airplane to disappear
    
g_iCvars]  =  register_cvar"csbr_glow_extra_damage""2" );            // extra damage to give to each glow
    
    // register_logevent FORWARDS
    
register_logevent"OnRoundStart"2"1=Round_Start" ); // hook round start
    
    // HAM FORWARDS
    
RegisterHamHam_TakeDamage"player""@HamTakeDamage_Pre");
    
RegisterHamHam_Player_ImpulseCommands"player""@HamPlayerImpulseCommands_Pre");
    
RegisterHamHam_Player_Jump"player""@HamPlayerJump_Post");
    
RegisterHamHam_Spawn"player""@HamSpawn_Post");
    
    
// FM FORWARDS    
    
register_forwardFM_CmdStart"@CmdStart" );
    
register_forwardFM_SetModel"@SetModel" );
    
register_forwardFM_AddToFullPack"@AddToFullPack_Post");
    
    
// Engine FORWARDS
    
register_thinkAIRDROP_CLASSNAME"@AirDropThink" ); // make airdrop think
    
    // Remove Armoury
    
remove_entity_name"armoury_entity" ); // remove all armoury_entity in the map
    
    
g_iFwOpenAirDrop       =   CreateMultiForward"PlayerOpenAirDrop",     ET_IGNOREFP_CELLFP_CELL );
    
g_iFwJumpPlane         =   CreateMultiForward"PlayerJumpPlane",       ET_IGNOREFP_CELL          );
    
g_iFwUrgentJumpPlane   =   CreateMultiForward"PlayerUrgentJump",      ET_IGNOREFP_CELL          );
    
g_iFwDeployParachute   =   CreateMultiForward"PlayerDeployParachute"ET_IGNOREFP_CELL          );
}

public 
plugin_precache( )
{
    
g_aWeaponData ArrayCreateWeaponData ); // create array for weapons
    
g_tRarityTrie TrieCreate( ); // create trie -> int map
    
    
RemoveObjectives( );
    
    
RegisterWeaponList( .id get_user_msgid"WeaponList" ) );
    
    new 
i;
    for( 
0sizeof g_szValuesi++ )
    {
        
TrieSetCellg_tRarityTrieg_szValues], g_iValues] ); // assign int values to trie
    
}
    
    for( 
1sizeof g_szStringAmmoNamesi++)
    {
        
g_IntAmmoNames] = engfuncEngFunc_AllocStringg_szStringAmmoNames] ); // allocate ammo names
    
}
    
    
precache_model"models/rpgrocket.mdl" ); // needed for camera view, server will crash without precaching it
    
    
g_iSpriteIndexExplosion precache_model"sprites/zerogxplode.spr" ); // airdrop explosion effect
    
g_iSprite precache_model"sprites/Arrow_Icon.spr" ); // arrow icon to show on teammates head
    
    
ReadModels( ); // read our models
    
ReadSounds( ); // read our sounds
    
log_to_file"DebugWeapons.txt""Reading started" );
    
ReadWeapons( ); // read our weapons
}

public 
CheckOriginFloat:fOrigin] )
{
    if( 
fOrigin] < -425.0 // we don't want our entities to be spawned in the under-ground area
    
{
        return 
0;
    }
    return 
1;
}

@
RegUserMsg( const szName[ ], const iSize )
{
    if( 
equalszName"WeaponList" ) )
    {
        
RegisterWeaponList( .id get_orig_retval( ) );
    }
}

RegisterWeaponList( const id )
{
    static 
iForwardHandle = -1;

    if( ! 
id )
    {
        
iForwardHandle register_forwardFM_RegUserMsg"@RegUserMsg", ._post true );
        return;
    }

    if( 
iForwardHandle != -)
    {
        
unregister_forwardFM_RegUserMsgiForwardHandle, .post true );
    }

    
register_messageid"@OnMessageWeaponList" );
}

@
OnMessageWeaponList( const iMsgId, const iMsgType, const iEnt )
{
    new 
iAmmoIndex get_msg_arg_int); // get ammo index
    
new iAmmoCount get_msg_arg_int); // get ammo count
    
new iWeaponID get_msg_arg_int);  // get weapon id
    
    
g_eAmmoIndexiWeaponID ][ AmmoIndex ] = iAmmoIndex// save ammo index
    
g_eAmmoIndexiWeaponID ][ AmmoCount ] = iAmmoCount// save ammo count
}

@
HamPlayerJump_Postid // player jump
{
    if( ! 
g_bPlayerInPlaneid ] ) // if hes not in airplane, no need to continue
    
return HAM_IGNORED;

    
set_pevidpev_solidSOLID_SLIDEBOX ); // set player solidity to default
    
set_pevidpev_movetypeMOVETYPE_TOSS ); // set player movetype to default
    
    
g_bPlayerInPlaneid ] = false// player left plane
    
g_bIsPlayerInParachuteid ] = true// player is in parachute now
    
    
set_user_renderingid ); // reset his rendering (make him visible)
    
    
set_pevidpev_gravityDEFAULT_GRAVITY ); // reset his gravity to default
    
set_user_maxspeedidDEFAULT_MAXSPEED );   // reset his speed to default
    
    
g_iPlayerViewid ] = VIEW_NONE// reset player camera view

    
set_pevidpev_sequencedeploy ); // make new sequence
    
    
set_taskget_pcvar_floatg_iCvars] ), "OnDeployParachute"id+TASK_PARACHUTE_DEPLOY ); // task for parachute
    
client_cmdid"spk sound/%s"g_iSoundsParachute_Deploy_Sound ] ); // emit parachute deploy sound
    
    
ExecuteForwardg_iFwJumpPlaneg_iDummyResultid );
    
    return 
HAM_IGNORED;
}

@
AddToFullPack_PostES_HandleEiEntiHostiHostFlagsiPlayeriSet)
{
    if( ! 
is_user_aliveiEnt ) || ! is_user_aliveiHost ) )
    return 
FMRES_IGNORED;
    
    if( 
GetPlayerTeamiEnt ) == GetPlayerTeamiHost ) && ( iEnt != iHost ) ) // check if the player in sight is our teammate and is not the host himself
    
{
        
message_beginMSG_ONE_UNRELIABLESVC_TEMPENTITY_iHost )
        
write_byteTE_PLAYERATTACHMENT );
        
write_byteiEnt );
        
write_coord45 );
        
write_shortg_iSprite ); 
        
write_short20 );
        
message_end( ); 
    }
    return 
FMRES_IGNORED;
}  

public 
OnDeployParachuteid )
{
    
id -= TASK_PARACHUTE_DEPLOY;

    
g_bIsPlayerInParachuteid ] = true;
    
ExecuteForwardg_iFwDeployParachuteg_iDummyResultid );
    
    
remove_taskid TASK_PARACHUTE_DEPLOY );
}

@
HamSpawn_Postid )
{
    if( 
is_user_aliveid ) )
    {
        
strip_user_weaponsid ); // remove all weapons
        
give_itemid"weapon_knife" ); // give him a knife, poor guy
        
        
set_viewidCAMERA_NONE ); // set his camera to default
        
g_iPlayerViewid ] = VIEW_NONE// assign default view to var
    
}
    return 
HAM_IGNORED;
}

public 
OnRoundStart( )
{
    
g_fCachedParachuteVelocity get_pcvar_floatg_iCvars] ); // cache our parachute velocity, we dont wanna retrieve same value every frame
    
g_fCachedAirDropVelocity get_pcvar_floatg_iCvars] ); // same as above

    
ROGShuffleOrigins( ); // randomize our origins

    
RemoveAllWeaponBox( );
    
    
remove_entity_nameAIRDROP_CLASSNAME ); // remove all airdrops
    
remove_entity_nameAIRPLANE_CLASSNAME ); // remove airplane
    
    
remove_taskTASK_AIRDROP ); // end task airdrop
    
    
g_iAirDrops 0;    
    
g_iAirPlaneEnt 0;
    
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
        
remove_taskiTempID TASK_PARACHUTE_DEPLOY ); // just to make sure
        
g_bLandedPlayeriTempID ] = false;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
RoundStarted( )
{    
    
MakeAirPlane( ); // create airplane
    
set_taskget_pcvar_floatg_iCvars] ), "DropAfkPlayers"TASK_AIRDROP_AFK ); // if there's AFK players who forgot to jump, force them to jump
    
    
new Float:fOrigin], WeaponEntityiArraySize ArraySizeg_aWeaponData ), eDataWeaponData ];
    
    for( new 
iiArraySizei++ )
    {
        
ArrayGetArrayg_aWeaponDataieData );
        
        
log_to_file"Newdebug.txt""Weapon Name: %s | Weapon Rarity: %d"eDataWeapon_Name ], eDataWeapon_Rarity ] );
        
        
ROGGetOriginfOrigin );
        
        new 
WeaponBoxEntity OrpheuCallHandleCreateNamedEntityFuncIntClassNameString ) ;
        if( 
pev_validWeaponBoxEntity ) != )
        {
            return 
0;
        }
        
        
engfuncEngFunc_SetOriginWeaponBoxEntityfOrigin );
        
ExecuteHamHam_SpawnWeaponBoxEntity );
        
        
WeaponEntity create_entityeDataWeapon_Name ] );
        
        if( 
pev_validWeaponEntity ) != )
        {
            
remove_entityWeaponBoxEntity );
        }

        
ExecuteHamBHam_SpawnWeaponEntity );
        new 
WeaponID cs_get_weapon_idWeaponEntity );
        
        
OrpheuCallHandlePackWeaponFuncWeaponBoxEntityWeaponEntity );
        if( 
WeaponBoxModelsWeaponID ][ ] != EOS 
        { 
            
engfuncEngFunc_SetModelWeaponBoxEntityWeaponBoxModelsWeaponID ] );
        }
        
        
set_pdata_intWeaponBoxEntitym_pfnThinkCWeaponBoxKill_Address);
        
        new 
iAmmoIndex g_eAmmoIndexWeaponID ][ AmmoIndex ];
        new 
iAmmoCount g_eAmmoIndexWeaponID ][ AmmoCount ];
        
        if( 
iAmmoIndex )
        {
            
OrpheuCallHandlePackAmmoFuncWeaponBoxEntityg_IntAmmoNamesiAmmoIndex ], iAmmoCount );
        }
        
        
set_pevWeaponEntitypev_iuser2eDataWeapon_Rarity ] );
        
GlowWeaponWeaponBoxEntityeDataWeapon_Rarity ] );
    }
    new 
Float:fTimeAirDrop random_floatget_pcvar_floatg_iCvars] ), get_pcvar_floatg_iCvars] ) ); // random time between 2 cvar floats
    
set_taskfTimeAirDrop"OnCreateAirDrop"TASK_AIRDROP__"b" );
    
    return 
PLUGIN_CONTINUE;
}

public 
DropAfkPlayers( )
{
    
engfuncEngFunc_RemoveEntityg_iAirPlaneEnt ); // remove airplane
    
    
new szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"a" );

    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        if( 
g_bPlayerInPlaneiTempID ] )
        {
            
ExecuteHamBHam_Player_JumpiTempID ); // make them jump
            
client_printiTempIDprint_center"%L"iTempID"EMERGENCY_DROP" );
            
            
ExecuteForwardg_iFwUrgentJumpPlaneg_iDummyResultiTempID );
        }
    }
}

@
SetModeliEntszModel[ ] ) // set weapons glow
{
    if( ! 
pev_validiEnt ) )
    return 
FMRES_IGNORED;

    new 
szClassName32 ];
    
peviEntpev_classnameszClassNamecharsmaxszClassName ) );
    
    if( ! 
equalszClassName"weaponbox" ) )
    return 
FMRES_IGNORED;
    
    new 
iWeaponEntity GetWeaponBoxWeaponTypeiEnt ); // get weapon entity
    
    
new iRarity peviWeaponEntitypev_iuser2 );
    
    if( 
iRarity )
    
GlowWeaponiEntiRarity ); // set glow
    
    
return FMRES_IGNORED;
}

public 
OnMessageStatusIconiMsgIdiMsgDestid )
{
    static 
szIcon];
    
get_msg_arg_string2szIconcharsmaxszIcon ) );

    if( 
equalszIcon"buyzone" ) && get_msg_arg_int) ) // block buyzone, not needed in this mod
    
{
        
set_pdata_intid235get_pdata_intid235 ) & ~ ( << ) );
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

@
CmdStartidiHandle // when opening airdrop, you have to press IN_USE
{
    if( ! 
is_user_aliveid ) )
    return 
FMRES_IGNORED;

    static 
iButtons;
    
iButtons get_uciHandleUC_Buttons );
    
    if( 
iButtons IN_USE )
    {
        new 
Float:fOriginPlayer], Float:fOriginEnt], iEnt = -1;
        
pevidpev_originfOriginPlayer );
        
        while( ( 
iEnt find_ent_by_classiEntAIRDROP_CLASSNAME ) ) )
        {
            
peviEntpev_originfOriginEnt );
            
            if( ( 
get_distance_ffOriginPlayerfOriginEnt ) <= get_pcvar_floatg_iCvars] ) ) && ( peviEntpev_flags ) & FL_ONGROUND ) ) // check if distance between player and airdrop is lower than cvar and airdrop has landed
            
{
                
OpenAirDropidiEnt ); // open the airdrop
            
}
        }
    }
    return 
FMRES_IGNORED;
}

@
HamTakeDamage_PreiVictimiInflicteriAttackerFloat:fDamage // give extra damage to each glow
{
    if( ! 
is_user_connectediAttacker ) )
    return 
HAM_IGNORED;
    
    new 
iEnt get_pdata_cbaseiAttackerm_pActiveItem );
    new 
iGlow peviEntpev_iuser2 );
    
    if( ! 
iGlow )
    return 
HAM_IGNORED;
    
    new 
iExtraDamage GetExtraDamageiGlow );
    
    
SetHamParamFloat4fDamage iExtraDamage );
    return 
HAM_IGNORED;
}

@
AirDropThinkiEnt )
{
    if( 
pev_validiEnt ) != )
    return 
PLUGIN_CONTINUE;
    
    new 
Float:fVelocity];
    
peviEntpev_velocityfVelocity );
    
    
set_peviEntpev_nextthinkget_gametime( ) + 0.01 );
    
    if( ( 
peviEntpev_flags ) & FL_ONGROUND ) || ( peviEntpev_flags ) & FL_INWATER ) ) // has landed on ground / in water
    
{
        if( ! 
peviEntpev_iuser2 ) )
        {
            
engfuncEngFunc_SetModeliEntg_iDataAirDropAirDrop_Model_Ground ] ); 
            
engfuncEngFunc_SetSizeiEntFloat:{ -35.0, -40.0, -65.0 }, Float:{ 35.040.065.0 } );
            
            
set_peviEntpev_movetypeMOVETYPE_TOSS );
            
            
client_cmd0"spk sound/%s"g_iSoundsAirDrop_Land_Sound ] );
            
            
set_peviEntpev_iuser2);
        }
    }
    
    else if( 
fVelocity] < 0.0 // still in air
    
{
        
fVelocity] = g_fCachedAirDropVelocity;
        
set_peviEntpev_velocityfVelocity );    
    }
    return 
PLUGIN_CONTINUE;
}

public 
OnCreateAirDrop( )
{
    if( 
g_iAirDrops <= get_pcvar_numg_iCvars] ) ) // create as many AirDrops as described in the cvar
    
{
        
MakeAirDropEnt( );
        
g_iAirDrops++;
    }
    
    else
    {
        
remove_taskTASK_AIRDROP ); // remove airdrop task, no more airdrops needed
    
}
}

public 
client_PreThinkid )
{
    if( ! 
is_user_aliveid ) )
    return 
PLUGIN_CONTINUE;
    
    if( 
g_bIsPlayerInParachuteid ] )
    {
        new 
Float:fVelocity]; 
        
pevidpev_velocityfVelocity ); 
        
        if( ! 
g_bLandedPlayerid ] && ( ( pevidpev_flags ) & FL_ONGROUND ) || ( pevidpev_flags ) & FL_INWATER ) ) ) // player has landed on ground/ in water
        
{
            
g_bIsPlayerInParachuteid ] = false// not in parachute anymore
            
set_pevidpev_sequencedetach );
            
set_pevidpev_movetypeMOVETYPE_WALK );
            
            
client_cmdid"spk sound/%s"g_iSoundsLanding_Sound ] ); // emit landing sound
            
            
g_bLandedPlayerid ] = true;
        }

        
        else if( 
fVelocity] < 0.0 // still in air
        
{
            
fVelocity] = g_fCachedParachuteVelocity;
            
set_pevidpev_velocityfVelocity );
        } 
    }
    return 
PLUGIN_CONTINUE;
}

@
HamPlayerImpulseCommands_Preid // block spray and replace it with camera
{
    if( ! 
is_user_aliveid ) )
    return 
HAM_IGNORED;
    
    if( ! 
get_pcvar_numg_iCvars] ) )
    return 
HAM_IGNORED;
    
    if( 
pevidpev_impulse ) == 201 )
    {
        
g_iPlayerViewid ] = g_iPlayerViewid ] == VIEW_3RDPERSON VIEW_NONE VIEW_3RDPERSON;
        
set_viewidg_iPlayerViewid ] );
        
        
set_pevidpev_impulse);
    }
    return 
HAM_IGNORED;
}

public 
client_connectid // reset vars
{
    
g_iPlayerViewid ] = VIEW_NONE;
    
g_bIsPlayerInParachuteid ] = false;
    
g_bPlayerInPlaneid ] = false;
    
g_bLandedPlayerid ] = false;
}

ReadWeapons( ) // read our weapons from .ini
{
    new 
szConfigsName256 ], szFilename512 ], eDataWeaponData ], szWeaponName32 ], szRarity18 ], szData128 ];
    
get_configsdirszConfigsNamecharsmaxszConfigsName ) );
        
    
formatexszFilenamecharsmaxszFilename ), "%s/%s"szConfigsNameg_szGameWeapons );
    
    new 
iFile fopenszFilename"rt" );
        
    if( 
iFile )
    {        
        while( ! 
feofiFile ) )
        {            
            
fgetsiFileszDatacharsmaxszData ) );
            
trimszData );
            
            switch( 
szData] )
            {
            case 
EOS'#'';':
                {
                    continue;
                }
                
            default:
                {
                    if( 
parseszDataszWeaponNamecharsmaxszWeaponName ), szRaritycharsmaxszRarity ) ) < )
                    continue;
                                        
                    for( new 
isizeof g_szForbiddenWeaponsi++ )
                    {
                        if( 
equalszWeaponNameg_szForbiddenWeapons] ) )
                        {
                            continue;
                        }
                    }
                                        
                    new 
iRarity;
                    if( 
TrieGetCellg_tRarityTrieszRarityiRarity ) )
                    {
                        if( ! ( 
RARITY_GREY <= iRarity <= RARITY_GOLD ) )
                        {
                            continue;
                        }
                        
                        
eDataWeapon_Rarity ] = iRarity;
                    }                    
                                        
                    
eDataWeapon_Name ] = szWeaponName;
                    
                    
ArrayPushArrayg_aWeaponDataeData );
                    
                    
log_to_file"debugold.txt""%s %d"eDataWeapon_Name ], eDataWeapon_Rarity ] );
                }
            }
        }
        
fcloseiFile );
    }
}

ReadModels( ) // read our models from .ini
{
    new 
szConfigsName256 ], szFilename512 ];
    
get_configsdirszConfigsNamecharsmaxszConfigsName ) );
    
    
formatexszFilenamecharsmaxszFilename ), "%s/%s"szConfigsNameg_szGameModels );
    
    new 
iFile fopenszFilename"r" );
    
    if( 
iFile )
    {
        new 
szData128 ], szValue64 ], szKey32 ];
        
        while( ! 
feofiFile ) )
        {
            
fgetsiFileszDatacharsmaxszData ) );
            
trimszData );
            
            switch( 
szData] )
            {
            case 
EOS'#'';'
                continue;
                
            default:
                {
                    
strtokszDataszKeycharsmaxszKey ), szValuecharsmaxszValue ), '=' );
                    
trimszKey ); 
                    
trimszValue );
                    
                    if( ! 
szValue] )
                    continue;
                    
                    if( 
equalszKey"AIRDROP_MODEL_FLYING" ) )
                    {
                        
g_iDataAirDropAirDrop_Model_Flying ] = szValue;
                        
precache_modelszValue );
                    }
                    
                    else if( 
equalszKey"AIRDROP_MODEL_GROUND" ) )
                    {
                        
g_iDataAirDropAirDrop_Model_Ground ] = szValue;
                        
precache_modelszValue );
                    }
                    
                    else if( 
equalszKey"AIRPLANE_MODEL" ) )
                    {
                        
g_iDataAirPlaneAirPlane_Model ] = szValue;
                        
precache_modelszValue );
                    }
                }
            }
        }
    }
    
fcloseiFile );
}

ReadSounds( ) // read our sounds from .ini
{
    new 
szConfigsName256 ], szFilename512 ];
    
get_configsdirszConfigsNamecharsmaxszConfigsName ) );
    
    
formatexszFilenamecharsmaxszFilename ), "%s/%s"szConfigsNameg_szGameSounds );
    
    new 
iFile fopenszFilename"r" );
    
    if( 
iFile )
    {
        new 
szData128 ], szValue64 ], szKey32 ];
        
        while( ! 
feofiFile ) )
        {
            
fgetsiFileszDatacharsmaxszData ) );
            
trimszData );
            
            switch( 
szData] )
            {
            case 
EOS'#'';'
                continue;
                
            default:
                {
                    
strtokszDataszKeycharsmaxszKey ), szValuecharsmaxszValue ), '=' );
                    
trimszKey ); 
                    
trimszValue );
                    
                    if( ! 
szValue] )
                    continue;
                    
                    if( 
equalszKey"PARACHUTE_DEPLOY_SOUND" ) )
                    {
                        
g_iSoundsParachute_Deploy_Sound ] = szValue;
                        
precache_soundszValue );
                    }
                    
                    else if( 
equalszKey"LANDING_SOUND" ) )
                    {
                        
g_iSoundsLanding_Sound ] = szValue;
                        
precache_soundszValue );
                    }
                    
                    else if( 
equalszKey"AIRDROP_APPEAR_SOUND" ) )
                    {
                        
g_iSoundsAirDrop_Appear_Sound ] = szValue;
                        
precache_soundszValue );
                    }
                    
                    else if( 
equalszKey"AIRDROP_LAND_SOUND" ) )
                    {
                        
g_iSoundsAirDrop_Land_Sound ] = szValue;
                        
precache_soundszValue );
                    }
                }
            }
        }
    }
    
fcloseiFile );
}

MakeAirPlane( )
{
    new 
Float:fOrigin], Float:fAngle] , Float:fVelocity];
    
GetPlaneDirectionfOriginfAnglefVelocity ) ;
    
    
g_iAirPlaneEnt create_entity"info_target" );
    
    
set_pevg_iAirPlaneEntpev_classnameAIRPLANE_CLASSNAME );
    
set_pevg_iAirPlaneEntpev_solidSOLID_NOT ); // we dont want it to collide with players who jump
    
set_pevg_iAirPlaneEntpev_movetypeMOVETYPE_FLY ); // its gonna fly, so..
    
engfuncEngFunc_SetModelg_iAirPlaneEntg_iDataAirPlaneAirPlane_Model ] );
    
engfuncEngFunc_SetOriging_iAirPlaneEntfOrigin );
    
set_pevg_iAirPlaneEntpev_anglesfAngle ); // set correct angles, we don't want a plane going backwards
    
set_pevg_iAirPlaneEntpev_velocityfVelocity );
    
    
fOrigin] -= 5.0// reduce the Z axi a little bit, find the best place for players to stand
    
    
new szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"ach" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
        
AttachPlayerToPlaneiTempIDfOriginfAnglefVelocity ); // attach the players to the plane
    
}
}

AttachPlayerToPlaneidFloat:fOrigin], Float:fAngle], Float:fVelocity] )
{
    
set_user_renderingidkRenderFxGlowShell000kRenderTransAlpha); // make player invisibile
    
    
engfuncEngFunc_SetOriginidfOrigin );
    
set_pevidpev_anglesfAngle );
    
set_pevidpev_fixangle); // idk if its really needed
    
set_pevidpev_velocityfVelocity );
    
set_pevidpev_gravity0.00001 ); // 0.0 doesnt work so lets set an extra small value
    
set_pevidpev_maxspeed0.00001 ); // same as above
    
    
g_bIsPlayerInParachuteid ] = false// player isnt in parachute
    
g_bPlayerInPlaneid ] = true// but hes in airplane
    
    
set_pevidpev_solidSOLID_NOT ); // make him SOLID_NOT so he doesnt collide with the others
}

GetPlaneDirectionFloat:fOrigin] , Float:fAngle], Float:fVelocity] ) // get a random hard-coded direction for the plane, impossible to do without hard-coding
{
    switch( 
random_num1) )
    {
    case 
1:
        {
            
fOrigin] = 3284.0;
            
fOrigin] = -3284.3;
            
fOrigin] = 3931.9;

            
fAngle] = -0.6;
            
fAngle] = 137.1;
            
fAngle] = 0.0;

            
fVelocity] = -219.9;
            
fVelocity] = 203.7;
            
fVelocity] = -10.0;
        }

    case 
2:
        {
            
fOrigin] = -2767.5;
            
fOrigin] = -1382.9;
            
fOrigin] = 3931.9;

            
fAngle] = -1.3;
            
fAngle] = 20.5;
            
fAngle] = 0.0;

            
fVelocity] = 280.2;
            
fVelocity] = 104.8;
            
fVelocity] = -20.8;
        }
    }
}

MakeAirDropEnt( )
{
    new 
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );

    new 
Float:fOrigin];
    
ROGGetOriginfOrigin ); // get a valid origin

    
fOrigin] = 3850.0// max height, as we're gonna stick to one map, hard-code it
    
engfuncEngFunc_SetOriginiEntfOrigin );
    
    
set_peviEntpev_classnameAIRDROP_CLASSNAME );
    
    
set_peviEntpev_movetypeMOVETYPE_TOSS ); // if it lands on the moving boat, to follow the boat instead of levitating
    
set_peviEntpev_solidSOLID_BBOX );
    
    
engfuncEngFunc_SetModeliEntg_iDataAirDropAirDrop_Model_Flying ] ); 
    
engfuncEngFunc_SetSizeiEntFloat:{ -35.0, -40.0, -5.0 }, Float:{ 35.040.05.0 } );

    
set_peviEntpev_nextthinkget_gametime( ) + 0.01 ); // make it think
    
    
client_cmd0"spk sound/%s"g_iSoundsAirDrop_Appear_Sound ] ); // emit airdrop appear sound
    
    
client_print0print_center"%L"LANG_PLAYER"AIRDROP_ARRIVED" );
}

OpenAirDropidiEnt // player is opening airdrop
{
    new 
Float:fOrigin];
    
peviEntpev_originfOrigin );

    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_EXPLOSION ); // make effect
    
engfuncEngFunc_WriteCoordfOrigin] );
    
engfuncEngFunc_WriteCoordfOrigin] );
    
engfuncEngFunc_WriteCoordfOrigin] );
    
write_shortg_iSpriteIndexExplosion );
    
write_byte30 );
    
write_byte15 );
    
write_byteTE_EXPLFLAG_NONE );
    
message_end( );
    
    
engfuncEngFunc_RemoveEntityiEnt ); // remove the ent
    
    
new iWeapon g_szPossibleAirDropWeaponsrandomsizeof g_szPossibleAirDropWeapons ) ]; // retrieve a random entry
    
    
StripWeaponsidPrimaryfalse ); // strip his primary weapon
    
    
GivePlayerSpecialWeaponidiWeapon ); // give him a special weapon
    
return PLUGIN_CONTINUE;
}

GivePlayerSpecialWeaponidiWeapon )
{
    new 
szWeaponName32 ], iNumWeaponsiWeaponIDszWeapons32 ];
    
get_weaponnameiWeaponszWeaponNamecharsmaxszWeaponName ) );

    new 
iEnt give_itemidszWeaponName );
    
    if( 
pev_validiEnt ) )
    {
        
set_peviEntpev_iuser2RandomGlowByChance( ) );
        
        
get_user_weaponsidszWeaponsiNumWeapons );
        
        for( new 
iiNumWeaponsi++ )
        {
            
iWeaponID szWeapons];
            
            if ( ( 
<< iWeapon ) & SKIP_THESE_WEAPONS )
            continue;
            
            
ExecuteHamBHam_GiveAmmoidg_szMaxBpAmmoiWeaponID ], g_szAmmoTypeiWeaponID ], g_szMaxBpAmmoiWeaponID ] );
        }
        
        
ExecuteForwardg_iFwOpenAirDropg_iDummyResultidiWeapon );
    }
}

RandomGlowByChance( ) // stock to pick a glow by chances
{
    new 
iReturnValue;
    
    const 
iPercentage 100;
    new 
iRandomNum random_num0iPercentage );

    switch( 
iRandomNum )
    {

    case 
.. 40:
        
iReturnValue RARITY_BLUE;

    case 
41 .. 75:
        
iReturnValue RARITY_PURPLE;

    case 
76 .. 100:
        
iReturnValue RARITY_GOLD;
    }
    return 
iReturnValue
}

GlowWeaponiEntiColor // glow the weapon
{
    switch( 
iColor )
    {
    case 
RARITY_GREY:
        
set_renderingiEntkRenderFxGlowShell192192192kRenderNormal50 );

    case 
RARITY_GREEN:
        
set_renderingiEntkRenderFxGlowShell02550kRenderNormal50 );    
        
    case 
RARITY_BLUE:
        
set_renderingiEntkRenderFxGlowShell0181255kRenderNormal50 );

    case 
RARITY_PURPLE:
        
set_renderingiEntkRenderFxGlowShell1280128kRenderNormal50 );

    case 
RARITY_GOLD:
        
set_renderingiEntkRenderFxGlowShell2552150kRenderNormal50 );
    }
}

GetExtraDamageiGlowColor // get damage according to glow
{
    return 
iGlowColor get_pcvar_numg_iCvars] );
}

RemoveAllWeaponBox( )
{
    new 
iEnt = -1;
    while( ( 
iEnt find_ent_by_classiEnt"weaponbox" ) ) != )
    {
        
set_pdata_intiEntm_pfnThinkCWeaponBoxKill_Address);
    }
}

GetWeaponBoxWeaponTypeiEnt )
{
    new 
iWeapon;
    for( new 
1<= 5i++ )
    {
        
iWeapon get_pdata_cbaseiEntm_rgpPlayerItems_CWeaponBox], XO_CWEAPONBOX );
        if( 
iWeapon 
        {
            return 
iWeapon;
        }
    }
    return 
0;
}

RemoveObjectives( )
{
    
remove_entity_name"info_bomb_target" );
    
remove_entity_name"func_bomb_target" );


When parsing info into array:
PHP Code:

L 08/05/2018 15:43:49Log file started (file "cstrike/addons/amxmodx/logs/debugold.txt") (game "cstrike") (amx "1.8.2")
L 08/05/2018 15:43:49weapon_p228 1
L 08
/05/2018 15:43:49weapon_glock 2
L 08
/05/2018 15:43:49weapon_scout 3
L 08
/05/2018 15:43:49weapon_hegrenade 4
L 08
/05/2018 15:43:49weapon_xm1014 5
L 08
/05/2018 15:43:49weapon_mac10 1
L 08
/05/2018 15:43:49weapon_aug 2
L 08
/05/2018 15:43:49weapon_smokegrenade 3
L 08
/05/2018 15:43:49weapon_elite 4
L 08
/05/2018 15:43:49weapon_fiveseven 5
L 08
/05/2018 15:43:49weapon_ump45 1
L 08
/05/2018 15:43:49weapon_sg550 2
L 08
/05/2018 15:43:49weapon_galil 3
L 08
/05/2018 15:43:49weapon_famas 4
L 08
/05/2018 15:43:49weapon_usp 5
L 08
/05/2018 15:43:49weapon_glock18 1
L 08
/05/2018 15:43:49weapon_awp 2
L 08
/05/2018 15:43:49weapon_mp5navy 3
L 08
/05/2018 15:43:49weapon_m249 4
L 08
/05/2018 15:43:49weapon_m3 5
L 08
/05/2018 15:43:49weapon_m4a1 1
L 08
/05/2018 15:43:49weapon_tmp 2
L 08
/05/2018 15:43:49weapon_g3sg1 3
L 08
/05/2018 15:43:49weapon_flashbang 4
L 08
/05/2018 15:43:49weapon_deagle 5
L 08
/05/2018 15:43:49weapon_sg552 1
L 08
/05/2018 15:43:49weapon_ak47 2
L 08
/05/2018 15:43:49weapon_p90 3
L 08
/05/2018 15:43:49weapon_p228 1
L 08
/05/2018 15:43:49weapon_glock 2
L 08
/05/2018 15:43:49weapon_scout 3
L 08
/05/2018 15:43:49weapon_hegrenade 4
L 08
/05/2018 15:43:49weapon_xm1014 5
L 08
/05/2018 15:43:49weapon_mac10 1
L 08
/05/2018 15:43:49weapon_aug 2
L 08
/05/2018 15:43:49weapon_smokegrenade 3
L 08
/05/2018 15:43:49weapon_elite 4
L 08
/05/2018 15:43:49weapon_fiveseven 5
L 08
/05/2018 15:43:49weapon_ump45 1
L 08
/05/2018 15:43:49weapon_sg550 2
L 08
/05/2018 15:43:49weapon_galil 3
L 08
/05/2018 15:43:49weapon_famas 4
L 08
/05/2018 15:43:49weapon_usp 5
L 08
/05/2018 15:43:49weapon_glock18 1
L 08
/05/2018 15:43:49weapon_awp 2
L 08
/05/2018 15:43:49weapon_mp5navy 3
L 08
/05/2018 15:43:49weapon_m249 4
L 08
/05/2018 15:43:49weapon_m3 5
L 08
/05/2018 15:43:49weapon_m4a1 1
L 08
/05/2018 15:43:49weapon_tmp 2
L 08
/05/2018 15:43:49weapon_g3sg1 3
L 08
/05/2018 15:43:49weapon_flashbang 4
L 08
/05/2018 15:43:49weapon_deagle 5
L 08
/05/2018 15:43:49weapon_sg552 1
L 08
/05/2018 15:43:49weapon_ak47 2
L 08
/05/2018 15:43:49weapon_p90 3
L 08
/05/2018 15:43:49weapon_p228 1
L 08
/05/2018 15:43:49weapon_glock 2
L 08
/05/2018 15:43:49weapon_scout 3
L 08
/05/2018 15:43:49weapon_hegrenade 4
L 08
/05/2018 15:43:49weapon_xm1014 5
L 08
/05/2018 15:43:49weapon_mac10 1
L 08
/05/2018 15:43:49weapon_aug 2
L 08
/05/2018 15:43:49weapon_smokegrenade 3
L 08
/05/2018 15:43:49weapon_elite 4
L 08
/05/2018 15:43:49weapon_fiveseven 5
L 08
/05/2018 15:43:49weapon_ump45 1
L 08
/05/2018 15:43:49weapon_sg550 2
L 08
/05/2018 15:43:49weapon_galil 3
L 08
/05/2018 15:43:49weapon_famas 4
L 08
/05/2018 15:43:49weapon_usp 5
L 08
/05/2018 15:43:49weapon_glock18 1
L 08
/05/2018 15:43:49weapon_awp 2
L 08
/05/2018 15:43:49weapon_mp5navy 3
L 08
/05/2018 15:43:49weapon_m249 4
L 08
/05/2018 15:43:49weapon_m3 5
L 08
/05/2018 15:43:49weapon_m4a1 1
L 08
/05/2018 15:43:49weapon_tmp 2
L 08
/05/2018 15:43:49weapon_g3sg1 3
L 08
/05/2018 15:43:49weapon_flashbang 4
L 08
/05/2018 15:43:49weapon_deagle 5
L 08
/05/2018 15:43:49weapon_sg552 1
L 08
/05/2018 15:43:49weapon_ak47 2
L 08
/05/2018 15:43:49weapon_p90 3
L 08
/05/2018 15:43:49weapon_p228 1
L 08
/05/2018 15:43:49weapon_glock 2
L 08
/05/2018 15:43:49weapon_scout 3
L 08
/05/2018 15:43:49weapon_hegrenade 4
L 08
/05/2018 15:43:49weapon_xm1014 5
L 08
/05/2018 15:43:49weapon_mac10 1
L 08
/05/2018 15:43:49weapon_aug 2
L 08
/05/2018 15:43:49weapon_smokegrenade 3
L 08
/05/2018 15:43:49weapon_elite 4
L 08
/05/2018 15:43:49weapon_fiveseven 5
L 08
/05/2018 15:43:49weapon_ump45 1
L 08
/05/2018 15:43:49weapon_sg550 2
L 08
/05/2018 15:43:49weapon_galil 3
L 08
/05/2018 15:43:49weapon_famas 4
L 08
/05/2018 15:43:49weapon_usp 5
L 08
/05/2018 15:43:49weapon_glock18 1
L 08
/05/2018 15:43:49weapon_awp 2
L 08
/05/2018 15:43:49weapon_mp5navy 3
L 08
/05/2018 15:43:49weapon_m249 4
L 08
/05/2018 15:43:49weapon_m3 5
L 08
/05/2018 15:43:49weapon_m4a1 1
L 08
/05/2018 15:43:49weapon_tmp 2
L 08
/05/2018 15:43:49weapon_g3sg1 3
L 08
/05/2018 15:43:49weapon_flashbang 4
L 08
/05/2018 15:43:49weapon_deagle 5
L 08
/05/2018 15:43:49weapon_sg552 1
L 08
/05/2018 15:43:49weapon_ak47 2
L 08
/05/2018 15:43:49weapon_p90 3 

When retrieving
PHP Code:

L 08/05/2018 15:44:17Weapon Nameweapon_p228 Weapon Rarity1
L 08
/05/2018 15:44:17Weapon Nameweapon_glock Weapon Rarity


Ghosted 08-05-2018 09:36

Re: Ent has null Private Data | Array not being read
 
Code:

WeaponEntity = create_entity( eData[ Weapon_Name ] );
create_entity creates just entity without any private data cause there's no classname to link its privatedata.

edon1337 08-05-2018 10:03

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by Ghosted (Post 2608293)
Code:

WeaponEntity = create_entity( eData[ Weapon_Name ] );
create_entity creates just entity without any private data cause there's no classname to link its privatedata.

So that means I have to create an entity such as info_target then set it's classname to eData[ Weapon_Name ] ?

klippy 08-05-2018 10:39

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by Ghosted (Post 2608293)
Code:

WeaponEntity = create_entity( eData[ Weapon_Name ] );
create_entity creates just entity without any private data cause there's no classname to link its privatedata.

No, that's EngFunc_CreateEntity.
@OP, debug every line of your code and check runtime errors. You may be having issues with weapon_glock like in one of your previous topics IIRC.
But I'm on my phone atm so I can't check the code thoroughly, just guessing.

Ghosted 08-05-2018 11:03

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by KliPPy (Post 2608307)
No, that's EngFunc_CreateEntity.
@OP, debug every line of your code and check runtime errors. You may be having issues with weapon_glock like in one of your previous topics IIRC.
But I'm on my phone atm so I can't check the code thoroughly, just guessing.

My bad! :crab:


Code:

WeaponEntity = create_entity( eData[ Weapon_Name ] );
       
        if( pev_valid( WeaponEntity ) != 2 )
        {
            remove_entity( WeaponBoxEntity );
        }

        ExecuteHamB( Ham_Spawn, WeaponEntity );

Check if entity is removed by remove_entity

edon1337 08-05-2018 14:13

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by KliPPy (Post 2608307)
No, that's EngFunc_CreateEntity.
@OP, debug every line of your code and check runtime errors. You may be having issues with weapon_glock like in one of your previous topics IIRC.
But I'm on my phone atm so I can't check the code thoroughly, just guessing.

Thanks, I always forget that it should be weapon_glock18, also that should fix the 2nd problem too, since there's nothing wrong with the method I'm using to retrieve the data from array. I'll let you know when I test.

Quote:

Originally Posted by Ghosted (Post 2608313)
Code:

WeaponEntity = create_entity( eData[ Weapon_Name ] );
       
        if( pev_valid( WeaponEntity ) != 2 )
        {
            remove_entity( WeaponBoxEntity );
        }

        ExecuteHamB( Ham_Spawn, WeaponEntity );


I don't think that's safe. You have to call m_pfnThink on weaponbox entities to properly remove them, remove_entity creates a memory leak.

Furthermore, HamletEagle didn't remove the weaponbox here and that surely has a reason behind.

Ghosted 08-05-2018 14:20

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by edon1337 (Post 2608344)
I don't think that's safe.

actually that's ur code, said to use print debugging option, nvm...

edon1337 08-05-2018 14:24

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by Ghosted (Post 2608348)
actually that's ur code.

Ah, just a misunderstanding, I've accidentally put it there when I was trying to test, but I never got the chance.

edon1337 08-05-2018 15:38

Re: Ent has null Private Data | Array not being read
 
KliPPY, it fixed it, thanks.

I have a question, can I just call m_pfnThink and destroy the weaponbox instead of returning 0?
PHP Code:

        new WeaponBoxEntity OrpheuCallHandleCreateNamedEntityFuncIntClassNameString ) ; 
        if( 
pev_validWeaponBoxEntity ) != 
        { 
            return 
0
        } 


HamletEagle 08-05-2018 15:48

Re: Ent has null Private Data | Array not being read
 
Quote:

Originally Posted by edon1337 (Post 2608385)
KliPPY, it fixed it, thanks.

I have a question, can I just call m_pfnThink and destroy the weaponbox instead of returning 0?
PHP Code:

        new WeaponBoxEntity OrpheuCallHandleCreateNamedEntityFuncIntClassNameString ) ; 
        if( 
pev_validWeaponBoxEntity ) != 
        { 
            return 
0
        } 


Why do you want to destroy something that was not even created?


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

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