FiveM Scripting 14 - Discord Rich Presence

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] become a patreon gentleman today and receive a ton of perks including just school rose early access content private support channels code snippets and more join today at patreon.com jjs okay so I'm gonna get right into it before we start actually we have the code here I'll put this link in the description all the code that we write is always on github yeah and you're gonna need this link right here I'll put it in the description so I might want to get started in this so first I'm gonna go create a resource so actually I didn't even talk about what we're doing today we're only using discord rich presence or discord RPC it's that's not it's called its discord rich presence I think I should I'm gonna show you in the beginning part that how it's working so yeah well it's gonna be linked with discord and I'll show you how to customize it and do whatever you want so I'm gonna be creating a folder and my resources folder called rich presents and I'm gonna go into it right click and I'm gonna create two files one is gonna be called a resource down low here I'll move this in the other side here okay so one of them is gonna be called resource tile and the other one is gonna be called I'm gonna call the client script for this is we're gonna be calling it discord out well that's what I'm gonna be calling it so it's going to there we'll set up the resource down it's not that hard you're gonna need the resource manifest version and is in this in for you guys so are this specific one I was having trouble without using one so I put one in and it started working I think so the code is in the description below I'll put this right here in the description too so you don't have to type it out but yeah you're gonna need the resource manifest version this time for the script and I'm gonna be doing a client scripts and putting in this score that one's gonna be opening it so yeah you can see that this score down I thought I spelled it wrong for a second okay so before we start going writing the the client part we're gonna go to this link right here discord app calm slash developer slash applications you have to log into your discord account so I did that you your first time going on this site you might not have any applications don't worry these are my distance 5 I'm bot this is Clyde but my personal one but you just forget about them we're gonna be clicking a new application we're gonna be calling this roomie calling you can call this application whatever you want so I'm just going to be calling it Java so this is what's gonna actually show up as the name it's like the game that you're playing when you create it or when you go into five M so I'm calling it Java and you can see that we actually have a folder of all the images that I'm gonna be using for this because you're in it you can use assets for rich presents so I'm gonna be I'm gonna be clicking on choosing new icon there it is I'm gonna put in a Java dot PNG so that's like the main image that's gonna show up for it and then yeah so we're gonna want to go to this part right here rich presence and for the cover image I'm just gonna put big because the this I just put whatever you image you want make sure it's big enough it's like you saw it it says that big and my love it wasn't so I put big there again and yeah make sure it's big so I'm gonna be creating acid or you can use assets you can see 150 you'll see how they work or I think you'll already see because I'm recording this before actually show how it works so I'm gonna be putting in my my personal logo and I do a logo I'm gonna be calling it the Sula this is right here just text right after this image right here that I'm changing that's the key for the text so make sure you remember that I mean you can see it anyways but I'm also gonna be putting big as another asset every I will should keep it big so yeah those are our assets so if it's pretty much also set up so I'm gonna go back to general information and this is your client ID we'll be using this when we actually set it up so I'm gonna go back into the script or into the little file and let's get started with ready so all of this is gonna be written in a thread because it's gonna be constantly running it has to be running with how we're implementing it so we'll do citizen dot create it's to be like this and we have to end the function okay and then in here we're gonna be putting this all in a while true loop I'll do an end and then in here I'm going to be I'm gonna be treating a variable called local player coaching gets player head -1 we're gonna be using this for one of the parts I just want to put it in a variable just so you can see that that works and then we're gonna want to make this citizen dot wait we have to make it wait if we don't have that it's gonna completely crash yeah it's gonna completely crash so I did 5 times 1000 because each second there is 1000 milliseconds so every 5 seconds this thread heard this this loop will loop again and I want to do 5 seconds instead of like 0 or 1 how we used to do it or in other scripts because this doesn't have to be running every frame I'm just gonna do it every 5 seconds so it uses less resources or less like system resources so yeah I'm gonna go I'm gonna be there's a ton of natives so we're actually going to start off we're gonna start writing off the natives so set this for app ID that's the first one that we're gonna be using and we're gonna so this is what's actually gonna do is we have to use this client ID to actually make it use Java so this this is the client ID I'm gonna paste that in there boom just like that no quotes no nothing so the next one set rich okay so that one is we're gonna leave that empty for now because I'll show you how that works later so yeah okay so now I'm gonna just do the assets now so set this or rich residence I feel like I'm gonna spell something wrong here assets and this is this is the asset this is the first asset so the big one I guess you can call it is I'm gonna be using this as my primary one so big in quotes you got have to put fake the string and then set just word you know I'm not going to type all this out and paste it set discord asset text get player oh yeah I'm sorry I'm not even explaining so in here this is when you hover over the big asset like the big picture it'll show up this string so I'm gonna make it show up my name so I'm going to get to player head or now get player name and that's gonna be source because we're getting our name and that native requires a source so yeah this is once we hover over that it'll show our name I'm gonna do sets just scored which you know I'm not even gonna type it out again even though I was just there they're set small and this is excuse me this is what's gonna be the little circle so I'm gonna put my profile picture there by zua in for the small one yeah zua and then the text small text when we hover over zoo we're gonna actually make it show my health that I have in game so to do that I'm just gonna be typing out health so just to tell indicate that it's health and I'm gonna do I'm gonna join this string by saying get our actually it's get and L and then the health is gonna be player - actually now it's gonna be player okay I'm gonna be I'm gonna space this out just a little bit because it can get a little complicated when you're using Sonia Natives so I'm gonna put a space there so we have to make it - 100 because the way the entity health works that's really dumb but just make it subtract one on you because this at the native returns 200 so and it's really dumb it doesn't do anything past 200 I think so just make it set it to NRI it does but you just just subtract about a hundred okay and then um yeah that's gonna be subtracting about a hundred that's yeah that's all good I'm gonna go back to what do we do this is rich presents this rich presents right here it's just a string it's like the main string you saw I'm gonna make it I've actually seen this done before and I kind of recreated it it's gonna show your name and then the street that you're on so yeah this is gonna be a little long so I'm gonna start off with spacing this out I'm gonna do gets player and main source it's gonna be saying I'll show you what it's saying or I'm gonna show you what is essentially gonna say I'll show you what the string is gonna say so it's gonna be like just do it is on that's she I don't know how to spell this scoop she bit something like that Boulevard I sorry I can so I'm gonna make it do something like that so to do that we're gonna do zua which is right here our name we joining this string by saying is on and then I'm gonna make it say so to do this this is gonna be a little long we're gonna make it say that the the street that we're on so the first native is gonna be get street name from ash Heat okay and then it's yeah it's a little complicated it's gonna get a little more because we're gonna be going inside this native for a little bit so also this requires a hash get street name from hash key so obviously it's gonna require a hash so to get the hash that we need we're gonna be using another native called get I'm gonna try to space this out as much as possible just so you guys can see so we're gonna be using native to return a hash call it get a street name at board and then this native requires the entity coordinates that the players on so I'm gonna be making it you know obviously go to the player wherever the player is so we have I'm going to use table dot unpack okay yeah this is getting pretty long here parenthesis are getting a little bit out of hand but it's alright you can probably store this in a variable and it'll look a lot better but I'm just gonna be doing it for the sake of what I already wrote so table dot unpack that's not it that's an I think that's a Lewin lua function whatever so this will be unpacking the table that the table that's gonna have the where we are so we have to get entity words of the player and remember this variable is already defined how I use it right here and right here hope I do not mean to do that right up here so we don't have to constantly write get player pen so hopefully I wrote that right you can see that there's like a ton there's that one that one that one that one that one are so we should be fine on that yeah I want to go inside the I'm gonna go inside and show you how this work okay so my server now and you can see that all right first of all I added the start rich presence to my resources dat CFG so and I and when I went in it kind of went and already and you could see that on my just my discord profile it says Java which is the name that we did unfortunately this is like I don't know why it's over my thing but you could see that I kind of like to fit it through you can see that's the name of our thing and Java tutorial that's our server named SP host name right here you could see it up here and you could see that it's a zoo is on runway one which is true I guess where's runway one I mean yeah it says right there I guess and I'm it updates like I said every five seconds so if we were to hover over this says my player name this rich presence that we wrote I close out of the file but yeah and you can see that my health is a hundred now I'm gonna show you like when when your health does go down I'll show you what happens so I have this eval thing just don't worry about I just want to show you how it works so you can see that my health is super low right here and if I hover over it it updates every five seconds so you could see that it's a little slow you could obviously change that weight time to maybe like 20 milliseconds or even less it's up to you how instant but it's kind of pointless because I don't think discord updates there they're rich presents thing that fast so it's just pointless I think there's a I think it's every minute I don't know I don't remember but that's some of the limitations of the discord API so I mean that works you can see that I'm stuck it I guess I'm 150 but you know it says something else that's my little name there and yeah you can see that that's all working and yeah I mean that's that's all there is really to discord rich friends so hope you guys enjoyed the video here make sure to support us on patreon patreon comm / Jeff EJ s yeah I'll try to pump out more videos I'm out of school now so yeah that's awesome and I'll see you guys in the next video yeah good bye
Info
Channel: Jeva
Views: 102,635
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 discord, discord rich presence, discord rp, discord fivem, fivem discord
Id: BvfDLIW6nfc
Channel Id: undefined
Length: 16min 0sec (960 seconds)
Published: Sun Jun 16 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.