AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Distances and units:Solved: (https://forums.alliedmods.net/showthread.php?t=144505)

BigMac 12-04-2010 20:01

Distances and units:Solved:
 
How to detect if a player is 2 unit away from the ground?

hleV 12-04-2010 20:07

Re: Distances and units
 
Genious method.
Code:
#include <engine>   public Something(client) {         if (GetDistanceFromGround(client) == 2)         {                 // It's good         } }   GetDistanceFromGround(client) {         // Check if player is on ground?         // if (entity_get_int(client, EV_INT_flags) & FL_ONGROUND)         //         return 0;           new Float:clientOrigin[3], Float:groundOrigin[3];           entity_get_vector(client, EV_VEC_origin, clientOrigin);         drop_to_floor(client);         entity_get_vector(client, EV_VEC_origin, groundOrigin);         entity_set_origin(client, clientOrigin);           return floatround(vector_distance(clientOrigin, groundOrigin)); }
/sarcasm

BigMac 12-04-2010 20:12

Re: Distances and units
 
Thanks will try this

BigMac 12-04-2010 20:55

Re: Distances and units
 
PHP Code:

public Something(id)
{
 if (
GetDistanceFromGround(id) == 2)
 {
  
client_print(0print_chat"testing");
 }
}
 
GetDistanceFromGround(id)
{
        
// Check if player is on ground?
        // if (entity_get_int(client, EV_INT_flags) & FL_ONGROUND)
        //         return 0;
 
 
new Float:clientOrigin[3], Float:groundOrigin[3];
 
 
entity_get_vector(idEV_VEC_originclientOrigin);
 
//drop_to_floor(id);
 
entity_get_vector(idEV_VEC_origingroundOrigin);
 
entity_set_origin(idclientOrigin);
 
 return 
floatround(vector_distance(clientOrigingroundOrigin));


Why doesn't this work then?
I jump up and didn't get that message and when i jump down or fell down i still didn't get that message!

wrecked_ 12-05-2010 00:49

Re: Distances and units
 
Quote:

Originally Posted by BigMac (Post 1363369)
PHP Code:

public Something(id)
{
 if (
GetDistanceFromGround(id) == 2)
 {
  
client_print(0print_chat"testing");
 }
}
 
GetDistanceFromGround(id)
{
        
// Check if player is on ground?
        // if (entity_get_int(client, EV_INT_flags) & FL_ONGROUND)
        //         return 0;
 
 
new Float:clientOrigin[3], Float:groundOrigin[3];
 
 
entity_get_vector(idEV_VEC_originclientOrigin);
 
//drop_to_floor(id);
 
entity_get_vector(idEV_VEC_origingroundOrigin);
 
entity_set_origin(idclientOrigin);
 
 return 
floatround(vector_distance(clientOrigingroundOrigin));


Why doesn't this work then?
I jump up and didn't get that message and when i jump down or fell down i still didn't get that message!

The odds of you being able to use that command when you're exactly 2 units from the ground are slim. Try checking a range rather than an exact unit amount.

BigMac 12-05-2010 10:54

Re: Distances and units
 
Shouldn't the player hit the 2 unit mark on the way down from jump or even on the way up and past it? All i want to do is to check when the player is 2 units away from the ground before the player hits the ground.

hleV 12-05-2010 11:14

Re: Distances and units
 
Why did you comment the
Code:
drop_to_floor(id);
?

ConnorMcLeod 12-05-2010 11:19

Re: Distances and units
 
You want to fake jump bug ? cheat plugin ? :mrgreen:

BigMac 12-05-2010 11:48

Re: Distances and units
 
No I just want to check if player has is within 2 units of the ground return value false.
if i use this
if (entity_get_int(client, EV_INT_flags) & FL_ONGROUND)
It works after the player has hit the ground. I want the value to be false right before the player hits the ground.

@ConnorMcLeod You want to fake jump bug ? cheat plugin ?
No just a event that detects a player right before a player hits the ground thats all.

BigMac 12-05-2010 12:31

Re: Distances and units
 
Never Mind I got it Thanks for your help hleV


All times are GMT -4. The time now is 11:22.

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