123iamking Posted April 14, 2016 Share Posted April 14, 2016 (edited) 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 April 14, 2016 by 123iamking Link to comment Share on other sites More sharing options...
Jitnaught Posted April 14, 2016 Share Posted April 14, 2016 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) ... Skorpro 1 Link to comment Share on other sites More sharing options...
123iamking Posted April 15, 2016 Author Share Posted April 15, 2016 @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 codeI gonna check if the "Ghost" ped is in air now. Link to comment Share on other sites More sharing options...
123iamking Posted April 15, 2016 Author Share Posted April 15, 2016 So I use the GRAPHICS::DRAW_LINE to draw a linehere 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 -> TRUEIS_ENTITY_A_MISSION_ENTITY -> FALSEIS_ENTITY_IN_AIR -> FALSE IS_ENTITY_VISIBLE -> TRUEIS_ENTITY_A_PED -> TRUEDOES_ENTITY_HAVE_DRAWABLE -> TRUEDOES_ENTITY_HAVE_PHYSICS -> TRUE Link to comment Share on other sites More sharing options...
123iamking Posted April 15, 2016 Author Share Posted April 15, 2016 (edited) 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/hrOI2XI2. 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 April 15, 2016 by 123iamking Link to comment Share on other sites More sharing options...
123iamking Posted April 15, 2016 Author Share Posted April 15, 2016 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 Jitnaught 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now