Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to get a random ped and attach a blip?

Featured Replies

Hi, don't know where should i post that....sorry if it's the wrong place.....

Hope you can help me.....

I've tried:




[...]

ped1 = World.GetRandomPed(Player.Character.Position, 20.0f);

blip1 = ped1.AttachBlip();

[...]

With this code i get a "blipped" random ped for 2 seconds....then the blip disappears. Don't know why. Moreover when i quit the game there's a kind of freeze....i've to quit with ctrl+alt+canc.....I'm sure the entire code is not wrong because if i change just the random ped part with a World.CreatePed etc. the script works fine and the game quits normally.

I'd like to get a random ped in a random position in one of the 4 islands.....so 20 as radius is low i know....but if i increase it then i don't see the blip even for a second. I think it's because the game try to pick a ped in some parts of the city that haven't been loaded yet....but that's just my guess.

The language is C.

Thanks!

  • Author

I see you did post this in GTA Forums too. And to be honest, you should have just kept it there.

This and gta forums are two different places. (the only 2 forums i follow about gta) But if i couldn't post it here, delete this thread... no problem. :wink:

Edited by Juventus

This and gta forums are two different places. (the only 2 forums i follow about gta) But if i couldn't post it here, delete this thread... no problem. :wink:

I think you can post a topic about it here. But i'm not sure if you will recieve much help from people. Although, maybe devs can help you out.

As you are using a random ped, the game will unload the random ped from memory, blip or no blip, hence why your blip disappears as the ped has disappeared. To stop this you need to use something such as ped1.BecomeMissionCharacter. Also try assigning some properties to the blip after you declare it. If you want, post the full module and I can help you out more.

"You tell me exactly what you want, and I will very carefully explain to you why it cannot be."

  • Author

As you are using a random ped, the game will unload the random ped from memory, blip or no blip, hence why your blip disappears as the ped has disappeared. To stop this you need to use something such as ped1.BecomeMissionCharacter. Also try assigning some properties to the blip after you declare it. If you want, post the full module and I can help you out more.

Thanks Sam for the reply.

I used ped1.BecomeMissionCharacter and the blip works....

As i thought, now the problem is the position....the "picked" ped is always very near me....actually too near, even if i set 1000 as radius...

I've tried this to fix the issue....


[...]

                      

                            Blip1 = Blip.AddBlipContact(World.GetNextPositionOnPavement(Player.Character.Position.Around(300.0F)));      

                            Blip1.Position = c;                                                                                                                                         

                            a = World.GetZoneName©;                                       

                            do

                            {

                                Wait(250);

                                b = World.GetZoneName(Player.Character.Position);

                            } while (a != b);



                            Ped1 = World.GetRandomPed(c, 10.0F);

                            Ped1.BecomeMissionCharacter();

                            Blip1 = Ped1.AttachBlip();

 [...]

...create a blip in a random position.....then, when i'm close to the position...get a random ped over there.....but the script doesn't work. Moreover i've a strange issue....(happened with World.CreatePed, too)....

9 times out of 10 i got a blip in this position....

gtaiv2011020218325749.th.jpg

gtaiv2011020218331221.th.jpg

That position is on top of a scyscraper...and there's no ped over there...don't know whether it's a known issue or not.

Honeslty i don't like this solution...i'd like to get a random ped directly.......is there any way to make the game load a random part of the city in order to get a random ped in that position? or something similar?

Thanks again for the help, Sam....you're very kind. (if you want i can post the whole script or whatever you want)

Edited by Juventus

About the position being in a skyscraper, sometimes I get that in LCPDFR. It seems that that position has the XYZ coords of 0,0,0 therefore if something goes wrong with the blip position, it will just be 0, hence why it spawns in the middle of the map.

Another thing you should know is that the GetRandomPed function is very unreliable and will not detect peds who are doing anything. The best method to use is World.GetPeds in a for loop where you can then loop through every ped in a specified distance. Something to try might be to set a position like Player.Character.Position.Around(100), and then do .Around(50) on that position - it should give you fairly good distances without too many errors.

"You tell me exactly what you want, and I will very carefully explain to you why it cannot be."

  • Author

About the position being in a skyscraper, sometimes I get that in LCPDFR. It seems that that position has the XYZ coords of 0,0,0 therefore if something goes wrong with the blip position, it will just be 0, hence why it spawns in the middle of the map.

Another thing you should know is that the GetRandomPed function is very unreliable and will not detect peds who are doing anything. The best method to use is World.GetPeds in a for loop where you can then loop through every ped in a specified distance. Something to try might be to set a position like Player.Character.Position.Around(100), and then do .Around(50) on that position - it should give you fairly good distances without too many errors.

ehm.... i don't get it....i'm sorry.

you mean something like this?

arraypeds = World.GetPeds(Player.Character.Position.Around(100));

arraypeds.getlenght(len);

for (int i = 1; i < len; i++)

{

?!?!?!?!?!

}

Edited by Juventus

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.