kevincouto6 Posted June 5, 2018 Share Posted June 5, 2018 Agora estou tentando fazer um Shop para Recarregar armas, com um total, sem que seja permitido passa-lo, bom esse shop sera apenas para recarregar as armas que tiverem no seu inventorio Aki estão os id das armas e o total que deve ser recaregado, porem elas devem estar no seu inventorio para ser carregadas, alguem poderia me ajudar com isso ? 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
kevincouto6 Posted June 6, 2018 Author Share Posted June 6, 2018 Desculpem por postar denovo, eu não consegui editar o post acima Algumas partes eu ja consegui fazer, Como GiveAmmo, TakeMoney and Total, porem não ser como fazer o player recarregar apenas as ARMAS que ele tem no inventario if ( ammo ) then giveWeaponAmmo ( thePlayer, 22, 1000 ) takePlayerMoney ( thePlayer, 5000 ) getPedTotalAmmo (thePlayer, 1000 ) else giveWeaponAmmo ( thePlayer, 24, 450 ) getPedTotalAmmo (thePlayer, 450 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 25, 200 ) getPedTotalAmmo (thePlayer, 200 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 26, 500 ) getPedTotalAmmo (thePlayer, 500 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 27, 850 ) getPedTotalAmmo (thePlayer, 850 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 29, 2100 ) getPedTotalAmmo (thePlayer, 2100 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 30, 1600 ) getPedTotalAmmo (thePlayer, 1600 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 31, 2500 ) getPedTotalAmmo (thePlayer, 2500 ) takePlayerMoney ( thePlayer, 5000 ) else giveWeaponAmmo ( thePlayer, 34, 50 ) getPedTotalAmmo (thePlayer, 50 ) takePlayerMoney ( thePlayer, 5000 ) end Link to comment
Other Languages Moderators Lord Henry Posted June 6, 2018 Other Languages Moderators Share Posted June 6, 2018 Já tentou usar getPedWeapon? Link to comment
kevincouto6 Posted June 6, 2018 Author Share Posted June 6, 2018 (edited) 12 hours ago, Lord Henry said: Já tentou usar getPedWeapon? Bro, sabe me dizer como fazer par Re-fill, apenas as armas que estiverem no inventario ? aacima estão as weapons que podem ser carregadas Edited June 6, 2018 by kevincouto6 Link to comment
Other Languages Moderators Lord Henry Posted June 6, 2018 Other Languages Moderators Share Posted June 6, 2018 Pq vc não respondeu minha pergunta? Link to comment
kevincouto6 Posted June 6, 2018 Author Share Posted June 6, 2018 6 minutes ago, Lord Henry said: Pq vc não respondeu minha pergunta? N essa funçao e para PED, eu preciso para playerr Link to comment
Other Languages Moderators Lord Henry Posted June 6, 2018 Other Languages Moderators Share Posted June 6, 2018 12 minutes ago, kevincouto6 said: N essa funçao e para PED, eu preciso para playerr E quem disse que só funciona em Ped? Vc chegou a testar? Se tivesse pelo menos lido o exemplo, teria visto que funciona em Player também. Link to comment
kevincouto6 Posted June 8, 2018 Author Share Posted June 8, 2018 On 06/06/2018 at 18:41, Lord Henry said: E quem disse que só funciona em Ped? Vc chegou a testar? Se tivesse pelo menos lido o exemplo, teria visto que funciona em Player também. manin usei sua função mas deu algum erro pode ajudar ? --Clientside-- Buyweapons = guiCreateWindow(244, 84, 186, 226, "Buy Weapons Factions", false) guiWindowSetSizable(Buyweapons, false) guiSetVisible(Buyweapons, false) guiSetProperty(Buyweapons, "CaptionColour", "FF10ECEE") ExitButton = guiCreateButton(10, 185, 166, 31, "EXIT", false, Buyweapons) refill = guiCreateButton(10, 144, 163, 31, "Re-Fill", false, Buyweapons) button1 = guiCreateButton(10, 24, 163, 68, "Satchel / Fuel \n $1000", false, Buyweapons) buyvip = guiCreateButton(10, 102, 163, 32, "Weapons V.I.P", false, Buyweapons) --if you want add Marker# {}, Mark = { {-2404.00000, -598.00000, 132}, } --Marker local Marker1 = createMarker(-2404.00000, -598.00000, 132, "cylinder", 1.5, 250,250,0) for k,v in ipairs (Mark) do z = v[3] -1 Marker = createMarker ( v[1], v[2], z, "cylinder", 1.5, 255, 255, 0, 255 ) addEventHandler('onClientMarkerHit', Marker, function ( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible (Buyweapons, true ) showCursor( true ) end end ) end function ExitButtonFist () guiSetVisible (Buyweapons, false) showCursor (false) end addEventHandler ("onClientGUIClick", ExitButton, ExitButtonFist) function Weapon1() local itemID = 39 local itemCost = 1000 local itemMunic = 1 triggerServerEvent ("weaponid1", getLocalPlayer(), itemID, itemCost,itemMunic) end addEventHandler ("onClientGUIClick", button1, Weapon1) function viperror () outputChatBox("Erro in buy WEAPONS VIP Sorry.", 255, 0, 255, true) end addEventHandler ("onClientGUIClick", buyvip, viperror) function reloadTheAmmo(thePlayer) triggerServerEvent("reloadWeapon", localPlayer) end addEventHandler ("onClientGUIClick", refill, reloadTheAmmo) --ServerSide-- addEvent ("weaponid1", true) addEventHandler ("weaponid1", getRootElement(), function (id, cost,munic) if (getPlayerMoney (source) >= tonumber(cost)) then outputChatBox ( "Your Buy Item", source, 255, 0, 255, true ) takePlayerMoney (source, tonumber (cost)) giveWeapon(source, tonumber (id),tonumber (munic)) else outputChatBox ( "Your don't have Money", source, 255, 0, 255, true ) end end) 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}, } addEvent ("reloadWeapon", true) 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 ) o erro é "buy.s.lua/29:bad argument @ 'getPedWeapon' [expected ped at argument 1, got nill]" sera que voçe pode ajudar ? Link to comment
[M]ister Posted June 9, 2018 Share Posted June 9, 2018 (edited) Quando você está chamando o evento "reloadWeapon" você não defini quem é o thePlayer Sempre que usar o triggerServerEvent (client-side), a função que você está chamando no lado (server) vai receber a variável pré-definida (client) que corresponde ao player que acionou tal evento, sendo assim, o correto é você trocar o thePlayer por client Spoiler addEvent ("reloadWeapon", true) addEventHandler("reloadWeapon", root, function() local cw = getPedWeapon(client) local d = weapons[cw] if (cw) and (d) and (takePlayerMoney(client, d.cost)) then setWeaponAmmo(client, cw, d.ammo) end end ) Edited June 9, 2018 by MaligNos cliente => client Link to comment
Other Languages Moderators Lord Henry Posted June 9, 2018 Other Languages Moderators Share Posted June 9, 2018 Você deve fazer isso que o @MaligNos disse, é o mais fácil e recomendável. Outra forma de fazer seria você colocar o localPlayer como parâmetro de função no triggerServerEvent e declará-lo nos parâmetros da função server-side. client-side triggerServerEvent ("reloadWeapon", localPlayer, localPlayer) server-side addEvent ("reloadWeapon", true) addEventHandler ("reloadWeapon", root, function (thePlayer) 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) 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