AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Origin -> Units (https://forums.alliedmods.net/showthread.php?t=117709)

wrecked_ 02-03-2010 20:03

Origin -> Units
 
Alright, so I'm working on a plugin that involves finding the origin before an entity is mvoed, and then AFTER an entity is moved, and I need to subtract these two origins and then convert them to units. I've searched both LJ Stats plugins and have found nothing on how to convert the origin (which, when I tested it, was about 9 digits each axis) to units. If you're not familiar with LJ Stats, it gives an amount of units (usually around 240, 250, etc.) instead of the origin number. If anyone could give me an equation or method of converting these two things, I'd appreciated it.

Thanks.

minimiller 02-03-2010 20:41

Re: Origin -> Units
 
im not sure if this is what u want, but using get_distance_f() will return the distane between the 2 origins

wrecked_ 02-03-2010 20:46

Re: Origin -> Units
 
Would this return the value in a float like 250.6789? Or would it give me some random origin like the nine digit one that I explained in my last post?

Sylwester 02-03-2010 23:03

Re: Origin -> Units
 
If you want to find distance between 2 origins you can do it this way:
PHP Code:

    new Float:o[3], Float:v[3]
    
//now store your origins in o and v
    
v[0] = v[0]-o[0]
    
v[1] = v[1]-o[1]
    
v[2] = v[2]-o[2]
    new 
Float:distance floatsqroot(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) 


wrecked_ 02-03-2010 23:11

Re: Origin -> Units
 
I'm very aware as to how I can store origins, but I need them to be stored in a certain way. If I had done the way that you've presented, I'd end up with a 8-10 digit number, doing me no good. I need a value to come out such as 256.8726 or something of that sort.

Exolent[jNr] 02-03-2010 23:30

Re: Origin -> Units
 
My LJStats uses get_distance().
The difference is that it uses the distance from where the player jumped to where the player landed.

Code:
new Float:fUnits = get_distance_f( vStartOrigin, vStopOrigin );

wrecked_ 02-03-2010 23:34

Re: Origin -> Units
 
Ah, thought it would be a little more complicated than that.

Thanks Exolent.

Sylwester 02-04-2010 01:08

Re: Origin -> Units
 
Quote:

Originally Posted by wrecked_ (Post 1077783)
I'm very aware as to how I can store origins, but I need them to be stored in a certain way. If I had done the way that you've presented, I'd end up with a 8-10 digit number, doing me no good. I need a value to come out such as 256.8726 or something of that sort.

It's stored in the same way everywhere. It's just displayed differently.

PHP Code:

    new Float:distance
    
// get distance ...
    
new msg[128]
    
format(msg127"distance: %.4f"distance



All times are GMT -4. The time now is 07:26.

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