Jump to content

Detecting a world object


Recommended Posts

Posted (edited)

Hi all, is it possible to detect a gta world object within a colshape?
For example: can i create a colshape in front of the player and then use isElementWithinColShape to detect if there is anyting inside the col? Even a object from the game itself?

I have created a vehicle shop with a control panel to spawn purchased vehicles.
But i have a little problem with the spawning part.

I use getElementPosition to detect the players x, y, z and the createVehicle (x, y, z).
But now i can spawn a vehicle inside a wall.

To prevent this from happening i want to create a colShape in front of the player and then check if there are any element withing the colShape, so also walls from the game itself.

Somebody any idea how i could detect this or resolve it?

(Sorry for my english xD i know it's not great)

Edited by Potato_Tomato420
  • Moderators
Posted
1 hour ago, Potato_Tomato420 said:

Somebody any idea how i could detect this or resolve it?

 

Not sure what the best approach is.

 

Kashtesov released a function that allows you to get the ground position serverside of the GTA san world.

 

But it would be probably better for your user case:

1. Send triggerClientEvent

2. Draw lines at the place where you want to place the vehicle and check for any collision.

https://wiki.multitheftauto.com/wiki/IsLineOfSightClear

3. Then confirm if there is any space: triggerServerEvent

That way you also take custom objects in account.

 

Or you can also combine those methods.

Good luck!

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...