Potato_Tomato420 Posted June 2, 2021 Posted June 2, 2021 (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 i know it's not great) Edited June 2, 2021 by Potato_Tomato420
Moderators IIYAMA Posted June 2, 2021 Moderators Posted June 2, 2021 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! 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Potato_Tomato420 Posted June 3, 2021 Author Posted June 3, 2021 Thx!! Got it working I created a function to check if the lineOfSightClear is clear from any object and then triggerServerEvent to spawn the vehicle. 1
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