FiveM lua Scripting 3.1 - Introduction to Threads, finding ingame coordinates

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello so this time i will introduce you to threads and show you how to implement the website your script and how they work basically so what reds are and why do you need to use them and why do you want to use them so threads are used to run the code that has to be executed continuously like it could be it could be for a specific period of time or it could be for as long as the player is in the server or maybe until some specific actions are finished and you want to put that in the thread in a separate thread because then it does not interrupt any other code that is running in that file basically because every single file is running from top to bottom but if you for example you put a thread thread is gonna uh execute all the code independently so i created a little resource called the white red and just added effects manifest and client that file to so in here what i'm gonna do is i'm gonna create a new thread i'm gonna add a function handler so it's in here and here i'll add a while 3 loop and i'm gonna add citizen weight zero so what it means i created a [Music] new thread added a function handler that has this code inside while loop is executed while this condition is true so it could be for example one equal to one or one more than zero then it will be executed but it will be one less than zero since that is false that's not gonna be executed but now we're just gonna hard code it to true because we want this to be running for as long as the player isn't in the server also you need a citizen weight zero because otherwise for some reason if you don't just put that inside any while loop uh services uh the client machine is just gonna crash basically so yeah you always wanna wait uh inside every single way a while loop and uh inside the first line of the thread we're going to create a new variable called pads and we're gonna i'm gonna assign a player pet to it so in gta 5 player model or any human model even animal model are called basically described as peds and each of them have their own unique id basically so if new pen is created it gets its own unique id so basically what it does is it returns uh for each and every single client its own bed model id so why we need that we're going to create a new variable we're going to call it player chords and we're gonna say get empty chords and we're gonna put in pen here so this is gonna get coordinates of the player model basically or of position of player and now we're just gonna basically print player chords to so every single frame you're gonna see different coordinates uh if the player is moving and here we can add i don't know two thousand so that's gonna every two seconds player coordinates are going to be printed to the console so i can try doing it now i'm gonna refresh and start my thread resource let's see [Applause] and now every two seconds it should show my coordinates if i move the coordinates obviously are gonna change so this time i have a little task for you um i'll just leave the i will leave the link for it in the description uh but basically your task is to since now you know how to get player coordinates use draw marker native function to draw a couple of markers one directly on the player and one just somewhere on the map i have a few hints for you and good luck on this then so yeah in this video it's just gonna be that and i hope you found it helpful if you need any other help just join my discord which i'm going to leave in the description so thank you for watching see you next time
Info
Channel: daZepelin
Views: 1,247
Rating: undefined out of 5
Keywords: gaming, game, gtaV, Fivem, lua, scripting, programming, resource, writing, VSC, Virtual Studio Code, coding, code, script, program, mods, rp, multiplayer, Grand Theft Auto, roleplay, role play, role-play, role, play, tutorial, education, how to, help, discord, fx manifest, fx server, fxserver
Id: iEedPS_mEEs
Channel Id: undefined
Length: 6min 12sec (372 seconds)
Published: Thu Sep 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.