FiveM Scripting 2 - GTA V Natives, Key Press, Giving Weapons.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey what's up guys my name is Zuo from Java today I'm going to be we're just gonna be doing some more 5 I'm scripting on natives keep pressing and giving guns just simple stuff I'm gonna try to keep it simple here so I have the code here on github up with this link in the description for you guys to see it's got all the code you can't follow along so yeah we're gonna gonna need you don't really need any of these actually you might required so this has the game controls that we're going to need you might need this this just has values for a gun so let's just get right into it I'll put all these links in the description so first we're gonna open up our server that we made in the previous episodes and we're gonna go to our c FX server data master resources and we're gonna be creating a new resource so to create a new resource like we've done last episode right click and you do folder and we're gonna call it guns just why not so um and we're gonna want to do is open up or we're gonna create a new file and call it underscore underscore resource and in there we're gonna open up for the vs which we've installed last episode hopefully I'm gonna open this loader this workspace so I can make files from there you can also just create it from there I'm gonna do yes because I like this so we're gonna call first one guns see blue guns client she's why we have that seat in here we're going to do client actually and we're also gonna create functions so the resource table we're gonna call we're going to type any client or scripts that script and that's gonna be an array you can open that up and in here you can type in functions and that should be fine so now what we're gonna do is I guess we could start writing now so in the function is not little I'm going to open this to the side using this little button and I have these two open so in here we're gonna define some functions because we just declared this in the same scope of this resource so what I'm going to do is in the function we're gonna declare a function call alert and this is going to be using a parameter of a message and also this is a gta5 native so to use this for gonna type in set text so function and we're gonna put pass through this parameter message we're due to just display text and these valleys don't really know what they do but test do with the native so yeah you could just type that in so we just ignored that function we're gonna type in some more functions here like notify we'll see what these does and what this does when we use it we're gonna have this parameter message too if you want notification and one more we're gonna do is give weapon function gonna have the ash of the weapon being passed through as a parameter and so what are you gonna do this is where it gets a little complicated just follow along it's kind of it's easy so just type in we're gonna use the local or the data to begin weapon I get another head and then this has a lot of parameters so just follow along so we're the first one we're gonna do get player head minus one which is this basically means you're giving the weapon to the player so that's basically a new one get you past the hash browns do this because essentially you're converting you will see how we convert this it automatically gets converted into from a string to the hash so then a new parameter this is the amount of animal you want so I'm just gonna do 99 for as much as we could put and this wasn't gonna be false this parameter is gonna be false are number reasons I don't know and then you can have this either true or false I'm gonna have a false basically the last parameter basically what it does is it's like when when you first get the gun it's going to equip it in your hands that I don't want to do that so now we have those functions declared in a gun see doubt Lua we're gonna start off with I'm gonna start off with creating a thread which is basically how you can find key presses this is a citizen create this isn't natives this is a5m stuff and then we're gonna pass through a function and I'm here typing and and then in here we're going to make two variables local age underscore P is equal to both local X underscore key so we have to find these so basically actually I'm gonna keep these blank until until we write this a walkthrough dubis which is basically just a loop and there's a lot of controversy I'm just moved because people hate having these useless loops being brain from stupid resources so yeah the dual citizen dot wait so there's a crash you need this or also crash your resource will crash your game and then we're gonna have an end for this loop right here and in here we're going to do if is roll just one which is the input group and then we're going to do the H underscore key and give weapon and then this this is the function that we declared them so basically what we're gonna have to do is find the weapon that you want so I know some but I'm gonna show you right here this is the weapon the list so let's say you want a pistol right here pista so what you're gonna want to do is have this name right here copy that and then put it in quotes type in weapon underscore and then pistol and let's also give weapon so that's gonna give these two guns when this H key is pressed but we have to find the H key so let's actually gonna add this first so the H key we have to find it in here so this what I'll put this link in the description like I said you have to find this on the right side H so let's look for H because that's that's the key that I want you can do any key you want just remember to set this variable as the key you want because this number is going to be put right here and which is equal to this key so let's find H because that's what I wanted us H is 74 so you're gonna paste H in here you don't that you can literally just take this 74 right here if you want but I just want to use I'll show you how variables work X key let's look for X that's right here 273 and paste that we'll see that I'll show you the other command that we're gonna do actually or do that and really ahead of myself I'm gonna do alert and let's see your alert and then this is to put the alert which is basically help text if you've never seen it up I'll put it on the top you'll see it like right here that's what help text is in GTA so to make this blue different blue green red there's there's more I'm gonna make it blue you have to have till days and then close that off sorry that's my discord going off and then type in I'm going to talk about given weapons and to actually see the outline of the key which you can see I'm going to do another one of this till date and then or is it 74 that we're using right here you can copy that that part paste that there and close that off and it'll look like it'll have like a little button outline so that's gonna alert that I'm gonna do another actually we don't need we don't need to do another one that's that's fine so that's it if if statement right there so now what we're gonna want to do is let's say you want to get rid of your gun so I'm up here I'm gonna make a command last episode kind of random and just a little review type in clear function this is the function and then end so then in here we're going to remove all native and then get we're going to get the player the current player and just like right here and then make that eight just we're removing all of this and then we could use this notify function right here notify even though they're in the different files by the way they'll work because we just declared of it in this scope so we just have to notify and it will be like I'll show you what notify looks like we'll see it in game click on I'm gonna do make this red and say clear and let's say you want to like concatenate strings we can do print over see how this works first and then in quotes function e quotes you say the key and then to combine them put these two dots and then H underscore heat then he was breasts so that's that's basically that what that'll do so yeah let's this should work you'll see how these work and yeah let's let's run this resource but before we do that we're going to go to our server dot CFG out that actually hoops I meant our resources CFG that we did from another episode and add-on start so I'm gonna run this script or I'm gonna go into the server and I'll see you guys then alright alright so I was on a server and I saw that I made a little typo here so yeah I figured that out so I'd switch these two little characters on so you just type in some level a to label sorry about that hopefully didn't actually follow it and then if you're already on your thing you can restart your resource by days and restarts guns you start it and now we're gonna click the H key I already have a pistol place testing it and the knife but it should put the age and it says given what the middle age like I said with a little pop-up a nice blue and clear your slash clear and that should clear all the weapons so there you go that works if you enjoy this video definitely like like the video to Jordan and subscribe for more we're gonna make more tutorials in the future and yeah have a good one
Info
Channel: Jeva
Views: 169,390
Rating: undefined out of 5
Keywords: fivem scripting, fivem modding, zua, zuacp, wesley, fivem hacking, fivem, fivem roleplay, fivem forum, gta 5 natives, gta 5 modding, lua, lua scripting, how to learn code fivem, js, fivem rp, gta 5 rp
Id: Pk2k--miSdM
Channel Id: undefined
Length: 13min 43sec (823 seconds)
Published: Fri Nov 16 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.