AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] get_distance_f (https://forums.alliedmods.net/showthread.php?t=167849)

TheArmagedon 09-20-2011 21:43

[HELP] get_distance_f
 
I have a problem with get_distance_f
When i type in chat "lala (registered in clcmd)" automatically creates a entity and shows for me the distance between me and ent...
But it did not work... In first time it works fine but when i type again, the entity creates normally but it shows "[", "u", "(" of distance...
Whats wrong with the code?

PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>

new const gModel[ ] = "models/teste.mdl"

public plugin_init()
    
register_clcmd("say lala""LALAc")
    
public 
plugin_precache()
    
precache_modelgModel )
    
public 
LALAc(id)
{
    new 
ent create_entity"info_target" );
    
    if( !
pev_valident ) )
    {
        return;
    }
    
    new 
Float:flPlayerOrigin];
    new 
Float:OrigENT];
    
pevidpev_originflPlayerOrigin );
    
peventpev_originOrigENT );
        
    
flPlayerOrigin] += 4.0;
    
    
engfuncEngFunc_SetOriginentflPlayerOrigin );
    
    
engfuncEngFunc_SetModelentgModel );
        
    
set_peventpev_solidSOLID_SLIDEBOX );
    
set_peventpev_movetypeMOVETYPE_NONE );
        
    
set_peventpev_framerate1.0 );
    
set_peventpev_sequence"spin" );
    
engfuncEngFunc_SetSizeentFloat:{ -10.0, -10.0, -10.0 }, Float:{ 10.010.010.0 } );
    
engfuncEngFunc_DropToFloorent );
    
set_peventpev_nextthinkget_gametime( ) + 1.0 );
    
    new 
Float:distancia
    distancia 
get_distance_fflPlayerOriginOrigENT )
    
    
client_print(idprint_chat"Distance between me and ent is: %s"distancia)
    



Hunter-Digital 09-20-2011 23:30

Re: [HELP] get_distance_f
 
The main problem in that code is that you're printing float values as string, that's why it's printing weird stuff.

And:
- Entities are created in the center of the map by default, you're getting distance between player and center of map basically.

- I think pev_sequence accepts numbers not strings, like the engine's EV_INT_sequence.

- You don't need to create a variable if you're going to use the function only once.


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

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