[Snippet] A Method of taking nearest random vehicle

Since, 0AB5 do not work in Multi-Player. There is a simple method of taking nearest car with specific radius!


PHP:
00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@ // This will store the XYZ Position in Variable 1@ 2@ 3@ (X = 1@, Y = 2@, Z = 3@)
 0AE2: 4@ = random_vehicle_near_point 1@ 2@ 3@ in_radius 10.0 find_next 0 pass_wrecked 0 // random car in near point and

Kinda useless but snippet is snippet!

Constant radius i recommend is 9.0
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
RE: [Snippet] Get nearest Vehicle with specific Radius

this doesnt take the nearst car! it takes the first car inside the memory in a predefined radius.
 

Ninja FTW

Active member
Joined
Aug 11, 2017
Messages
61
Reaction score
0
Location
Saturn
RE: [Snippet] Get nearest Vehicle with specific Radius

Opcode.eXe said:
this doesnt take the nearst car! it takes the first car inside the memory in a predefined radius.

Add a activation with jump at the end. Each time you'll Enter the Activation code in different place.. each time it'll take nearest car which will store the new car inside the memory.

Add few lines like (radius 6@ and then 6@ += 1.0) and edit it everytime in-game with a particular key and connect it with '0AE2'. That's all. 

Looks complicated when reading but easy in making.
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
RE: [Snippet] Get nearest Vehicle with specific Radius

Ninja FTW said:
Opcode.eXe said:
this doesnt take the nearst car! it takes the first car inside the memory in a predefined radius.

Add a activation with jump at the end. Each time you'll Enter the Activation code in different place.. each time it'll take nearest car which will store the new car inside the memory.

Add few lines like (radius 6@ and then 6@ += 1.0) and edit it everytime in-game with a particular key and connect it with '0AE2'. That's all. 

Looks complicated when reading but easy in making.

Then you should rename the snippet or add some description in it
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
RE: [Snippet] Get nearest Vehicle with specific Radius

Seems like a pretty pointless snippet tbh as most people want snippets for complex stuff that takes a bunch of math and memory coding to accomplish. Whereas this is not that hard to figure out on your own.
 

Ninja FTW

Active member
Joined
Aug 11, 2017
Messages
61
Reaction score
0
Location
Saturn
RE: [Snippet] Get nearest Vehicle with specific Radius

Zin said:
Seems like a pretty pointless snippet tbh as most people want snippets for complex stuff that takes a bunch of math and memory coding to accomplish. Whereas this is not that hard to figure out on your own.

Why not easy and making newbies life easy.


supahdupahnubah said:
Then you should rename the snippet or add some description in it

There is no need to. It's very same like that opcode which does not work in MP anymore. It finds a closest car but random closest! Now, the setting of radius and opcode magic.. it's becomes familiar like closest opcode.
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
RE: [Snippet] Get nearest Vehicle with specific Radius

Ninja FTW said:
supahdupahnubah said:
Then you should rename the snippet or add some description in it

There is no need to. It's very same like that opcode which does not work in MP anymore. It finds a closest car but random closest! Now, the setting of radius and opcode magic.. it's becomes familiar like closest opcode.

Closest car in area != Random car in area, it will fail in more serious calculations, since it will give you "random" handle of a car, that's what I'm trying to say
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
RE: [Snippet] Get nearest Vehicle with specific Radius

Code:
0AB1: @GET_CLOSEST_CAR 0 0@

:GET_CLOSEST_CAR
8@ = 300.0 // search radius
9@ = -1 // make vehicle invalid
IF
0AE2: 0@ = random_vehicle_near_point in_radius 300.0 find_next 0 pass_wrecked 0
THEN
    REPEAT
    IF    
    056E:   car 0@ defined
    THEN
        00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
        00AA: store_car 0@ position_to 4@ 5@ 6@
        050A: 7@ = distance_between_XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@
        IF         
        0025:   8@ > 7@  // (float)
        THEN
            0087: 8@ = 7@ // (float) // set search radius to closest
            0087: 9@ = 0@ // (float) // store car
        END        
    END
    UNTIL 8AE2: 0@ = random_vehicle_near_point 0@ 1@ 2@ in_radius 300.0 find_next 1 pass_wrecked 0
END
0AB2: ret 1 9@
Here it will loop through all vehicles and filter the closest one out!
 

Ninja FTW

Active member
Joined
Aug 11, 2017
Messages
61
Reaction score
0
Location
Saturn
RE: [Snippet] Get nearest Vehicle with specific Radius

Lol, if you've read the topic.. I've said that it's just a method of taking nearest car.. not an actual or total opcode.
 

Based_Racist

New member
Joined
Nov 20, 2020
Messages
1
Reaction score
0
Location
Nigger
RE: [Snippet] Get nearest Vehicle with specific Radius

Code:
0AB1: @GET_CLOSEST_CAR 0 0@

:GET_CLOSEST_CAR
8@ = 300.0 // search radius
9@ = -1 // make vehicle invalid
IF
0AE2: 0@ = random_vehicle_near_point in_radius 300.0 find_next 0 pass_wrecked 0
THEN
   REPEAT
   IF    
   056E:   car 0@ defined
   THEN
       00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
       00AA: store_car 0@ position_to 4@ 5@ 6@
       050A: 7@ = distance_between_XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@
       IF        
       0025:   8@ > 7@  // (float)
       THEN
           0087: 8@ = 7@ // (float) // set search radius to closest
           0087: 9@ = 0@ // (float) // store car
       END        
   END
   UNTIL 8AE2: 0@ = random_vehicle_near_point 0@ 1@ 2@ in_radius 300.0 find_next 1 pass_wrecked 0
END
0AB2: ret 1 9@
Here it will loop through all vehicles and filter the closest one out!


Thanks for that one.
 
Top