Vectors and Scripts question

Hey Everyone I hope i post this in the right section. So i started learning about vectors and so far know how to set it as a spawn point … Now im just wondering is it possible to use vector in other ways for example

Lets say i want to pay a ticket and the players needs to be within a vector to /payticket is that possible? and if it is anyone can point me to the right direction… Im still learning and new to this still! But know the Beginner Basic of Lua and made some small scripts to test it out…so now im ready to learn about using vectors :slight_smile: Thank you for the support in advance

This page previews lot of neat calculations and other stuff with vectors

1 Like

I seen it but it didnt cover what i was wondering :frowning: unless i mis understand its explaining. :frowning:

I would look at the natives for distance checking:

https://runtime.fivem.net/doc/natives/#_0xF1B760881820C952

https://runtime.fivem.net/doc/natives/#_0x2A488C176D52CCA5

https://runtime.fivem.net/doc/natives/#_0xB7A628320EFF8E47

These allow you to pass two Vector values, and will return a single integer, which is easy for comparison.


You can see how I used it here, for example:

https://github.com/inferno-collection/Fire-Alarm/blob/master/[inferno-collection]/inferno-fire-alarm/client.lua#L837&L849

1 Like

Thank you i will check them out and see what i come with up:) time to set up those native and see how it works now :slight_smile: thank you all for the help i am very grateful for the support

1 Like

You don’t need natives for distance checking though, just simple maths

local coord1 = vec3(....
local coord2 = vec3(...

local distance = #(coord1 - coord2)

And it will always be faster than native

2 Likes

You are correct, some of us are just not as mathematically inclined :stuck_out_tongue: