Raised This Month: $ Target: $400
 0% 

Help native error ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-08-2017 , 15:20   Help native error ?
Reply With Quote #1

Hi

There is a problem with this plugin but I would like some help to fix it
So you can replace the line that contains the problem .. Or maybe change the function of the plugin in full ..
In fact, I have no idea how to fix the bugs
Any help please!!

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

enum _:EntityProp
{
    
EntityIndex,
    
EntityType,
    
Float:BrushEntityOrigin[3]
}

new const 
EntsToRemove[][] =
{
    
"info_player_deathmatch",
    
"info_player_start"
}
new const 
EntClassnames[][] =
{
    
"info_player_team1",
    
"info_player_team2"
}

new Array:
ArrayEnts

public plugin_init()
{
    
ArrayEnts ArrayCreate(EntityProp)
    
    
//Remove ents
    
new Targeti
    
for(02i++)
    {
        
Target = -1
        
while((Target find_ent_by_class(TargetEntsToRemove[i])))
        {
            if(
pev_valid(Target))
            {
                
server_print("Removing %i ent[ %s ]"TargetEntsToRemove[i])
                
remove_entity(Target)
            }
        }
    }

    
//Search for info_player_team1 and info_player_team2 ents
    
new Data[EntityProp]
    
Target = -1
    
new FloatBrushOrigin[3]
    for(new 
02i++)
    {
        while((
Target find_ent_by_class(TargetEntClassnames[i])))
        {
            
//Found a valid entity
            
if(pev_valid(Target))
            {
                
//Save it's index, type(for t or ct) and origin
                //Push everything in the array
                
get_brush_entity_origin(TargetBrushOrigin)
                
                
Data[EntityIndex] = Target
                Data
[EntityType] = i
                Data
[BrushEntityOrigin] = _:BrushOrigin
                ArrayPushArray
(ArrayEntsData)
            }
        }
    }

    
//Hook spawn
    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn"true)
}

public 
plugin_end()
{
    
//Destroy the array to free memory
    
ArrayDestroy(ArrayEnts)
}

public 
CBasePlayer_Spawn(id)
{
    
server_print("Spawn has been triggered")
    
    
//Filter invalid spawns.
    
if(!is_user_alive(id))
    {
        return 
    }
    
server_print("Player is succesfully spawned")
    
    new 
Team get_user_team(id)
    
    new 
EntsArraySize ArraySize(ArrayEnts), Data[EntityProp], i
    
new Array: TempArray ArrayCreate(EntityProp)
    
    for(
0EntsArraySizei++)
    {
        
ArrayGetArray(ArrayEntsiData)
        
Team Team 1
        
if(Data[EntityType] == Team)
        {
            
ArrayPushArray(TempArrayData)
        }
    }
    
    
ArrayGetArray(TempArrayrandom_num(0ArraySize(TempArray) - 1), Data)
    
ArrayDestroy(TempArray)//done with that array, destroy it

    
new Float:SearchOrigin[3
    
SearchOrigin Data[BrushEntityOrigin]
    
    
//Check if the origin that we have is empty
    
if(ValidSpotFound(idSearchOrigin))
    {
        
//Teleport the player
        
set_pev(idpev_originSearchOrigin)
    }
    else
    {
        
//If the sport is not free we need to do some searches
        //I've set the max searches to 300, you can increase it if it's found nothing and fail to teleport the player
        
new RestrictMaxSearches 600iFloat:FoundOrigin[3]
        while(--
RestrictMaxSearches 0)
        {
            
//Get some random origins around our one
            
for(03i++)
            {
                
FoundOrigin[i] = random_float(SearchOrigin[i] - 5SearchOrigin[i] + 5)
            }
            if(
ValidSpotFound(idFoundOrigin))
            {
                
//A valid spot has been found, set player origin and stop the loop
                
set_pev(idpev_originFoundOrigin)
                break
            }
        }
    }
}

bool:ValidSpotFound(idFloat:SearchOrigin[3])
{
    
//Send a TraceHull to check if the spot that we found is empty
    //Return true if found
    //False otherwise
    
new HandleGlobalTraceLine
    engfunc
(EngFunc_TraceHullSearchOriginSearchOriginIGNORE_MONSTERSpev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMANidHandleGlobalTraceLine)    
    if(
get_tr2(HandleGlobalTraceLineTR_InOpen) && !(get_tr2(HandleGlobalTraceLineTR_StartSolid) || get_tr2(HandleGlobalTraceLineTR_AllSolid))) 
    {
        return 
true
    
}
    return 
false        


Quote:
L 12/07/2017 - 108:01: Start of error session.
L 12/07/2017 - 108:01: Info (map "agctf_duff") (file "addons/amxmodx/logs/error_20171207.log")
L 12/07/2017 - 108:01: Invalid index 0 (count: 0)
L 12/07/2017 - 108:01: [AMXX] Displaying debug trace (plugin "team_spawn.amxx", version "unknown")
L 12/07/2017 - 108:01: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 12/07/2017 - 108:01: [AMXX] [0] team_spawn.sma::CBasePlayer_Spawn (line 104)
line 104 :
PHP Code:
ArrayGetArray(TempArrayrandom_num(0ArraySize(TempArray) - 1), Data
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
 



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 18:51.


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