Quantcast

Jump to content

» «
Photo

[VB.NET] How do I detect specific objects within a radius of 0.5ft?

5 replies to this topic
FabricOfFortune
  • FabricOfFortune

    Player Hater

  • Members
  • Joined: 12 May 2014
  • United-States

#1

Posted 13 May 2014 - 06:00 PM

I remember doing it once but I do not remember how I did it.

 

But basically, I want to detect specified models (like cj_hippo_bin and cj_dumpster_2) if they are within a radius of .5. I know I need to do it with Player.Character.Position.DistanceTo() but I do not remember how store object names and such.


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#2

Posted 13 May 2014 - 06:33 PM Edited by LordOfTheBongs, 13 May 2014 - 06:34 PM.

World.GetAllObjects() will return an array of objects... just loop through it and check each object's properties to identify the object ur trying to find... u can either look at scripthookdotnet source code or put it in a reflector like ilspy if ud like to see all the available properties in the object class or u can use visual studio's object browser but i dont like using it


FabricOfFortune
  • FabricOfFortune

    Player Hater

  • Members
  • Joined: 12 May 2014
  • United-States

#3

Posted 13 May 2014 - 06:37 PM

World.GetAllObjects() will return an array of objects... just loop through it and check each object's properties to identify the object ur trying to find... u can either look at scripthookdotnet source code or put it in a reflector like ilspy if ud like to see all the available properties in the object class or u can use visual studio's object browser but i dont like using it

I'm a beginner at this and I don't exactly know how to do it with those methods. 

 

What I remember doing originally was "For each <insertobjecthandle> In World.GetAllObjects() Then"

 

I just do not remember how to store the object model name. I'm about as far as Private Object1 As GTA.Object. I don't know where to go from there. I would expect that I would have to put Object1 = <insert objecthandle> but I don't know how to.


julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#4

Posted 13 May 2014 - 08:36 PM

i recommend filter the object model in the getObjects because its a heavy process:

For each o as gta.object in world.GetAllObjects("w_grenade")

...

Next

 

 

seems that scripthook convert the string to model or create the model based on string, so you can use the name there instead of a Model


FabricOfFortune
  • FabricOfFortune

    Player Hater

  • Members
  • Joined: 12 May 2014
  • United-States

#5

Posted 13 May 2014 - 09:06 PM

i recommend filter the object model in the getObjects because its a heavy process:

For each o as gta.object in world.GetAllObjects("w_grenade")

...

Next

 

 

seems that scripthook convert the string to model or create the model based on string, so you can use the name there instead of a Model

Thank you both. Is there a way to use IsRequiredForMission on an object though? In another thread I asked for the opposite of NoLongerNeeded and was given that, but as far as I can tell I cannot use it on an object. I want to make it not despawn.


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#6

Posted 13 May 2014 - 11:48 PM Edited by LordOfTheBongs, 13 May 2014 - 11:52 PM.

 

i recommend filter the object model in the getObjects because its a heavy process:

For each o as gta.object in world.GetAllObjects("w_grenade")

...

Next

 

 

seems that scripthook convert the string to model or create the model based on string, so you can use the name there instead of a Model

Thank you both. Is there a way to use IsRequiredForMission on an object though? In another thread I asked for the opposite of NoLongerNeeded and was given that, but as far as I can tell I cannot use it on an object. I want to make it not despawn.

 

if u spawn an object it shouldnt delete on it's own unless you cal NoLongerNeeded(), are u sure u tested?

 

here are all available methods and properties in object class, take a look at source code or use something like ILSpy to look at the code so u know what ur doing. You can see what native functions do what ;)

 

ky0poLF.png

 

u can see the method u want to use just wraps this native for u... MARK_OBJECT_AS_NO_LONGER_NEEDED (shown here http://www.gtamoddin...tive_functions)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users