Raised This Month: $ Target: $400
 0% 

[HELP] get_distance_f


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheArmagedon
Senior Member
Join Date: Sep 2010
Location: Unknown Source
Old 09-20-2011 , 21:43   [HELP] get_distance_f
Reply With Quote #1

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)
    

TheArmagedon is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-20-2011 , 23:30   Re: [HELP] get_distance_f
Reply With Quote #2

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.
__________________
Hunter-Digital 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 19:44.


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