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

origin of entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 02-25-2018 , 15:38   origin of entity
Reply With Quote #1

I tried to make second origin for entity and shows me only one why? something wrong?

I know I can do:

Code:
new const szInfo[2][INFO] =
{
    { "35hp_2", 1066.52, -1025.00, -551.00},
    { "35hp_2", 1066.52, -1075.00, -551.00}
}
if i have 2 entitys in 35hp_2 is not possible to detect only one becouse :

is the distance between player and g_Origin

The red selection is what i change

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

#define PLUGIN "Crear Entity"
#define VERSION "1.0"
#define AUTHOR "xPaw & Luqqas'"

enum _:INFO
{
    MAP[20],
    Float:X,
    Float:Y,
    Float:Z
}
new Entity
new Float:g_Origin[3],  Float:x_Origin[3]

new const DATE[] = "models/test.mdl"

new const szInfo[1][INFO] =
{
    { "35hp_2", 1066.52, -1025.00, -551.00}

}

new const xzInfo[1][INFO] =
{
    { "35hp_2", 1066.52, -1075.00, -551.00}

}


new maxplayers
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_think("NiceArbol","Think_NiceArbol" );
    register_clcmd("say /origins", "origins")
    maxplayers = get_maxplayers()
}


public Think_NiceArbol(Ent)
{
    entity_set_float( Ent, EV_FL_nextthink, halflife_time() + 0.01 )
    new Float:PlayerOrigin[3]
    new Float:fDistance, Float:xDistance 
    
    for(new i = 1 ; i <= maxplayers; i++)
    {
        pev(i, pev_origin, PlayerOrigin)
        fDistance = get_distance_f( g_Origin, PlayerOrigin )
        xDistance = get_distance_f( x_Origin, PlayerOrigin )
        
        if( fDistance <= 100.0)
        {
            client_print(i , print_center, "Distance to entity: %.2f", fDistance )
        }
    
        if( xDistance <= 100.0)
        {
            client_print(i , print_center, "Distance to entity: %.2f", fDistance )
        }
    
    }
    
}
public origins(id)
{
    new Get_Origins[3]
    pev(id , pev_origin, Get_Origins)
    
    client_print(id, print_chat, "%0.2f - %0.2f - %0.2f", Get_Origins[0], Get_Origins[1], Get_Origins[2])
    
    return PLUGIN_HANDLED
}
public plugin_precache() 
{
    precache_model(DATE)
    
    static map[20]
    get_mapname(map, charsmax(map))
    
    for( new i = 0 ; i < 2 ; i++)
    {
        if( equal( map, szInfo[i][MAP] ))
        {            
            g_Origin[0] = szInfo[i][X]
            g_Origin[1] = szInfo[i][Y]
            g_Origin[2] = szInfo[i][Z]

            CreateEntity( 0 , g_Origin)
        }
    }
    
    for( new j = 0 ; j < 2 ; j++)
    {
        if( equal( map, xzInfo[j][MAP] ))
        {            
            x_Origin[0] = xzInfo[j][X]
            x_Origin[1] = xzInfo[j][Y]
            x_Origin[2] = xzInfo[j][Z]

            CreateEntity( 0 , x_Origin)
        }
    }
    

}

CreateEntity( id,  Float:Origin[3] = { 0.00, 0.00 , 0.00 })
{
    if( !id && Origin[0] == 0.00 && Origin[1] == 0.00 && Origin[2] == 0.00 )
        return;
        
    Entity = create_entity( "info_target" );

     //assert is_valid_ent(Entity)
    if( is_valid_ent(Entity) )
    {
        entity_set_string( Entity , EV_SZ_classname, "NiceArbol");
        entity_set_float( Entity, EV_FL_nextthink, halflife_time() + 0.01 )
        entity_set_int( Entity , EV_INT_solid, SOLID_BBOX);
        entity_set_model( Entity , DATE );
        entity_set_size( Entity , Float:{ -320.0, -220.0, 0.0 }, Float:{ 320.0, 220.0, 10.0 } );        
        
        
        server_print("* Entidad creada en las coordenadas %0.2f %0.2f %0.2f", Origin[0], Origin[1], Origin[2] );

        entity_set_origin( Entity, Origin );
    }
        
    return;
}

Last edited by Saint Sinner; 02-25-2018 at 15:48.
Saint Sinner is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 02-26-2018 , 14:30   Re: origin of entity
Reply With Quote #2

Code:
for( new j = 0 ; j < 2 ; j++)
    {
        if( equal( map, xzInfo[j][MAP] ))
        {            
            x_Origin[0] = xzInfo[j][X]
            x_Origin[1] = xzInfo[j][Y]
            x_Origin[2] = xzInfo[j][Z]

            CreateEntity( 0 , x_Origin)
        }
    }
Here you rewrite the same cell every cycle of the loop.
It should be something like this: (one array entry for each entity.)
Code:
for( new j = 0 ; j < 2 ; j++)
    {
        if( equal( map, xzInfo[j][MAP] ))
        {            
            x_Origin[j][0] = xzInfo[j][X]
            x_Origin[j][1] = xzInfo[j][Y]
            x_Origin[j][2] = xzInfo[j][Z]

            CreateEntity( 0 , x_Origin)
        }
    }
Obviously, you must change the method of checking the distance.
__________________
My English is A0
E1_531G is offline
Old 02-27-2018, 07:42
KiLLeR.
This message has been deleted by KiLLeR.. Reason: I didn't read the first post...
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 11:20.


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