Malganys23 Posted December 11, 2022 Share Posted December 11, 2022 Hi, I'm trying to make a mission system and other stuff with peds but I've a limited idea how to do it on scripting, basically what functions to use. My idea is to detect if player is near ped dynamically, I tried to use onClientRender but is it the best way? Thanks in advance for any answer. Link to comment
mafioz Posted December 11, 2022 Share Posted December 11, 2022 Greetings! You can create a sphere and attach it to the player on the client side, then you can control the elements entering the sphere (that is, the closest elements) Link to comment
Trust aka Tiffergan Posted December 11, 2022 Share Posted December 11, 2022 To detect if a player is near a ped, you can use the isElementWithinColShape function. This function takes two arguments: the first is the element you want to check (in this case, the player), and the second is the colshape you want to check if the element is within (in this case, the ped). If the player is within the colshape of the ped, the function will return true, otherwise it will return false. Here is an example of how you might use this function in your script: function onClientRender() local player = getLocalPlayer() -- get the local player local ped = getPedOccupiedVehicle(player) -- get the ped the player is in if ped then -- if the player is in a ped local pedColShape = createColCircle(getElementPosition(ped), 5) -- create a colshape around the ped if isElementWithinColShape(player, pedColShape) then -- check if the player is within the colshape -- player is within 5 units of the ped, so do something here end end end Link to comment
Malganys23 Posted December 11, 2022 Author Share Posted December 11, 2022 Thanks to both for answering, now I've an idea what to do Link to comment
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