Looktovask Posted February 27, 2021 Share Posted February 27, 2021 (edited) hello, i created this script, but i dont know how i can make to show only the items the player have, and how to save and load the player item list, someone can help me? client.lua --[[ __ __ __ __ /\ \ /\ \ /\ \__ /\ \ \ \ \ ___ ___\ \ \/'\\ \ ,_\ ___ __ __ __ ____\ \ \/'\ \ \ \ __ / __`\ / __`\ \ , < \ \ \/ / __`\/\ \/\ \ /'__`\ /',__\\ \ , < \ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\\ \ \_/\ \L\ \ \ \_/ |/\ \L\.\_/\__, `\\ \ \\`\ \ \____/\ \____/\ \____/\ \_\ \_\ \__\ \____/\ \___/ \ \__/.\_\/\____/ \ \_\ \_\ \/___/ \/___/ \/___/ \/_/\/_/\/__/\/___/ \/__/ \/__/\/_/\/___/ \/_/\/_/ By Looktovask, Mantenha os creditos! --]] Items = { {"Cachorro Quente"}, {"Pizza"}, {"Biscoitos"}, {"Marmitex"}, {"Agua Mineral"}, {"Refrigerante"}, {"Primeiros Socorros"} } addEventHandler("onClientResourceStart", resourceRoot, function () JanelaInventario = guiCreateWindow(0.80, 0.56, 0.19, 0.42, "Inventario", true) guiWindowSetSizable(JanelaInventario, false) guiSetAlpha(JanelaInventario, 0.90) ListaInventario = guiCreateGridList(0.03, 0.07, 0.94, 0.79, true, JanelaInventario) guiGridListAddColumn(ListaInventario, "Items", 0.9) for i = 1, 23 do guiGridListAddRow(ListaInventario) end for i,v in ipairs(Items) do local Nome = Items[i][1] local row = guiGridListAddRow ( ListaInventario ) guiGridListSetItemText ( ListaInventario, row, 1, ""..tostring(Nome).."", false, false ) end guiSetAlpha(ListaInventario, 0.90) BotaoUsar = guiCreateButton(0.03, 0.87, 0.45, 0.11, "Usar", true, JanelaInventario) guiSetAlpha(BotaoUsar, 0.90) BotaoLixo = guiCreateButton(0.52, 0.87, 0.45, 0.11, "Jogar Fora", true, JanelaInventario) guiSetAlpha(BotaoLixo, 0.90) guiSetVisible(JanelaInventario,false) -- importante pra não iniciar ligada end) -- esse codigo é pica pra mostrar a tela bindKey ( "f1", "down", function( ) local tostate = not guiGetVisible ( JanelaInventario ) guiSetVisible ( JanelaInventario, tostate ) showCursor ( tostate ) end ) -- função dos botões addEventHandler ("onClientGUIClick",root, function () if ( source == BotaoUsar ) then local itemselecionado = guiGridListGetItemText(ListaInventario, guiGridListGetSelectedItem(ListaInventario), 1) -- a lista, a linha escolhida, e a coluna if itemselecionado == "Cachorro Quente" then local Px, Py, Pz = getElementPosition( localPlayer ) local Burger = createObject( 2880, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_burger") exports.pAttach:attach(Burger, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("CachorroQ", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Burger ) end, 3500, 1 ) elseif itemselecionado == "Pizza" then local Px, Py, Pz = getElementPosition( localPlayer ) local Pizza = createObject( 2702, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_pizza") exports.pAttach:attach(Pizza, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("Pizza", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Pizza ) end, 3500, 1 ) elseif itemselecionado == "Biscoitos" then local Px, Py, Pz = getElementPosition( localPlayer ) local Biscoito = createObject( 2663, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_burger") exports.pAttach:attach(Biscoito, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("Biscoitos", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Biscoito ) end, 3500, 1 ) elseif itemselecionado == "Marmitex" then local Px, Py, Pz = getElementPosition( localPlayer ) local Marmita = createObject( 2768, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_burger") exports.pAttach:attach(Marmita, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("Marmitex", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Marmita ) end, 3500, 1 ) elseif itemselecionado == "Agua Mineral" then local Px, Py, Pz = getElementPosition( localPlayer ) local Agua = createObject( 1509, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_burger") exports.pAttach:attach(Agua, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("AguaM", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Agua ) end, 3500, 1 ) elseif itemselecionado == "Refrigerante" then local Px, Py, Pz = getElementPosition( localPlayer ) local Refri = createObject( 2601, Px, Py, Pz ) setPedAnimation(localPlayer, "food", "eat_burger") exports.pAttach:attach(Refri, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("Refrigerante", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( Refri ) end, 3500, 1 ) elseif itemselecionado == "Primeiros Socorros" then local Px, Py, Pz = getElementPosition( localPlayer ) local KitS = createObject( 1575, Px, Py, Pz ) setPedAnimation(localPlayer, "misc", "scratchballs_01") exports.pAttach:attach(KitS, localPlayer, 25, 0, 0, 0, 0, 0, 0 ) triggerServerEvent("PrimeirosS", localPlayer) setTimer ( function() setPedAnimation(localPlayer) destroyElement( KitS ) end, 3500, 1 ) end elseif ( source == BotaoLixo ) then local itemselecionado = guiGridListGetItemText(ListaInventario, guiGridListGetSelectedItem(ListaInventario), 1) -- a lista, a linha escolhida, e a coluna outputChatBox( "Jogou Fora " ..itemselecionado ) triggerServerEvent("Lixo", localPlayer) -- Chama Função Lixo (Jogar Fora) end end) server.lua --[[ __ __ __ __ /\ \ /\ \ /\ \__ /\ \ \ \ \ ___ ___\ \ \/'\\ \ ,_\ ___ __ __ __ ____\ \ \/'\ \ \ \ __ / __`\ / __`\ \ , < \ \ \/ / __`\/\ \/\ \ /'__`\ /',__\\ \ , < \ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\\ \ \_/\ \L\ \ \ \_/ |/\ \L\.\_/\__, `\\ \ \\`\ \ \____/\ \____/\ \____/\ \_\ \_\ \__\ \____/\ \___/ \ \__/.\_\/\____/ \ \_\ \_\ \/___/ \/___/ \/___/ \/_/\/_/\/__/\/___/ \/__/ \/__/\/_/\/___/ \/_/\/_/ By Looktovask, Mantenha os creditos! --]] function jogarfora() outputChatBox( "test" ) end addEvent( "Lixo", true ) addEventHandler( "Lixo", root, jogarfora ) function SalvarItems() -- função end function CarregarItems() -- função end function Cachorro(source) outputChatBox( "1" ) end addEvent( "CachorroQ", true ) addEventHandler( "CachorroQ", root, Cachorro ) function Pitsa(source) outputChatBox( "2" ) end addEvent( "Pizza", true ) addEventHandler( "Pizza", root, Pitsa ) function Biscoito(source) outputChatBox( "3" ) end addEvent( "Biscoitos", true ) addEventHandler( "Biscoitos", root, Biscoito ) function Marmita(source) outputChatBox( "4" ) end addEvent( "Marmitex", true ) addEventHandler( "Marmitex", root, Marmita ) function Agua(source) outputChatBox( "5" ) end addEvent( "AguaM", true ) addEventHandler( "AguaM", root, Agua ) function Refri(source) outputChatBox( "6" ) end addEvent( "Refrigerante", true ) addEventHandler( "Refrigerante", root, Refri ) function Socorros(source) outputChatBox( "7" ) end addEvent( "PrimeirosS", true ) addEventHandler( "PrimeirosS", root, Socorros ) and i have another question, how i can make the player need to wait the function end to click again on "Usar" Edited February 27, 2021 by Looktovask Link to comment
Tekken Posted February 27, 2021 Share Posted February 27, 2021 (edited) Please use code tags: <> when posting code! Sorry that have to do something with Forum theme that changed! Edited February 27, 2021 by Tekken 1 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