kevincouto6 Posted June 5, 2018 Share Posted June 5, 2018 Now I'm trying to make a Shop to Reload weapons, with a total, without being allowed to pass it, well this shop will only be to reload the weapons they have in your inventory here are the weapons id and the total that must be reloaded, but they must be in your inventory to be loaded, could anyone help me with this? local weapons = { { weapon={22}, ammos={1000}}, { weapon={24}, ammos={450}}, { weapon={25}, ammos={200}}, { weapon={26}, ammos={500}}, { weapon={27}, ammos={850}}, { weapon={29}, ammos={2100}}, { weapon={30}, ammos={1600}}, { weapon={31}, ammos={2500}}, { weapon={34}, ammos={50}}, } Link to comment
Skream Posted June 5, 2018 Share Posted June 5, 2018 its not that simple and I don't think anyone gonna make it for you for free. Link to comment
kevincouto6 Posted June 5, 2018 Author Share Posted June 5, 2018 5 minutes ago, Skream said: its not that simple and I don't think anyone gonna make it for you for free. I only want functions and tips I intend to develop, if you can help me please tell me Link to comment
Ryan2233 Posted June 6, 2018 Share Posted June 6, 2018 (edited) I'm not going to make it for you, but give you some tips for what you can do, but please do some wiki research to implement it all properly. If I was you, here is what I would do. Find a way to get the player to reload his weapon, createReloadMarker = createMarker([coordinates of the marker here, here, here], "cylinder") Then trigger the player entering the marker with an event handler addEventHandler("onMarkerHit", createReloadMarker, [nameOfTheFunctionYouTrigger]) The [nameOfTheFuntionYouTrigger] is the name of the function you trigger when the player enters the marker. You then show the player some kind of information to reload his weapon. That can be done via a GUI or key binding. Once you did that, you reload the players weapon, you can do something like this function reloadTheAmmo(thePlayer) setWeaponAmmo(thePlayer, 30, 30) end To be honest, it's more complicated using a table, so use the setWeaponAmmo for all the guns. (The 30 is the gun id, the second 30 is the ammo amount). I've given you the basic idea you will need and the basic functions you'll need to make this script; but to progress you must make it all yourself and I purposely left stuff out because I'd like you to read the respected functions there as it's more knowledgeable than me. https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions Good luck! Edited June 6, 2018 by Ryan2233 Link to comment
kevincouto6 Posted June 6, 2018 Author Share Posted June 6, 2018 To Windows I have already developed, add some functions, if you want I can post it I already got weapons, now I wanted to know how to make players able to buy apens the weapons that are in your inventory, or if they re-fill in weapons that are in your inventory function reloadTheAmmo(thePlayer) if ( ammo ) then setWeaponAmmo ( thePlayer, 22, 1000 ) takePlayerMoney ( thePlayer, 5000 ) getPedTotalAmmo (thePlayer, 1000 ) else setWeaponAmmo ( thePlayer, 24, 450 ) getPedTotalAmmo (thePlayer, 450 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 25, 200 ) getPedTotalAmmo (thePlayer, 200 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 26, 500 ) getPedTotalAmmo (thePlayer, 500 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 27, 850 ) getPedTotalAmmo (thePlayer, 850 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 29, 2100 ) getPedTotalAmmo (thePlayer, 2100 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 30, 1600 ) getPedTotalAmmo (thePlayer, 1600 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 31, 2500 ) getPedTotalAmmo (thePlayer, 2500 ) takePlayerMoney ( thePlayer, 5000 ) else setWeaponAmmo ( thePlayer, 34, 50 ) getPedTotalAmmo (thePlayer, 50 ) takePlayerMoney ( thePlayer, 5000 ) end end addEventHandler ("onClientGUIClick", button3, reloadTheAmmo) Link to comment
Discord Moderators Pirulax Posted June 8, 2018 Discord Moderators Share Posted June 8, 2018 Jeeees' Juuunk code, juunk, god. And it will never work, since you cant have more than one 'else', but you can have more than 1 'elseif' function reloadTheAmmo(thePlayer) triggerServerEvent("reloadWeapon", localPlayer) end addEventHandler ("onClientGUIClick", button3, reloadTheAmmo) --// Serverside local weapons = { [22] = {ammo = 1000, cost = 5000}, [24] = {ammo = 450, cost = 5000}, [25] = {ammo = 200, cost = 5000}, [26] = {ammo = 500, cost = 5000}, [27] = {ammo = 850, cost = 5000}, [29] = {ammo = 2100, cost = 5000}, [30] = {ammo = 1600, cost = 5000}, [31] = {ammo = 2500, cost = 5000}, [34] = {ammo = 50, cost = 5000}, } addEventHandler("reloadWeapon", root, function() local cw = getPedWeapon(thePlayer) local d = weapons[cw] if (cw) and (d) and (takePlayerMoney(thePlayer, d.cost)) then setWeaponAmmo(thePlayer, cw, d.ammo) end end ) And I would add a timer that so called, protects the server from flood. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now