FiveM Scripting 13 - Using FiveM Natives | Back to the Basics (2)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] today receive a ton of perks including just school rose early access content private support channels code snippets and more join today at patreon.com slash ever GS okay so what is my name is duo from Java today I'm gonna be slowing things down I know I've been doing maybe some advanced things for some people and some people just do not even understand what I'm doing so I'm gonna be I'm gonna be starting or I'm gonna be continuing this series back to the basics I think it was 5 I'm scripting 12 or 11 I don't know but I tried slowing things down for slower users and that wasn't even good enough or that that video was not that good but I can do a better job and I'm just gonna start from start from the beginning here for this series back to the basics so pretty much what I'm gonna do is just today in this episode I'm just gonna be showing you how natives work in five and you might have heard him but natives are pretty much code that was already written for the environment and you know they're functions that were predefined when you're in this environment so these gta5 natives will only work in this environment which is 5m and anything else all right if it's outside it will not work it only work in 5 m so I'm gonna be showing you just basic things on what a native really does so I mean there's there's a bunch of things there's a bunch of natives as you can see this list goes all the way down and there are a bunch of categories so I'm gonna start out I'm just gonna be showing you the categories or CFX which is what was made for 5m that was added with by 5m there's an app which is from GTA 5 and did the rest are you know that there there are ton of categories but they they go down for a long time and you can see that this is this is how you this how you you pretty much interact with a game there are so many natives to use so let's get right into it I'm going to be I'm gonna be sure I'm gonna be using this I don't even have a script for this video I don't have any way of structuring this video so I'm just gonna be doing it with you guys but I've pre-made this script called eval or it's a it's a command that pretty much lets me execute JavaScript but through the chat which is not not a good idea I just made this this code is actually in our private it's in our private channel for page Patrick patrons patreon.com/scishow Jimmy G is if you want to ever become one but yeah so this pretty much lets me you know it says it right here it lets me execute anything in JavaScript and I wrote this in JavaScript just because but it's the same thing as lua i when were just talking about natives so I'm gonna be showing you just I'm gonna be showing you get player head which is a native this is probably one of the most important natives because you're essentially getting the player that you are sourcing it to so if I were to click enter it would return a number which is my unique number for this at least so if I were to this unique number will work in it a lot of things so I'm gonna actually be showing you I'm also doing this I don't want you to write anything with me I mean if you want if it helps you go ahead I just want to show you how these natives work so I'm gonna be this is already a blank file where's yeah it's it's in a resource that we made or actually that I made before the video so pretty much I'm just gonna be writing I'm gonna be showing you native so get player pet let's see where we can use here I'll show you get player ahead so this returns a or it doesn't it returns a number but it's it still uses your player source so if I were to do like register and then I do let's call it wish I do I'll just use player this is I'm registering a command to my server right now so I'm gonna be using the two arguments source and args click and I'm going to type in there so that pretty much just registers the command all the syntax this this this is also a native and five them actually show you register command it it has a the command name which is the first parameter I'm going to show you how you can like actually use these native so you could see that the first parameter is the command name which is a string and we put that in the string the handlers a function you could see that you know there's a function and then restricted right here you can see what restricted does but we're not gonna do anything with ace permission so we don't even need to do that so I'm gonna do I was gonna what's called I was gonna show you we're going to print print is a this is a native looat function so it'll come in any version of Lua print which pretty much just outputs anything into command log or into just the lock so I'm going to do get player head - one I have to follow syntax here the player pet is in function and I minus 1 which is sourcing it to you but you could see it here I'll restart actually we need to do there I'll restart basics which is the thing that we're using I forgot a parenthesis what did I do I put one more extra let me restart that ok so this will when I do slash player it'll print out my player my unique player ID that we will be using so I'm going to do slash player and if I go into the f8 which is my client console you can see that it prints out two five eight here I don't know if you can see that well but it'll print that out there and if I were to do so okay so pretty much when you do register command it uses or it handles two parameters so the args which is whatever you write after you know we've talked about this and other episodes whatever you write after the command as arguments and source is the player that wrote wrote it so if I were to do source it should theoretically return the same - maybe let's see actually I don't know do such player yeah okay so it does it'll return the same exact unique number that it did when we when wrote or when we initially did it with - one okay sorry about that my computer just died there for a brief brief moment there you can see that it's dying pretty hard here but what I was gonna do was there's also another function native called the player pet ID and I prefer this one but it's not good in some instance but it just it doesn't require any parameters so I guess it makes things simpler it's just plug our pet ID you put it in I'm gonna up a pet in I'm gonna restart it actually I don't restart basics and when I do player oh yeah by the way if you do slash player it's the same thing as doing it in the console so I'll just be doing it in the console you can see that it returns the same the same player number but uh you know I didn't even showed I think I don't remembered where I left off on the last part of it before my computer kind of died so I'm gonna do slash to die and I'm gonna show you that the player pet ID its it pretty much or it kind of makes it kind of makes a new thing when you every time you die so this time it's five it's constantly going up that's intended until I guess the server restarts I think I don't know or when you restart your game rejoin but yeah that's how that works now I'm gonna be showing you I'm gonna be using more native so natives that use the player source so what we were doing here was initially we were just gonna go find it get player player so we were doing get player pet and we were using the source of us which was right here so now we could use natives like get player name and it's using the same thing so I'm gonna do get a player name and it says it uses the player source so I'm just gonna be using it through the function or through this command here so I'm just gonna type in source restart it I'm sorry about that restart basics and then I'm gonna type in player and it's gonna return my my name I think that's Steam I don't remember I think it might be steam whatever it name goes off your name now let's see another native that let's try like get server ID this will be like the same thing and you can see this is right here see a citizen FX API set this is the client and we've been using this main.lua I made it in the client in the client just to disregard that and I'm gonna do get server ID and then it'll be using my source I'm gonna restart it restart the resource and then I'm gonna type of player and you can see that my server ID it's saying what I am I am server ID 1 and I could show you but if you look right there it says ideas once so I'm gonna do another I'm gonna do a couple more natives let's see here you could do get registered commands this doesn't require any parameters it looks like because you could see that there's nothing after it but you could see that it's gonna return an array right here yeah so let's try that I'm gonna just copy that and I'm going to print this I think it's gonna return it might this might not work because your start basics and I take a player yeah it's gonna return a table because this is Lua and in Lua you can't dump tables out like in JavaScript but if I were to do this in JavaScript in fact let me just try that will just disregard what I'm doing I just want to show you that this array works I this is a little cleared thing I just want to show you that there's nothing special about this I'm just gonna change this to show or actually I will just call it show I just want to show you how this works this isn't JavaScript so just disregard it but how to do console dot log we're doing get registered commands we're going to register it's gonna show all the registered commands and pretty much what they do is gonna restart basics and I'm going to type in show slash show and you could see that's these are all the registered commands there are ton because do you see this is help from evil are evaluate connect CMD list yeah there's a ton that works too but yeah okay so pretty much I'm going to gonna be doing more into this I'm gonna revert back to what we were this was a little clearer skirt just so I could clear the chat I kind of forgot about but I'm gonna be showing you what this player source now gets used into so I'm going to be doing get vehicle now we've done this before but I never really explained in a good manner so I'm gonna do get vehicle ahead is in you could see that there's a get vehicle ped is using by the way I never even said anything about it this website I'll put in the description I'm sorry I completely forgot but yeah this is just like all the natives in 5m so there's a there's one called get vehicle pet is in get vehicle pet is using and get vehicle pet is trying to enter so I'm just gonna be using get vehicle or get vehicle pet is in you can see that this requires a ped it's using a ped parameter and a last vehicle parameter so you can see that this is a boolean so they're right here and this is this player source or it's gonna be something like that so I'm actually going to make it yeah I'll make it print it out I'll enter this just so you guys can see better excuse me and now I'm gonna type it and get vehicle if I kind of copy it yeah vehicle pet is in and I'm gonna be typing player head actually let me make sure that I'm doing this right player head yeah there's a player pet yes okay so they're eager you're supposed to use player pet ID I'm gonna go back to where I was at right here player pet ID we're using the player source again which is also works as pet I'm gonna be using player pet ID because I prefer that and then the boolean it says if it's false if we make this false then it'll be the current vehicle if it's true then it'll be the last vehicle we were in so I'm just gonna make it false because I want it to be in the one we are currently in so yeah so when I actually run this it should be giving me a null or it should be giving me a value that doesn't really exist so I'm gonna do restart basics and I'm gonna be typing in player yeah should be giving me something zero so now let's go into this little vehicle right here I'm gonna go in I want to show you that the valley is gonna change so it's gonna be zero and when I do slash player now it should be an actual number and I think it should change I mean this this numbers definitely gonna be the same I think I never really looked into it yeah it's gonna be the exact same David say that yeah okay oh yeah if I were to go into this jet right here it's gonna give me a different number let's go into that okay I'm gonna type in player and it's giving me a different number because we are in a different vehicle okay so now I'm gonna be using a little bit of JavaScript or not I'm saying maybe using a little bit of lieu of logic here so just to you know maybe show you guys how you know we'd actually want to use this so if get player so this number returns a 0 when there's no car in it or when you're not in a vehicle so I'm gonna do if it's equal to 0 then and and you always want to end your conditionals so if it's equal to zero then we're going to print not in a vehicle and then if it is will actually do else and and then if it is anything else then we're going to print that you are in a vehicle so now I'm going to be showing you how that works so if I were to do player it says I'm not in a vehicle but if I do go under there yeah now I am in a vehicle because now I am in a vehicle so that's pretty much that I'm gonna go back to what I was doing previously okay so what else is there there are so many natives and I like to just show you the get ones because they're easy they and they return numbers now oh yeah okay I was doing ok I'm going way too far back okay so I'm gonna go back to where it currently was so this is gonna be the vehicle the the number that we're returning that this native returns is go is gonna be used in what we're actually gonna be it's gonna be reused in wherever it uses the vehicle parameter when you see vehicle here so I'm actually going to in fact I'm just gonna do local vehicle for short is equal we're gonna store this in a variable a local one and and we're going to actually be using it in in another native where it requires the vehicle like I just said so we can there's a ton of them so I'm gonna be let's just find one I guess get vehicle fuel level let's see I'm just gonna right click that and then we're going to actually I want to make it great because we just want to show the value get vehicle fuel level and then since it's using the vehicle as the parameter I'm gonna be using this because this returns a vehicle unique number so I don't know what term that's called but this should theoretically return ever give us the number of feel I don't even know how that I've never used this native so yeah let's type in player there's no such entity because we are not inside of the vehicle get into here if I were to click do slash player you can see that it's sixteen point five I actually don't know how a pretty sure it isn't fuel unlimited in GTA so I don't think it like matters but I just want to show you how that native works with vehicle parameters sort of do yeah it's good it's probably gonna be the same thing every time because it doesn't matter it's fun another one that requires the vehicle so this time will actually make it set will make it set the vehicle whatever uses the vehicle so I'm gonna do sit give me a second here actually everybody sorry about that let's see here I'm gonna do something said vehicle I'm gonna find turbo pressure now we're gonna do current rpm so I'm gonna be copying this and it's gonna be setting that I think this has to be run every thread I'll go into threads next episode because this is already a long episode I just want to show you this works so set vehicle I'm gonna make it set it so it's gonna require the vehicle parameter and then rpm as an integer so we're gonna do V and a number let's just I don't know the scale for this I'll just do 900 let's see how that works and this isn't that native if it has to be run I might have to be run every frame let's see here player yeah I think it has to be run every frame but uh yeah actually I don't know this is fast yeah I actually do not know but I should go in the car okay that didn't really even spawn in anything they could do that again here we go okay I don't even know if it changed anything here I'll make it a huge number okay yeah I don't maybe I don't know but I'll definitely go into more of this it's just been a long video and I'll if you guys want another video explaining natives just ask for it yeah let me see if there's any more natives that might need me to like clarify I mean I just want to show you how it works if it's asking for something like a vehicle then it's gonna want something that returns a vehicle native so or you know a vehicle number yeah I just wanted to show that thank you guys for watching that's kind of the end of the video and yeah I hope you guys enjoyed it make sure to subscribe and like for more videos and yeah I'll see you guys later
Info
Channel: Jeva
Views: 21,755
Rating: undefined out of 5
Keywords: Fivem, zua, fivem scripting, fivem coding, fivem lua, how to code, lua, gta v modding, gta v scripting, gta 5 scripting, gta 5 modding, fivem roleplay, fivem rp, gta 5 natives, natives program, jevajs, jeva, gta hack, fivem hack
Id: dVB0a2YYANE
Channel Id: undefined
Length: 22min 27sec (1347 seconds)
Published: Wed Jun 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.