Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Sometime get "ghost" ped?


123iamking
 Share

Recommended Posts

I'm using these functions to get ped

PED::GET_CLOSEST_PED(vec.x, vec.y, vec.z, 1000.0f, 1, 1, &ped, 0, 1, -1)//p4 must true, p7 is get playeror Ped GetClosestPed(Vector3 crtPos){    Ped peds[ARR_SIZE];    Ped chosenPed = 0;    int count = worldGetAllPeds(peds, ARR_SIZE);    float minDis = FLT_MAX, crtDis;        for (int i = 0; i < count; i++)    {        if (playerPed != peds[i] && ENTITY::DOES_ENTITY_EXIST(peds[i]) && !PED::IS_PED_DEAD_OR_DYING(peds[i], 1))                    {            crtDis = Distance(crtPos, ENTITY::GET_ENTITY_COORDS(peds[i],1));            if (crtDis < minDis)            {                minDis = crtDis;                chosenPed = peds[i];            }                        }    }    return chosenPed;}

But sometimes I got - I don't know how to call it - "ghost" ped, maybe.

This ped:

is exist - It got through the check ENTITY::DOES_ENTITY_EXIST(ped)

this ped has normal health and alive - the health is 150 for some, 175 for some, it got through the check !PED::IS_PED_DEAD_OR_DYING(peds, 1)

can't be seen - but it's still there, I teleport the ped I got in front of the player,the player can still punch it, insult it - but like punch and insult the thin air.

can't be burnt - I toss molotov to burnt it but can't see the burnt body,

has normal model - I get the entity model and set the model to the player - it works.

my get ped function keep getting the "ghost" ped for a while unless I leave the area - or the ped is gone.

 

Note that the same problem also happens with vehicle, sometimes I can get warp into a ghost car - with mod, of course.

 

If you met this problem before and know how to detect the "ghost" ped, please tell me how.

If you didn't met this problem before, please tell me how to draw something - like corona at the ped's coords so I can check if it has bone.

 

Thank for reading :)

Edited by 123iamking
Link to comment
Share on other sites

You could check if the ped is visible using ENTITY::IS_ENTITY_VISIBLE(Entity entity).

 

There are many functions for drawing things, such as...

  • GRAPHICS::DRAW_LINE(float x1, float y1, float z1, float x2, float y2, float z2, int r, int g, int b, int alpha)
  • GRAPHICS::DRAW_POLY(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, int r, int g, int b, int alpha)
  • GRAPHICS::DRAW_BOX(float x1, float y1, float z1, float x2, float y2, float z2, int r, int g, int b, int alpha)
  • ...
Link to comment
Share on other sites

@Jitnaught

Forgot to mention, I have already check ENTITY::IS_ENTITY_VISIBLE(Entity entity) and it return TRUE.
I have tried GRAPHICS::DRAW_LINE(float x1, float y1, float z1, float x2, float y2, float z2, int r, int g, int b, int alpha) both alpha 255 and 0 but I can't see any line. maybe I need to put the line in a loop code

I gonna check if the "Ghost" ped is in air now.

Link to comment
Share on other sites

So I use the GRAPHICS::DRAW_LINE to draw a line
here is how it works with normal ped:

http://imgur.com/J4sBb6G

 

And here is the "ghost" ped:

toss it:

http://imgur.com/Wkbm3Ia

kick it:

http://imgur.com/gKRdZqv

 

As you can see, the ped can still be recognized by the player.
I have check the following with the "ghost" ped:

IS_ENTITY_ON_SCREEN -> TRUE
IS_ENTITY_A_MISSION_ENTITY -> FALSE
IS_ENTITY_IN_AIR -> FALSE

IS_ENTITY_VISIBLE -> TRUE
IS_ENTITY_A_PED -> TRUE
DOES_ENTITY_HAVE_DRAWABLE -> TRUE
DOES_ENTITY_HAVE_PHYSICS -> TRUE

Link to comment
Share on other sites

I realize that the "ghost" ped is the ped who is somewhere else, here how did I test it:
1. I got a test ped and turn on the red line (with DRAW_LINE), like this: http://imgur.com/hrOI2XI
2. I change player's model to this ped model.

3. I turn, walk around, suddenly the the red line leads me to the real ped.

4. I follow the red line and I found a ped whose model like my player's current model.

So I have tried other method to teleport ped like: SET_PED_COORDS_NO_GANG, SET_PED_COORDS_KEEP_VEHICLE, SET_ENTITY_COORDS_NO_OFFSET, but the problem still there.

Edited by 123iamking
Link to comment
Share on other sites

Ok, finally I got the solution: If the script can't distinguish "ghost" and real, I'll distinguish it myself.
In stead of using the get nearest ped function, I use my get alive ped function:

//Remember to get playerPed before use this functionPed GetAlivePed(){	Ped peds[ARR_SIZE];	int count = worldGetAllPeds(peds, ARR_SIZE);	for (int i = 0; i < count; i++)	{		if (playerPed != peds[i] && ENTITY::DOES_ENTITY_EXIST(peds[i]) && ENTITY::GET_ENTITY_HEALTH(peds[i]) > 0)		{			return peds[i];		}	}	return 0;}

and to avoid "ghost" ped, I do this

//pedForLoop is my global variable, so it will keep the last ped which I got last time//So to make sure, I kill the ped I get last time - in case it's the "ghost" ped - to avoid sticking with itif (pedForLoop != playerPed && ENTITY::DOES_ENTITY_EXIST(pedForLoop))	PED::APPLY_DAMAGE_TO_PED(pedForLoop, 1000, 1);//Clear ped, in case ghost pedpedForLoop = GetAlivePed();if (pedForLoop != 0 && ENTITY::DOES_ENTITY_EXIST(pedForLoop)){//Do anything I like in here with the new ped}

Thank for reading :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.