Butcher Shop WarMenu Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey thanks for tuning in so tonight i'm going to be showing the beginning programmers how to use war menus to create a user interface creating a user interface is one of the challenges whenever you're first starting programming and war menus is one of the best ones easiest ones that i've found i'm also going to be showing you how to move variables between the client and the server and how that process works and let's get into it so i've set up a folder that has a bunch of blank files in it but this is the basic setup you need to get started with this program so we need an fx manifest we've got a server folder that has a server file inside of it and we got a client folder with our blips our client lua and our war menu i'd like to give a shout out to rexshaq gaming who wrote a bait shop script that i read to figure out how to do this so this is not exactly his bait shop script but i used some of his information to do this so the first thing that i'm going to do is bring in the war menu script and i can tell you that this is going to be placed in the links below the video and i do not fully understand how all this works so you can pull this file from the github link that's going to be posted with the video and [Music] it's a very large script and i as far as i know rex chat gaming uh created the script because i pulled it from bait shop it's basically your base menu that you need the base program you need to create your war menus i'm not gonna go through this code because uh i would be lying to you if i told you i understood how it works but this base script is what allows you to create the war menus so thanks rex shack gaming for creating bait shop and making it available to everyone oh yeah save that okay so now let's talk about stuff that i do understand so the first thing we want to do is to set up locations on the map where we can uh have our interaction points for our menus i did this video once before and i was typing everything and it took forever so tonight we're just going to do pasting and i'm going to explain what i just pasted so the very first thing we got to define our variables our variables blips and our blip is going to have a name it's going to show up you know on the map it's going to have a sprite not exactly sure what the sprite is to be totally honest i don't know it's a i think it's a native thing don't worry about it this native right here is hash and this is uh the blip hash and you can find it um at uh the discoveries link that's going to be posted below the video you can find all of the blips that are available in red m and then these are the locations you want your x coordinate your y coordinate and your z coordinate these can be anywhere these are just going to be a location that when you walk into it you actually get the menu pop up the prompt so they can be next to a butcher shop they can be out in the middle of a field it doesn't matter whenever you get within a certain distance of these coordinates it's going to prompt you if you want to pop up the war menu and then we have to put those on the map and so we're going to use this code right here and again all of this is available in the link below to the github this entire finished product will be there for you to download and use so this uh create thread is uh basically a function that's gonna run um whenever the script is launched and it's going to do a loop and so it's gonna be a for loop and this is something that uh it took it took me a long time to understand and uh i think i'm there now so i'm gonna try to explain it as best i can so on a for loop your first variable can be pretty much anything you want uh it could be a underscore eye whatever you just have to reference it down below and info is going to be for each iteration the things that are there so for each iteration of this loop it's going to pull back a blip and this is blips because it's coming from where we entered it up here so for each iteration you're going to set up a local variable for a blip and this is a native i don't know uh exactly what it is you could search for it on the reference below the discoveries but that's the native that's going to create the blip and so the first variable is going to be your hash so that's going to be your your hash id for the icon that you want to use and then it's going to get your coordinates okay and then it's going to set the blip sprite and this split that's part of the native functions red m this is not blips this is blip that's part of the command and so you have to have your set blip sprite a blip the sprite and then a one means that it's turned on and then you set your blip scale again this is split this is a native and then 0.2 is the scale you can make it bigger or smaller by changing the number and then you're going to run a native function and this is just the syntax for the native function uh you got your native execution which is going to be doing putting the blips on the map and storing them in the cache or whatever and this is part of the native also blip again it's not blips it's just blip and info name so this is going to put the prompt on the map whenever you click on it you know what it says it's going to save me and that's all you need for your blips so this file is done so now we're going to go to the client lua so every time you're starting a client lua if you're doing a war menu you have to have this code at the top this is a lot like the data code that you have to use on your server side if you want to grab data from the config the inventory config okay so this uh this code right here is just going to go back to redmrp menu base getdata and it's going to give you your menu data and a call and it's it's just got to be there i can't tell you exactly how it works we'd have to go dig through that code but just trust me if you're doing a war menu you need that on top the next thing we want to do is assign our variables so since we're building a butcher shop the variables that we're looking for is the price for these different items so that we can populate the shop with prices and i'm setting them equal to zero because i'm actually going to pull them from the red mrp inventory later but i have to define them as something so that the script knows that it's looking for a variable that's an integer all right so now we need to add our butcher locations and there's probably a lot of ways to do this that are more technical such as doing a loop like we did in blips but um this works too and this is easy so i just put in 10 locations these are the same as my blips okay and this is going to be the actual location where the prompt pops up so over here these locations populate your map with a blip these locations add a prompt at the location all right that should be pretty self-explanatory just xyz all right and then i'm going to want to get these prices i'm gonna want to fetch those from i gotta fetch those okay now this is going to be a function that we do and it's going to be called from elsewhere we're actually going to have to call this this event from the server we'll talk about that later but after the function you see all of these variables okay and i have them set up as a different name because i don't want them to mess up anything on the client side by having the same variable name i don't want to reassign any variables i'm just bringing these over so the way this works is when you write the actual call for the function you're going to send these variables and we'll talk more about it later but basically i'm fetching the all these prices from the server from the redmrp inventory on the server side and then i'm going to execute this function and send those variables over because you can't pull from the redmrp inventory on the client side you have to pull it on the server side and then basically i'm going to go through here i don't need that one and i'm going to assign these variables so we got big game price big game price and then we're going to assign it the actual price from the config that we sent over and then we're going to print it just so that it pops up on our on our f8 console so we can make sure that we got a price for all these it's a good for troubleshooting to just throw in a print anytime you're having trouble with a script i recommend just put in a print message and help you identify where your problems are so that's pretty much it we've assigned all of our we've signed all of our prices now well sort of we still have to do stuff on the server side but we'll do that later we're going to do the whole client first so now i want to start the butcher shop and so i i'm this is going to be for the war menu all right so for the war menu i need a variable called active i need a variable called shot prompt i need a variable for has already entered the marker and a variable for last zone this is a way to assign more than one variable at a time with the comma there and then my current zone is nil and then uh to set up the war menu you have to do a setup shop prompt all right and this is going to be the prompt that pops up when you walk into one of these coordinates and it's a it's a thread function and it's going to the local string here is going to be open butcher shop so that's going to be what pops up on your screen when you enter the coordinates and then we're going to have pull our shop prompt right here and it's going to tell it to begin the shop prompt which means it's going to pop it up and to set the control action this is a native this means that's the button you're going to press to activate the prompt and in our case this native is your left alt button and then we're going to have a string create variable string literal string this is just the native command to pop up this so this is a native command it always has to say literal string and uh i think 10 is i don't know what 10 is but the string is the text that's going to pop up i'm not sure what that first variable is but uh 10 works so there's that and then we're going to set the text it's going to be the shop prop string and all this stuff is is basically native stuff that has to take place we're going to set it as enabled false that means that it hasn't been activated we're going to set it as visible false because it hasn't been the area hasn't been walked into yet if you uh you prompt set to hold true that means that you have to hold the left alt button when you get into the area in order to open the menu and then we're just ending that means that's the end of the prompt so there's nothing else going to happen when you walk into the area you're going to get this message on your screen and that's it that's all we want to do here here's mud all right so now we're gonna have to add a couple of event handlers i'm gonna add two of them so our first one is for has entered marker this is just going to be called whenever the player walks into the blip area and it's going to change their zone from current zone to zone and uh we'll talk about that later whenever we get to the portion where we actually enter the zone and then next we're gonna have we want to check whenever the player exits the marker so if if it's active then we set the if it's active that means that somebody has already interacted they've if it's active that means somebody has entered the blip area they've helped their left alt and opened the menu so if the menu is open we don't want to see the prompt anymore so we want to disable it and we want to uh hide it and we want it to be inactive and uh if they walk out of the area we want it to because they've exited the marker we want it to close the menu and make the current zone nil so that it basically resets it so if the player walks back into the blip area then the prompt will pop up again so basically this is sand if they've already activated the menu close the prompt if they walk out of the area close the prompt okay simple enough alright here's our next piece of code here so this is going to set up the shop prompt and this is going to be how you check if the players in the area so it's going to be a while true do loop that means it's going to be running since it's just the citizen create thread that means that from the time the the script is launched it's going to start this loop and it's going to wait 0 milliseconds so it's going to be checking constantly if a player is in the coordinate area so you want to get since we're on the client side we want to use player pet id to find out which player it is and then once we've identified the player we can get their coordinates for the player so this is going to just get into the chords is going to return to the uh to the server uh what uh what their coordinates are and then local isn't marker current zone equals false so the script is launched not the player is not there yet and so both of these uh variables are false then we're going to run a loop and so for kv in paris butcher shop and butcher shop is all of our blips up here or all of our locations so for uh it's this is this loop is running through and checking all those chords against our player's chords v distance checks what the distance is between our player player chords and our shop chords so k is essentially player and v is essentially butcher shop so the players chord x players chord y players chord z and then it's checking against the shop v x y z if that distance is less than 1.5 meters then they are in the marker it's true their current zone is the butcher shop and their last zone is the butcher shop all right so it's going to do that loop and then it's going to check are they in the marker and if we said that they were in the marker then that's true and not has already entered marker so that means that they they haven't uh they haven't um opened the menu essentially then uh then it makes the has already entered true because they've entered the zone and it's going to trigger the event that has entered marker that we put up here it's just going to take change the current zone to zone and this is sending the variable current zone and it's catching that variable as zone but it still is the current zone they just redefined it as zone and then they said the current zone equals zone that's just a way to send it receive it and register it all right so if they're not in the marker but they have already entered the marker then we don't need the has already entered marker anymore it's false because we don't want to do that again and the zone is just last zone because we we told it this happens then we're in the butcher shop and so this is just going to tell you that you're in the butcher shop location and what that does is that keeps it from popping the prop back up so the prompt will pop up the first time you enter the zone if you open the menu the prompt goes away if you leave the area the prompt goes away so that's basically what this is doing all right so now we're going to create our war menu because we've got we've been able to identify if the players in the zone or not we've given them a prompt to open the menu now they have to have a menu to open so this is how you create a war menu you have a war menu create menu is going to be your master menu name and we're going to call it the butcher shop and it's going to pop up some text butcher shop that's what's going to print at the top of the menu interaction and then we want to set a subtitle for the butcher shop that says buy and sell meat so the menu is going to open it's going to say butcher shop at the top and then below butcher shop it's going to say buy and sell me and then the sub menus are going to be our actual buttons so we're going to have a button for buying raw meat we could throw a raw in there if we wanted to and we're going to have an action to sell raw meat and then we're going to have an action to buy cooked meat and a button to buy or to sell cooked meat the first one is your button's name the second one is the menu that it's assigned to and the third one is the text that shows up on the button all right now we're going to build our first sub menu uh and this war menu display actually goes i should have pasted it before it goes here right below that i'll put a space there to keep it separated so this is our first button that's our buy button so uh whenever they open the buy button it's going to give them the option to buy big game meet and it's going to show them the price so the way this works is this is just text that's going to pop up on the menu and then the dot dot is the same as an ampersand in excel it's a concatenate so and then it's going to print the big game price so on the screen they're going to see by big when they when they that button pops up it's going to say buy big game meet for this price and again the dot dot is how you concatenate uh stuff you don't use an ampersand or anything like that you just use dot dot and that's a concatenate so if they click the first button then it's going to trigger a server event called meat shop buy and the reason it's a server event is because we're going to be manipulating their inventory and you can't do that on the client side you have to do that on the server side okay so if they click the button then they're gonna get the price we're gonna send the price over to the server we're gonna send the product's name to the server and the zero is i don't remember we'll have to look whenever we get over on the server side so we have a button for each meat type and this is to buy raw meat and this is under the buy menu and at the bottom of our menu we got the display and then our second menu is going to be for the sell button and it's the exact same process so first is the main menu open okay then if you click the buy button that's your uh elsif then you're going to be able to select from the byron meet category if you click the sell button then you're going to be able to interact with the cell buttons and then in the interest of time we're going to go ahead and add our other two buttons at one shot so we added our buy big game meat or our buy cooked meat and we added our cell cooked meat and they all have events now uh one thing that i should talk about is this this information right here so again this is your text in your button and then before we just had the price because the price that we fetched from the server was just the raw meat price well this is to that's to purchase the raw meat to sell the raw meat i want it to be less than the purchase price so i'm going to multiply it by 0.75 that means it's going to be 25 less than the uh than to purchase the meat so you can't just buy meat and sell it and make money you're always going to lose 25 if you try to do that math.4 is going to prevent if if we just do this then we could end up with a whole lot of decimal places but we're talking about dollars and cents so we only want two decimal places so the first thing i'm going to do is to use this math.4. that's going to round this times 0.75 times big game price that's going to round it to the lowest integer all right but it could be just cents and so that would round it to zero i don't want to do that so i'm going to multiply it by a hundred all right so now my math 4 is rounding this entire statement to the lowest integer so say it was 50 cents it would round it to 50. well i don't want it to be 50 for the price so i divide so i take all of this well so the math.4 interacts with these two uh parentheses okay so that's what's being rounded so i want to take that rounded number which is 50 say if it was 50 cents and then i divide it by 100 and that takes it back to 50 cents so this is just a a way to ensure that you always end up with two decimal places okay and i did that for the buy cooked i want the buy cooked to be 65 more than buying it raw so i multiplied it by one times 0.65 and i want the to sell the cooked price for the same price it cost me to buy raw so if a player buys raw and cooks it he's going to break even it's just to prevent people from farming the butcher shop all right so now all of our buttons are defined and we can end this thread and i'm missing something it's missing here so if we click on this one where does it go to it goes to there so i've got an extra end here somewhere let me just highlight all the other code instead of trying to search for where i missed a copy all that means is somewhere in here i'd either am missing an elsa or an if or something oh yeah oh yeah i see where it's at at the very top of the thread we needed an if statement let me uh do proper formatting and tap these things over yeah so at the very start of this function i missed i missed this uh we're checking if the war menu is opened so that means the player has held the button to open the war menu so we want to make sure the menu is open and then we populate the menu with all the buttons still got it still got a problem if oh dang it wow i'm sorry guys sorry guys ignore that that was in the wrong place it's got to go here because we have to run a loop so this creates the buttons in the menu just like i said the first time all right and then we have to run a loop to interact with the menu so if the war menu is opened that means we've done our prompt interaction to open the menu then we have these options which means if you click on the button and then if you click on the buy raw meet button then it's going to activate the buy button so i'm sorry about that but that should be clear uh before nothing would have happened because there was no uh statement saying did the player click the button uh this loop is just checking and watching what the player does and whenever he clicks one of these four buttons then it will go down and say uh which button did they click uh if they clicked buy then the buy menu is open and you got all the buy buttons all right now everything's good sorry about that a little confusing but uh we're almost there we're almost done with the client all right the next thing we have to do is determine uh if the if the player holds the button or not to open the shot prompt so we said that we were going to hold left alt up whenever we defined the prompt and now this loop right here is checking to see if the player entered the zone and held the button so if they're in the current zone and it's not active the menu is not active then we're going to show the prompt and we're going to set it to visible and then as soon as we do that then active is true so then it's going to start once it's true in this loop it's going to skip this statement and it's going to watch for them to press the button so if they hold the left alt button then we're going to trigger an event to fetch the prices and we're going to wait a little bit of time so that the prices can populate this is one second 1000 milliseconds and then we're gonna after we've waited for the prices to populate then we're gonna open the menu and then we're gonna display the menu and then we're gonna turn the prompt off because we don't need to see the prompt anymore because we've already held the button and we're gonna make our current zone kneel and that's just gonna keep the prompt from popping up and then for the loop it's gonna wait five milliseconds before it runs the loop and that means the player whenever he walks into the zone within five milliseconds of getting within the blip zone it'll pop up the prompt all right and finally i don't call this anywhere and i'm not sure what the purpose is but it was in a rec shop gaming's original bait shop script and it may be it's got a bunch of native stuff in here so you may just have to have it for everything to work properly but i don't call this anywhere so i'm not sure exactly what it does but it was there in the original script and i chose not to take it out because i didn't know what it does and i advise you to do the same and now we are done with our client lewis so we have our blip slew where we uh put blips on the map we have our client lua where we created our interaction menus and we have this uh incredible uh war menu program that rex shack gaming provided us with so thanks rex shack again alright so now we need to do things whenever those buttons are pressed so on your server side if you're going to be working with inventory you have to have this statement at the top this is part of the built-in red mrp stuff so you have to have that in order to get item data and then we're going to need some variables here and it's the variables that we want to send over it's all of our big game prices it's all of our meat prices so if a player hits that first button that first button is to buy raw meat so on whenever the they are interacting with the butcher shop the first option is to buy raw meat and so if that player clicks the buy raw meat button we launch this uh event and we have to add an event handler and these are the variables that it receives okay so the zero was level all right these are the variables that it receives so let's talk about that for a second if you're sending from client to server this is the button they pit press they pressed uh buy raw big game so we're going to send to the server the big game price we're going to tell the server that the item they're purchasing is big game and we're going to tell the server that their level is zero that they only have to have a zero level in order to purchase this so if you wanted to make it where an experienced hunter is the only one that can sell big game you would just change your level and then it would be based off their xp but it's a butcher shop so i want everybody to have access so we're gonna make the level zero so we've sent over our price our item and our level and then we're going to trigger this red mrp event this is back to the inventory of red mrp and we want to send to that the source and the user so it knows which user is trying to interact with the inventory and then we're going to define that user with an identifier so this is uh getting the users identifier which will be like their it'll be their steam id i believe and then it's going to grab their level to figure out what level they are to make sure they're able to price it purchase the item which is handy if you're trying to make it you know tiered pricing for like weapons or something but for me we don't care everybody can sell me and then we're going to get item info and we're going to do data dot get item data for the item and the item is big game neat because that's what we sent over one more thing to mention real quick if you're a beginner you might not understand how this works so these are the variables that are received they don't have to be named the same this is variable 1 variable 2 variable 3. you can send anything you want over and it's going to arrive and the order you sent it and then you can assign it a new name in the order you sent it so we know that we sent the big game price the item name and the level and so we're going to call it the price the item and the level but we could call it whatever we wanted to we could call it p1 i3 xyz it doesn't matter you can call it whatever you want you just have to call it the same thing when you reference it below so for price we're referencing it here and here for item we're referencing it here here and for level we're only referencing it here okay so now we've grabbed information on the item on the player and the item that we sent over and then we're going to check if the user's got enough money to buy the item so we're going to get the money that the user is currently holding and if it's greater than equal to the price of that item then he's going to be able to purchase it so if that's true then we're going to check if their level is high enough to purchase the item in this case it's zero so everybody can purchase it and so then we're going to take their money for the item so uh whatever the prices of the big game meet we're going to remove that from their wallet and then we're going to get some uh item data so item info and item data are two different things okay so for item info you got to get item data for the item for the item data you get item data your data get item and then you want to tell it it's for the player and you want to tell the item you're looking for this item data is for the items in the player's inventory this item info is for the item and the red mrp inventory config so this is going to return the item's label weight price um any tags that you have in there it's going to return all those tags this is only going to tell you does the player have the item yes or no how much of it does he have okay and so we're going to print the item data item amount so that's going to tell you how much the user has in their inventory in this case we're buying so it's not it's not really necessary all right i just set it up because i checked this in every one so it's easier to just copy it right so basically this is not needed okay except i'm going to use it in my alert so that's why it's here okay but we'll get there in a second all right so i'm gonna this is a print itemdata.item amount this is gonna go to your server uh to your tx admin menu or control panel and it's gonna tell you how much of the particular item the player has and it's just for troubleshooting and then we're going to add one of whatever they bought to their inventory and then we're going to trigger a client event to notify the player that they bought something so this is going to reference the red mrp notification it's going to say for the source just tells it that it's the player that clicked the button and it's going to tell them that they bought and then they're going to concatenate so it's going to be you bought item info label comes from here so that's going to tell you big game meet and however you have it instead of just being the name of the item that you have in the config it's going to give you the label so like what you called it um it's going to show up for three seconds and it's going to it's going to be a success message so it'll be a green message if you weren't a high enough level it'll tell you uh you're not high enough level if you don't have enough money it's going to tell you you can't buy it because you don't have enough money so there you go so now whenever the player clicks the buy button for buyer big game meet or any of those items uh in the raw meet tab that's going to uh do it here it's going to sell it to them and they can send it because we used because we used we sent variables as one two three these can be anything and this still works so it doesn't have to be specific to the exact item it can just be anything that they click over there so we also need our uh cell raw meat and our buy cooked meat and sell cooked meat so we'll just do them all at one time there is a little bit different process if you're selling as opposed to buying okay so uh the this in this case they're selling cooked meat uh so we're just pulling the price and the meat we don't care the level because anybody can sell so i did i just removed level from this that way everybody can sell the meat and we're not checking for a level we're going to print this is a troubleshoot it's going to tell us the price and the meat just to make sure that these are populated in case we have any error messages anything's nil we can go back and figure out why and then we're going to look up the item and we have to put this uh we have to put these quotes around the parentheses because in the config it's it's not just called uh if we just put meat then it's just gonna return say it was cooked big game that's what it's gonna return all right and that doesn't mean anything to these other uh steps down here it's got to have the quotes like that for it to be recognized where we use it below like here right so we're adding those little quoties we're adding those little single quotes so that it's in the proper format so this is just concatenating those little quotes around me all right and then we're going to print the lookup item just to make sure that worked uh local source because the the server wants to know who the player is that's uh sending this command and then we're gonna look up the item info for a day to get out of meat and that's why we had to do this because if we just had big game meet here it wouldn't find anything and we'd get a nil back right uh and then we're gonna trigger uh get player from id source function user and this is gonna uh this is going to get the players information from the server and we're going to look up the item data get item for i changed source there source equal source and just looking for the big game meet cookbit gaming and then we're going to do another print here just for troubleshooting and then we're going to calculate figure out how many items of this source the player has because remember data.getitem gets the player's inventory so this is going to tell us how many of the cook game meet the player has and that's going to be our total item then we're going to print that just for troubleshooting to make sure they have had something in their inventory and so if that's greater than one then we're gonna sell all of them so we're gonna take the total item let's say they had five times the price and uh so it's gonna be if it's a dollar they get five dollars and then we're gonna give them 5xp for selling five cooked meat and then we're gonna add money the total money which is uh however many items they have times the price we're gonna add xp for however many items they had times uh one because we didn't do any math it's just how many items they had given xp and then we're going to remove those items from their inventory and we're going to remove all of them you could change this to one if you only wanted to do one but usually if somebody's selling raw meat or cooked meat or anything if they're selling it they want to sell all of it so there you go and then we're going to trigger a message to tell them how much it's going to tell the source tells the message that is talking to the player that clicked the button and they sold however many items of whatever item it was for however much money they got and they got this much xp if uh they didn't have any of that item it's gonna tell them they didn't have any and so that's that's how you do the cell the shops are both the same and the cells are both the same i'm sorry the buys are both the same and the cells are both the same so we have two cell buttons two by buttons they're all in here now the one thing that we did call earlier that we need to talk about now is uh fetching the price and once we fetch the price we've got to send it back to the client all right so butcher fetch raw price if we go back to our clue to our client lula you'll remember at the top up here the very first thing we did was to fetch these prices we assigned them a value of zero and then we fetched them all right now these are the variables that we're going to receive on the client and this is where we're going to send them but before we send them we have to fetch them so we do our local source equal source we do our this is the same as data info but since i'm just fetching several variables i call them each by whatever meat type it is and we're going to do that datum dot get item data and then there you can see there's the quotes around the big game which is why we did that whole step right here all right and then we're gonna print the big game info price and uh price buy is not something that's defaulted into your config so you're going to have to add buy price tag a price buy tag to all of your items that you want to be able to sell here and we're going to uh concatenate to that the uh label and this these prints are always just uh they're just to troubleshoot to make sure that we're getting variables so each time we pull one we print it just to make sure we got it and that again all these prints are just troubleshooting and then our big game price is going to be equal to our big game info dot price by big game info we fetched the price uh whenever we did this data get item data so we're that's where we pulled it all right and we right here we were just checking to make sure we got it so uh this is where we're going to assign it so that value we pulled we're just assigning to big game price all right we do that for all the needs we tell we want to do some troubleshooting so we tell ourselves that we sent the prices to the client that means that we've ran through all this everything was assigned there was no nils the program's still running and then it's gonna it's gonna trigger the client event to fetch the prices and then here's all the information that we're sending and this one right here is important anytime that you're sending variables from the server to the client you have to have source as your first variable it doesn't send anything over there it just tells the uh program which which player it was that sent the command okay and then we're assigning all of our variables and i did mutton price twice at the bottom that's why on the client side there's a blank because i got mutton price and then i've got a blank but you'll notice source is not on the client side and this is important all right pay attention if you if you don't understand how to send variables back important this is very important if you're going from the client to the server you don't have to tell its source because it knows where it came from because the client side is the individual player but if you're going from the server back to the client it's got to know which client to go to so you have to tell it the source but once you've told it the source it doesn't care anymore because it's in the client so the source is the whoever it is that's uh playing right so you don't bring that variable over and that variable doesn't get sent that just tells it where to go so the first one always has to be source but you don't have to worry about it you just have to put it in there so that it goes to the right client and then all these prices uh get sent over so you'll see that on my client side big roll big game is my first variable big game price and again i the reason i call it it's big game price here because that's the variable i'm using and everything but whenever i receive it i don't want to call it big game price because that can cause problems all right so i want to give it a different name and then i tell this big game price here okay just to make sure everything's done correctly and it's going to work right and that's it that is all there is to it uh this menu is complete oh i'm sorry we gotta do our manifest so we're not quite done yet so for the manifest um at the top of your manifest uh it's just uh you always gotta have this and you'll notice it's on top of pretty much every uh script out there and i need to change this name to a.lua there we go so this always has to be at the top and then i'm not going to type these in i'm just going to copy and paste them and then talk about it so we we're going to need server scripts and for our server we're gonna need server slash server slash tells it that it's in the server uh folder and then the file name is server.lua okay and then on our client side we have three scripts and order of operations is important all right client first then more menu than blips if you're doing any sql syncing you always have to have mysql async at the top if it's not at the top it won't work so the order of operations does matter over here which one loads first in this case all of these scripts are in the same uh menu in the same folder but it still matters because i can tell you if you put war menu above client it doesn't work tried that so this is the correct order for these folders i think blips can be anywhere because it's not referenced by the other two scripts but client has to be above war menu now we are done and i will go do a quick demonstration on the server for you guys and uh i'll be right back okay so here we are in the mid in the game we're gonna test out our butcher shop menu i set it up at this table right here so i just walked into the zone and you can see on the bottom right of my screen there we go that holding left bolt we hold it and there's a slight delay and let's look at the server console and you can see this is the fetch price troubleshooting that we put in there so we got a big game is a dollar fifty venison's a dollar fifty so on and so forth and we said that the prices were simply client so our troubleshooting work there if we hit our f8 we can see that on the client side it did receive all those prices all right so everything's good so here's our menu butcher shop at the top buy and sell meat is our label and so if we want to buy raw meat we just hit enter and we can scroll through here and see all those prices didn't depopulate so let's buy some big game meat we lost 1.50 and we bought a big game me and uh let's buy five venison so we lost a dollar fifty per vinson all right and then we want to sell that raw meat uh sell our big game meat for a dollar twelve and i sold one because i only had one you can see in my inventory i've got five venison so we should sell five venison and we did we sold five venison for 560. and just to make sure we'll try to sell beef we don't have any so we don't have any to sell and then we can buy cooked alligator for 412. we can sell cooked alligator for 250 so we just lost money on that deal but there you go all the menus work uh there you go you've built your first uh raw uh war menu butcher shop i appreciate you guys for watching tune in next time we'll have some more uh some more tutorial videos coming out thank you [Music] you
Info
Channel: KSUIE Gaming
Views: 455
Rating: undefined out of 5
Keywords: rdr2, RedM, Tutorial, KSUIE, Modding, Coding, LUA, How to, Sending, Variables, Client, Server, Demonstration, scripting, butcher, shop, programming, videogame, gaming, developer, beginner, loop, for
Id: 6zeqB8JG3dg
Channel Id: undefined
Length: 52min 53sec (3173 seconds)
Published: Mon Sep 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.