AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NAN orgin :S (https://forums.alliedmods.net/showthread.php?t=107573)

ogelami 10-27-2009 22:24

NAN orgin :S
 
PHP Code:

    new ball[] = "models/head.mdl";
    new 
float:AimingFrom[3];

public 
plugin_precache(){
    
precache_model(ball);
}
public 
plup(id){
    
    
get_user_origin(id,AimingFrom,1);
    
    new 
entid create_entity("info_target")
    
entity_set_string(entidEV_SZ_classname"some_guy")
    
entity_set_model(entidball)
    
entity_set_origin(entidAimingFrom)
    
    
entity_set_int(entidEV_INT_solid1)
    
entity_set_int(entidEV_INT_movetype6)



This returns to nan orgin when get_user_origin returns a negative number.
And when i set the numbers all by my self the entity dosen't get spawned i have precached the model.

Xellath 10-28-2009 16:01

Re: NAN orgin :S
 
The get_user_origin() function does not return a floated value. And entity_set_origin() sets an origin(floated one).

So you'd have to do it like this(using IVecFVec()):

Code:
new iOrigin[ 3 ], Float:fOrigin[ 3 ]; get_user_origin( id, iOrigin, 3 ); // 3 is ending position from eyes(crosshair) IVecFVec( iOrigin, fOrigin ); // integer origin converted to float entity_set_origin( ent, fOrigin ); // entity at that origin

or you could just use float().

Code:
new iOrigin[ 3 ], Float:fOrigin[ 3 ]; get_user_origin( id, iOrigin, 3 ); // 3 is ending position from eyes(crosshair) fOrigin[ 0 ] = float( iOrigin[ 0 ] ); fOrigin[ 1 ] = float( iOrigin[ 1 ] ); fOrigin[ 2 ] = float( iOrigin[ 2 ] ); // im not sure but i think you could do this also // fOrigin = float( iOrigin ); entity_set_origin( ent, fOrigin ); // entity at that origin

xPaw 10-28-2009 16:33

Re: NAN orgin :S
 
@Xellath: IVecFVec( ) is a stock using float( ).

PHP Code:

stock IVecFVec(const IVec[3], Float:FVec[3])
{
    
FVec[0] = float(IVec[0]);
    
FVec[1] = float(IVec[1]);
    
FVec[2] = float(IVec[2]);

    return 
1;



Xellath 10-28-2009 17:10

Re: NAN orgin :S
 
Yeah, saw that when I looked closer on the stock. Anyway, it's perfectly fine to write it both ways, no difference at all.

xPaw 10-28-2009 17:35

Re: NAN orgin :S
 
Yeah, just for info

ConnorMcLeod 10-28-2009 17:57

Re: NAN orgin :S
 
But you can't do :

// im not sure but i think you could do this also
// fOrigin = float( iOrigin );


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

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