-
Posts
97 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Rakashy
-
Resolvido, pode fechar o post
-
Bom, gostaria de uma luz, possuo um sistema de inventário em banco de dados MySql, quando o jogador morre não está perdendo as armas, (não tem nenhum sistema a parte salvando pois testei só com o sistema de inventário e mesmo assim o erro continua). Tentei utilizar a função takeallweapons no onPlayerWasted, porém não acontece nada, minha pergunta é, como eu faço para quando o jogador morrer, ser retirado as armas do inventário dele através do banco de dados ? Se alguém puder me dar um exemplo de como começar pelo menos, já seria de grande ajuda
-
PROBLEMA COM BANCO DE DADOS (ME AJUDEM POR FAVOR)
Rakashy replied to Rakashy's topic in Programação em Lua
Sim, foi bobeira minha, eu dei uma olhada, e era 1 valor invertido, consegui resolver, está 100% agora, o único problema é que os items nao somem quando morre, teria alguma solução do que fazer para excluir as armas do banco de dados quando o jogador morrer ? -
PROBLEMA COM BANCO DE DADOS (ME AJUDEM POR FAVOR)
Rakashy replied to Rakashy's topic in Programação em Lua
Consegui resolver, PORÉM agora o item está vindo na mesma quantidade que vale, por exemplo, 1 hamburguer vale 100 reais, vem 100 hamburgueres para o inventário -
Depois de muito custo consegui desbugar quase que 90% do sistema de inventário. Agora o único problema é que o item não vai, ele gera o item no banco de dados, porém não aparece no inventário, como podem ver no vídeo. Alguém tem alguma solução ? Vídeo demonstrativo
-
Eu ja fiz essa alteração kkk, li na wiki e chegue ia este mesmo resultado, funciona bem, a questão é que, os items não estão indo para o banco de dados, nas tabelas do mysql até geram os ids de item quando compro algo, porém não estão aparecendo no inventário.
-
Bom, dei mais uma vasculhada na Wiki, e arrumei o código para este: function buyItem(player, item, value, amount, count, db) local money = getPlayerMoney(player) if money > amount then exports.Rakashy_inventario:giveItem(player, item, value, db, 0) exports["Rakashy_info"]:showBoxS(player,"Compra efetuada com sucesso","info") else exports["Rakashy_info"]:showBoxS(player,"Dinheiro insuficiente","error") end end addEvent("addItem", true) addEventHandler("addItem", getRootElement(), buyItem) Agora quando o dinheiro é maior recebo a mensagem "Compra efetuada com sucesso", e quando é menor, recebo "Dinheiro insuficiente", a questão é que, o item não está indo pro inventário kkkk, e não apresenta NENHUM erro ainda,
-
Bom, script todo certo, não há NENHUM erro, o problema é que quando tento efetuar a compra de qualquer item, recebo o erro : server.lua:4: attempt to compare number with boolean Seque abaixo a parte do script, lembrando que é em MySql, e que todas as tabelas estão de acordo. server: function buyItem(player, item, value, amount, count, db) if (getElementData(player, "char.money")>=amount) then -- PARTE ONDE OCORRE O ERRO exports.Rakashy_inventario:giveItem(player, item, value, db, 0) setElementData(player, "char.money", getElementData(player, "char.money") - amount) exports["Rakashy_info"]:showBoxS(player,"Compra efetuada com sucesso","info") else exports["Rakashy_info"]:showBoxS(player,"Dinheiro insuficiente","error") end end addEvent("addItem", true) addEventHandler("addItem", getRootElement(), buyItem) Teria alguma variável que eu poderia substituir pelo "char.money" ? digo, algo que esteja na wiki ? tentei algo como getPlayerMoney, más não tive resultados. Ou caso alguém tenha um sistema de compra e exportação de item pro inventário mais fácil, e queira compartilhar, seria de grande ajuda.
-
Eu de novo aqui kkk, Bom, o sistema de carro esta perfeitamente bem, todas as Keys funcionam e não apresenta absolutamente NENHUM erro, o que dificulta. Resumindo, ao apertar a Bind Key que deveria confirmar a compr ado veiculo, nao acontece absolutamente NADA, no entanto as outras binds como de passar os carros, mudar cor, etc, Funcionam perfeitamente, alguma solução rápida ? server: addEvent("onClientBuyVehicle", true) addEventHandler("onClientBuyVehicle", root, function(playerSource, model, price, r, g, b, r1, g1, b1) if setElementData(playerSource, "char.money", getElementData(playerSource, "char.money") - price) then local regiertek = getElementData(playerSource, "char.money") local ujertek = getElementData(playerSource, "char.money") + price exports["vz_vehicle"]:createShopVehicle(playerSource, model, r, g, b, r1, g1, b1) exports["vz_info"]:showBoxS(playerSource,"Compra efetuada com sucesso","info") outputChatBox("#4169E1[SERVER NAME]: #ffffffLembre-se de estacionar seu veiculo para que ele sejá salvo em nosso sistema", playerSource, 255, 255, 255, true) end end) addEvent("onClientBuyVehiclePP", true) addEventHandler("onClientBuyVehiclePP", root, function(playerSource, model, pp, r, g, b, r1, g1, b1) if setElementData(playerSource, "char.diamante", getElementData(playerSource, "char.diamante") - pp) then local regipp = getElementData(playerSource, "char.diamante") local ujpp = getElementData(playerSource, "char.diamante") - pp exports["vz_vehicle"]:createShopVehicle(playerSource, model, r, g, b, r1, g1, b1) exports["vz_info"]:showBoxS(playerSource,"Compra efetuada com sucesso","info") outputChatBox("#4169E1[SERVER NAME]: #ffffffLembre-se de estacionar seu veiculo para que ele sejá salvo em nosso sistema", playerSource, 255, 255, 255, true) end end) Client: local screenSize = {guiGetScreenSize()} local currSelected = 1 local isShopActive = false local left, top = screenSize[1]/2 - 414/2, screenSize[2]/2 - 163/2 - 30 local dataFont = dxCreateFont("files/font.ttf", 19, false, "cleartype") local sellVehicles = {-- [ID DO VEICULO], [NOME DO VEICULO], [VALOR EM DINHEIRO], [KM/H], [VALOR EM DIAMANTE], [UNIDADES DISPONIVEIS] {600, "SAVEIRO CROSS", 1000, 180, 800, 21}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, {586, "NOME DO CARRO", 3200, 50, 800, 0}, } local blip = createBlip(1329.7835693359, -877.1875, 39.578125,55) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() shopPickup = createPickup(1329.7835693359, -877.1875, 39.578125, 3, 1274) end) addEventHandler("onClientPickupHit", root, function(playerSource) if source == shopPickup and playerSource == localPlayer then cancelEvent() fadeCamera(false) setElementFrozen(localPlayer, true) isShopActive = true setElementData(localPlayer, "showOOC", 0) setElementData(localPlayer, "showHUD", 0) setElementData(localPlayer, "showRadar", 0) setTimer(function() fadeCamera(true) setCameraMatrix(1317.8608398438, -867.76007080078, 41.221599578857, 1317.7788085938, -866.78424072266, 41.019165039063) shopVehicle = createVehicle(sellVehicles[currSelected][1], 1317.5485839844, -854.9912109375, 39.096145629883) addEventHandler("onClientRender", root, vehicleRotation) addEventHandler("onClientGUIClick", root, colorButtonFunctions) updateCarColor() end, 2000, 1) showChat(false) currSelected = 1 end end) function exitShop() if isShopActive then setElementFrozen(localPlayer, false) setElementDimension(localPlayer, 0) setCameraTarget(localPlayer) setElementData(localPlayer, "showOOC", 1) setElementData(localPlayer, "showHUD", 1) setElementData(localPlayer, "showRadar", 1) isShopActive = false destroyElement(shopVehicle) setElementPosition(localPlayer, 1333.9366455078, -875.04479980469, 39.578125) removeEventHandler("onClientRender", root, vehicleRotation) removeEventHandler("onClientGUIClick", root, colorButtonFunctions) showChat(true) currSelected = 1 updateCarColor() end end addEvent("backToCharacter",true) addEventHandler("backToCharacter",getRootElement(),exitShop) function vehicleRotation() local x, y, z = getElementRotation(shopVehicle) setElementRotation(shopVehicle, x, y, z + 0.5) panelImage = dxDrawImage(left-50, top * 2, 566, 245, "files/carshop.png") dxDrawText(sellVehicles[currSelected][2], left + 58, top * 2 + 31, 269, 10, tocolor(65, 105, 225,204), 0.5, dataFont) dxDrawText(sellVehicles[currSelected][4].. "#4169E1 km/h", left + 89.1, top * 2 + 55, 269, 10, tocolor(255,255,255,204), 0.5, dataFont, "left", "top", false, false, false, true) dxDrawText("#4169E1$#ffffff" ..sellVehicles[currSelected][3], left + 70, top * 2 + 165, 269, 10, tocolor(255,255,255,190), 0.5, dataFont, "left", "top", false, false, false, true) dxDrawText("#4169E1$#ffffff"..sellVehicles[currSelected][5].."", left + 80, top * 2 + 194, 269, 10, tocolor(255,255,255,190), 0.5, dataFont, "left", "top", false, false, false, true) if sellVehicles[currSelected][6] > 0 then dxDrawText((#getPremiumVehicles(sellVehicles[currSelected][1]) or 0).."#ffffff/#4169E1"..sellVehicles[currSelected][6], left + 58, top * 2 + 82, 269, 10, tocolor(65, 105, 225,204), 0.5, dataFont, "left", "top", false, false, false, true) else dxDrawText("Não", left + 58, top * 2 + 82, 269, 10, tocolor(65, 105, 225,204), 0.5, dataFont, "left", "top", false, false, false, true) end end addEventHandler("onClientKey", root, function(key, source) if not source or not isShopActive then return end if key == "backspace" then exitShop() elseif key == "arrow_l" then if sellVehicles[currSelected - 1] then currSelected = currSelected - 1 setElementModel(shopVehicle, sellVehicles[currSelected][1]) else currSelected = #sellVehicles setElementModel(shopVehicle, sellVehicles[currSelected][1]) end elseif key == "arrow_r" then if sellVehicles[currSelected + 1] then currSelected = currSelected + 1 setElementModel(shopVehicle, sellVehicles[currSelected][1]) else currSelected = 1 setElementModel(shopVehicle, sellVehicles[currSelected][1]) end elseif key == "enter" then if sellVehicles[currSelected][6] > 0 then if (#getPremiumVehicles(sellVehicles[currSelected][1]) or 0) >= sellVehicles[currSelected][6] then exports["vz_info"]:showBox("A loja atingiu o limite maximo desse veiculo","error") return end end if sellVehicles[currSelected][3] > tonumber(getElementData(localPlayer, "char.money")) then exports["vz_info"]:showBox("Dinheiro insuficiente","error") else local r,g,b,r1,g1,b1 = getVehicleColor(shopVehicle, true) triggerServerEvent("onClientBuyVehicle", localPlayer, localPlayer, sellVehicles[currSelected][1], sellVehicles[currSelected][3], r, g, b, r1, g1, b1) exitShop() end elseif key == "d" then if sellVehicles[currSelected][5] > tonumber(getElementData(localPlayer, "char.diamante")) then exports["vz_info"]:showBox("Diamante insuficiente","error") else local r,g,b,r1,g1,b1 = getVehicleColor(shopVehicle, true) triggerServerEvent("onClientBuyVehiclePP", localPlayer, localPlayer, sellVehicles[currSelected][1], sellVehicles[currSelected][5], r, g, b, r1, g1, b1) exitShop() end end end) function updateCarColor() if isShopActive then orange = guiCreateButton(left+8, top * 2 + 123, 15, 15, "o", false) guiSetAlpha(orange, 0) red = guiCreateButton(left+28, top * 2 + 123, 15, 15, "r", false) guiSetAlpha(red, 0) black = guiCreateButton(left+48, top * 2 + 123, 15, 15, "b", false) guiSetAlpha(black, 0) white = guiCreateButton(left+68, top * 2 + 123, 15, 15, "w", false) guiSetAlpha(white, 0) blue = guiCreateButton(left+88, top * 2 + 123, 15, 15, "b", false) guiSetAlpha(blue, 0) green = guiCreateButton(left+108, top * 2 + 123, 15, 15, "g", false) guiSetAlpha(green, 0) else destroyElement(orange) destroyElement(red) destroyElement(black) destroyElement(white) destroyElement(blue) destroyElement(green) end end function colorButtonFunctions(button,state) if source == orange then setVehicleColor(shopVehicle, 219, 105, 13, 255, 255, 255) elseif source == red then setVehicleColor(shopVehicle, 157, 37, 37, 255, 255, 255) elseif source == black then setVehicleColor(shopVehicle, 0, 0, 0, 255, 255, 255) elseif source == white then setVehicleColor(shopVehicle, 255, 255, 255, 255, 255, 255) elseif source == blue then setVehicleColor(shopVehicle, 9, 53, 93, 255, 255, 255) elseif source == green then setVehicleColor(shopVehicle, 10, 55, 27, 255, 255, 255) end end function getVehicleRealName(model) for k, v in ipairs(sellVehicles) do if v[1] == model then return v[2] end end return "Desconhecido" end function getVehiclePrice(model) for k, v in ipairs(sellVehicles) do if v[1] == model then return v[3] end end return 5000 end function getPremiumVehicles(id) local have = {} for k, v in ipairs(getElementsByType("vehicle")) do if getElementData(v, "veh.owner") and getElementData(v, "veh.owner") > 0 then if id == getElementModel(v) then have[#have + 1] = v end end end return have end
-
Mano vou enviar pra voce o conjunto, o Shop, inventário
-
Mesmo com o gamemode alterado, possuo um [play] modificado, que não salva, tanto que com o inventário desativado, as armas são perdidas na morte, porém com o inventário, assim que renasço, lá estão elas no meu inventário novamente.
-
Notei que no script todo não há registro de algum "setElementData (char.money)", logo, o getElementData (char.money) nao funciona, talvez este seja o erro ? se sim, aonde basicamente eu deveria adicionar a data?
-
Bom, parou de dar erro, porém agora quando clico pra confirmar a compra do item na loja (no caso comida), não acontece absolutamente nada, o item não vai ao inventário, e também não apresenta nenhum erro... Bom, consegui resolver, era um Event errado, Erro meu, porém kkk, agora o problema é que consigo comprar o item na loja, só que não está descontando o dinheiro, o item vem de graça, e por exemplo, ele custa "6Reais", quando compra vem 6 Unidades do item, alguma ideia ?
-
E como eu poderia resolver isto ? deve ser algo bobo, más que está me dando uma dor de cabeça...
-
Bom, eu possuo um sistema de compra de items por uma loja, tudo perfeito sem nenhum erro, porém quando tento comprar algo, recebo o seguinte erro: server.lua:14 attempt to compare number with boolean abaixo a parte aonde está dando o erro. function buyItem(player, item, value, amount, count, db) if (getElementData(player, "char.money")>=amount) then exports.inventario:giveItem(player, item, value, db, 0) setElementData(player, "char.money", getElementData(player, "char.money") - amount) exports["info"]:showBoxS(player,"Compra efetuada com sucesso","info") else exports["info"]:showBoxS(player,"Dinheiro insuficiente","error") end end addEvent("addItem", true) addEventHandler("addItem", getRootElement(), buyItem) Alguma solução ? o erro poderia ser devido ao "amount" dps do >= ? por não conter um numeral de 0-1 ? se alguém tiver alguma sugestão..
-
Server mysqlConnection = exports["mtasa_sqlite"]:getConnection() function getElementItems(playerSource, elementSource, playerValue) if (elementSource) then local elementTypes = getTypeOfElement(elementSource) local elementOwnerID = tonumber(getElementData(elementSource, "ID")) local loadedItems = { ["bag"] = {}, ["key"] = {}, ["cards"] = {}, } local query = dbPoll(dbQuery(mysqlConnection, "SELECT * FROM items WHERE item_owner = ? and item_type = ?", elementOwnerID, elementTypes[1]), -1) if query then for index, sor in ipairs (query) do if not loadedItems[items[tonumber(sor["item_id"])].typ] then loadedItems[items[tonumber(sor["item_id"])].typ] = {} end loadedItems[items[tonumber(sor["item_id"])].typ][tonumber(sor["item_slot"])] = { ["ID"] = tonumber(sor["id"]), ["id"] = tonumber(sor["item_id"]), ["value"] = tostring(sor["item_value"]), ["count"] = tonumber(sor["item_count"]), ["duty"] = tonumber(sor["item_duty"]), ["slot"] = tonumber(sor["item_slot"]), ["health"] = tonumber(sor["item_health"]), } end end if (tonumber(playerValue) == 1 or tonumber(playerValue) == 2) then triggerClientEvent(playerSource, "setElementItems", playerSource, loadedItems, playerValue, elementSource) else return loadedItems end end end addEvent("getElementItems", true) addEventHandler("getElementItems", getRootElement(), getElementItems) addEvent("itemBugFixServer", true) addEventHandler("itemBugFixServer", root, function(player) triggerClientEvent(player, "itemBugFixClient", player) end) function takeStatus(playerSource, elementSource, itemDBID, newStatus) if (newStatus) then dbPoll(dbQuery(mysqlConnection, "UPDATE items SET item_health = ? WHERE id = ?", newStatus, itemDBID), -1) end end addEvent("takeStatus", true) addEventHandler("takeStatus", getRootElement(), takeStatus) function updateItemSlot(playerSource, elementSource, newSlot, oldItem) if (newSlot and oldItem) then local itemDBID = oldItem["ID"] dbPoll(dbQuery(mysqlConnection, "UPDATE items SET item_slot = ? WHERE id = ?", newSlot, itemDBID), -1) end end addEvent("updateItemSlot", true) addEventHandler("updateItemSlot", getRootElement(), updateItemSlot) function updateItemCount(playerSource, elementSource, itemSlot, newCount, itemDBID) if (newCount and itemDBID) then dbPoll(dbQuery(mysqlConnection, "UPDATE items SET item_count = ? WHERE id = ?", newCount, itemDBID), -1) end end addEvent("updateItemCount", true) addEventHandler("updateItemCount", getRootElement(), updateItemCount) function updateItemValue(playerSource, elementSource, itemSlot, newValue, itemDBID) if (newValue and itemDBID) then dbPoll(dbQuery(mysqlConnection, "UPDATE items SET item_value = ? WHERE id = ?", newValue, itemDBID), -1) end end addEvent("updateItemValue", true) addEventHandler("updateItemValue", getRootElement(), updateItemValue) function removeDutyItems(element) if not mysqlConnection then return end local playerItems = getElementItems(element, element, 0) for k, v in ipairs(playerItems["bag"]) do if (tonumber(v["duty"]) >= 1) then deleteItem(element, element, v["ID"]) end end for k, v in ipairs(playerItems["key"]) do if (tonumber(v["duty"]) >= 1) then deleteItem(element, element, v["ID"]) end end for k, v in ipairs(playerItems["cards"]) do if (tonumber(v["duty"]) >= 1) then deleteItem(element, element, v["ID"]) end end getElementItems(element, element, 1) end addEvent("removeDutyItems", true) addEventHandler("removeDutyItems", getRootElement(), removeDutyItems) function takeAllItem(element, itemID, itemValue) if not mysqlConnection then return end local playerItems = getElementItems(element, element, 0) for k, v in ipairs(playerItems["bag"]) do if (tonumber(v["id"]) == itemID) and (tonumber(v["value"]) == itemValue)then deleteItem(element, element, v["ID"]) end end for k, v in ipairs(playerItems["key"]) do if (tonumber(v["id"]) == itemID) and (tonumber(v["value"]) == itemValue) then deleteItem(element, element, v["ID"]) end end for k, v in ipairs(playerItems["cards"]) do if (tonumber(v["id"]) == itemID) and (tonumber(v["value"]) == itemValue) then deleteItem(element, element, v["ID"]) end end getElementItems(element, element, 1) end addEvent("takeAllItem", true) addEventHandler("takeAllItem", getRootElement(), takeAllItem) function deleteItem(playerSource, elementSource, itemDBID) if (elementSource and itemDBID) then dbPoll(dbQuery(mysqlConnection, "DELETE FROM items WHERE id = ?", itemDBID), -1) end end addEvent("deleteItem", true) addEventHandler("deleteItem", getRootElement(), deleteItem) function takeWeaponFromPlayer(element) if not mysqlConnection then return end takeAllWeapons(element) setElementData(element, "Char->usingWeapon", {false, -1, -1, -1, -1, -1}) end addEvent("takeWeaponFromPlayer", true) addEventHandler("takeWeaponFromPlayer", getRootElement(), takeWeaponFromPlayer) playerWeapons = {} function checkWeapons(player, array) if array then if playerWeapons[player] then for k, v in ipairs(playerWeapons[player]) do if isElement(v[1]) then destroyElement(v[1]) end playerWeapons[player] = {} end end for i=1, row * column do if array["bag"] and array["bag"][i] and tonumber(array["bag"][i]["id"] or -1) > -1 and weaponModels[array["bag"][i]["id"]] then local model_ID = weaponModels[array["bag"][i]["id"]][1] if not playerWeapons[player] then playerWeapons[player] = {} end local obj = createObject(model_ID, 0, 0, 0) setObjectScale(obj, weaponModels[array["bag"][i]["id"]].scale) setElementCollisionsEnabled(obj, false) playerWeapons[player][#playerWeapons[player] + 1] = {obj, model_ID, item_id = array["bag"][i]["id"], slot = array["bag"][i]["slot"]} end end end end addEvent("Inventory->checkWeapons", true) addEventHandler("Inventory->checkWeapons", getRootElement(), checkWeapons) function getWeaponFromID(playerSource, wID) for k, v in ipairs(playerWeapons[playerSource]) do if (tonumber(v.model_ID) == tonumber(weaponModels[wID][1])) then return k end end return -1 end addEventHandler("onPlayerQuit", root, function() for k, v in ipairs(getElementsByType("vehicle")) do if (getElementData(v, "Inventory->Vehicle->isOpened") or false) then if getElementData(v, "Inventory->Vehicle->opener_Player") == source then setElementData(v, "Inventory->Vehicle->opener_Player", nil) setElementData(v, "Inventory->Vehicle->isOpened", false) end end end if playerWeapons[source] then for k, v in ipairs(playerWeapons[source]) do if isElement(v[1]) then destroyElement(v[1]) end playerWeapons[source] = {} end end end) function createNewItem(playerSource, elementSource, itemID, itemSlot, itemCount) if (itemID and itemSlot) then local elementType = getTypeOfElement(elementSource) local elementOwnerID = tonumber(getElementData(elementSource, "ID")) local elementOwnerType = elementType[1] dbPoll(dbQuery(mysqlConnection, "INSERT INTO items SET item_id = ?, item_slot = ?, item_owner = ?, item_value = 1, item_count = ?, item_type = ?, item_duty = 0", itemID, itemSlot, elementOwnerID, itemCount, elementOwnerType), -1) if (elementSource == playerSource) then getElementItems(playerSource, elementSource, 2) end getElementItems(playerSource, elementSource, 1) end end addEvent("createNewItem", true) addEventHandler("createNewItem", getRootElement(), createNewItem) function tradeItem(playerSource, elementSource, activeElementSource, activeItem) if (playerSource and elementSource and activeItem) then local elementType = getTypeOfElement(elementSource) local itemDBID = activeItem["ID"] local elementOwnerID = tonumber(getElementData(elementSource, "ID")) local elementOwnerType = elementType[1] local pSlotState, pSlotID = getFreeSlot(elementSource, activeItem["id"]) if (pSlotState and pSlotID) then if dbPoll(dbQuery(mysqlConnection, "UPDATE items SET item_type = ?, item_owner = ?, item_slot = ? WHERE id = ?", elementOwnerType, elementOwnerID, pSlotID, itemDBID), -1) then if (activeElementSource == playerSource) then getElementItems(playerSource, activeElementSource, 2) end local playerItems = getElementItems(elementSource, elementSource, 0) checkWeapons(elementSource, playerItems) getElementItems(playerSource, activeElementSource, 1) end end if elementOwnerType == "player" then elseif elementOwnerType == "vehicle" then elseif elementOwnerType == "object" then end end end addEvent("tradeItem", true) addEventHandler("tradeItem", getRootElement(), tradeItem) function getElementItemsWeight(element) local playerItems = getElementItems(element, element, 0) local bagWeight = 0 local keyWeight = 0 local cardsWeight = 0 for i = 1, row * column do if (playerItems["bag"][i]) then bagWeight = bagWeight + (getItemWeight(playerItems["bag"][i]["id"]) * playerItems["bag"][i]["count"]) end end for i = 1, row * column do if (playerItems["key"][i]) then keyWeight = keyWeight + (getItemWeight(playerItems["key"][i]["id"]) * playerItems["key"][i]["count"]) end end for i = 1, row * column do if (playerItems["cards"][i]) then cardsWeight = cardsWeight + (getItemWeight(playerItems["cards"][i]["id"]) * playerItems["cards"][i]["count"]) end end return math.ceil(bagWeight + cardsWeight + keyWeight) end function hasItem(playerSource, itemID) if not mysqlConnection then return end local playerItems = getElementItems(playerSource, playerSource, 0) if playerItems then for i=1, (row*column) do if(playerItems["bag"][i] and tonumber(playerItems["bag"][i]["id"] or -1) > 0)then if tonumber(playerItems["bag"][i]["id"]) == itemID and tonumber(playerItems["bag"][i]["value"]) > 0 then return {true, i, playerItems["bag"][i]["value"]} end end end return {false, -1, 0} end end addEvent("hasItem", true) addEventHandler("hasItem", getRootElement(), hasItem) function giveItem(playerSource, itemID, itemValue, itemCount, itemDuty) if (playerSource and itemID and itemValue and itemCount and itemDuty) then local elementType = getTypeOfElement(playerSource) local elementOwnerID = tonumber(getElementData(playerSource, "ID")) local elementOwnerType = elementType[1] local pSlotState, pSlotID = getFreeSlot(playerSource, itemID) dbPoll(dbQuery(mysqlConnection, "INSERT INTO items ( item_id, item_slot, item_owner, item_value, item_count, item_type, item_duty) VALUES ( '"..itemID.."', '"..pSlotID.."', '"..elementOwnerID.."', '"..itemValue.."', '"..itemCount.."', '"..elementOwnerType.."', '"..itemDuty.."' )"), -1) getElementItems(playerSource, playerSource, 1) getElementItems(playerSource, playerSource, 2) end end addEvent("giveItem", true) addEventHandler("giveItem", root, giveItem) addCommandHandler("enviaritem", function(playerSource, cmd, id, item, value, count,dutyitem, itemState) if getElementData(playerSource, "char.adminlevel") >= 5 then -- Administrador acima do nivel *5 podera usar a função if id and item and value and count and dutyitem then local targetPlayer, targetPlayerName = exports['vz_main']:findPlayerByPartialNick(playerSource, id) if targetPlayer then if tonumber(item) == 1 then addPhone(targetPlayer) elseif tonumber(item) == 53 then addLaptop(targetPlayer) else giveItem(targetPlayer,tonumber(item),tostring(value),tonumber(count),tonumber(dutyitem)) end end else outputChatBox("#4169E1[Use]:#ffffff /"..cmd.." [ID] [ItemID] [Quantidade] [DB] [Bloqueado [0=Não , 1=Sim]", playerSource,255,255,255,true) end end end ) function hasPlayerAmmo(playerSource, item_id) if not mysqlConnection then return end local playerItems = getElementItems(playerSource, playerSource, 0) if playerItems then for i=1, (row*column) do if(playerItems["bag"][i] and tonumber(playerItems["bag"][i]["id"] or -1) > 0)then if tonumber(playerItems["bag"][i]["id"]) == item_id and tonumber(playerItems["bag"][i]["value"]) > 0 then return {true, i, playerItems["bag"][i]["value"]} end end end return {false, -1, 0} end end function getFreeSlot(elementSource, forItemID) local playerItems = getElementItems(elementSource, elementSource, 0) local nextSlot = 1 for i = 1, (row * column) do if not (playerItems[items[forItemID].typ][i]) then return true, nextSlot else nextSlot = nextSlot + 1 end end return false, -1 end function loadCraftMarkers() for k,v in ipairs(craftMarkers) do local markers = createMarker(v[1],v[2],v[3]-1, "cylinder", 0.55,65, 105, 225,150) setElementDimension(markers,9) setElementInterior(markers,2) setElementData(markers, "craftMark", true) setElementData(markers, "craftMark:ID", k) end for k,v in ipairs(getElementsByType("vehicle")) do setElementData(v,"veh:use",false) end end addEventHandler("onResourceStart", resourceRoot, loadCraftMarkers) function doorState(vehicle,typ) if typ == 1 then setVehicleDoorOpenRatio(vehicle,1,1,1200) setElementData(vehicle,"veh:use",true) else setVehicleDoorOpenRatio(vehicle,1,0,1200) setElementData(vehicle,"veh:use",false) end end addEvent("doorState", true) addEventHandler("doorState", root, doorState) function itemAnim(element, targetElement) setPedAnimation(element,"DEALER","DEALER_DEAL",3000,false,false,false,false) setPedAnimation(targetElement,"DEALER","DEALER_DEAL",3000,false,false,false,false) end addEvent("itemAnim", true) addEventHandler("itemAnim", root, itemAnim) function takeItem(playerSource,item) triggerClientEvent(playerSource,"takeItemServer",playerSource,item) end function onServerBikeLockStateChange(v) local lockState = tonumber(getElementData(v, "veh.locked")) or 0 if lockState == 1 then setVehicleLocked(v, false) setElementData(v, "veh.locked", 0) else setElementData(v, "veh.locked", 1) setVehicleLocked(v, true) end end addEvent("onServerBikeLockStateChange", true) addEventHandler("onServerBikeLockStateChange", root, onServerBikeLockStateChange) addEvent("sendBugMessageToAdmins", true) addEventHandler("sendBugMessageToAdmins", root, function(player) for k, v in ipairs(getElementsByType("player")) do if (getElementData(v, "char.adminlevel") or 0) >= 6 then end end end) local serverItemCache = {} function loadPlayerItems(player) for i=0,31 do setElementData(player, "items"..i, 0) end serverItemCache[player] = {} local dbid = tonumber(getElementData(player, "ID")) dbQuery( function (queryHandler) local result, numAffectedRows, errorMsg = dbPoll(queryHandler, 0) if numAffectedRows > 0 then for k,row in pairs(result) do local slot = tonumber(row.slot) or -1 local id = tonumber(row.id) or 0 local item = tonumber(row.itemID) or 0 local value = tostring(row.itemValue) or 0 serverItemCache[player][#serverItemCache[player] + 1] = {item,value,slot,id} end triggerClientEvent(player, "onClientReceiveItems", player, serverItemCache[player]) end end, connection, "SELECT * FROM items WHERE type = 1 AND owner = ?", dbid ) end addEvent("loadPlayerItems",true) addEventHandler("loadPlayerItems", getRootElement(), loadPlayerItems) Client -- © Créditos: Mods MTA Oficial & Blowiddev -- © Site: www.modsmta.com.br sX, sY = guiGetScreenSize() pW, pH = itemSize*column + margin*(column+1), itemSize * row + (1+row)*margin moveX, moveY = (sX/2), (sY/2) setElementData(localPlayer, "char.showedPlayerInventory", 0) showInventory = false local showLeft = false local font = dxCreateFont("files/font.ttf", 16, false, "cleartype") local lastClick = 0 local invMenu = 1 local selectedAmount = 1 local amountBox = nil local inSlotBox = false local m = {} local moving = false playerItems = {} inventoryItems = {} itemBugFixOnOff = false clickedTimer = false local actionItems = {} local elementSource = nil activeSide = "bag" newMenu = nil local vehBoot = false local hoverSlot = -1 local hoverItem = nil local inMove = false local startTick = -1 local movedItem = nil local movedSlot = -1 local inClone = false local clonedItem = nil local clonedSlot = -1 local actionSlots = 6 local action_array = {} for i=1, actionSlots do action_array[i] = {-1, -1, "bag"} end local isCursorInAction = false local current_action_slot = -1 local isMove = false defX, defY = 0,0 actPos = {sX/2-(300/2), sY-50} activeBikeLockSlot = -1 activeBikeLockKeySlot = -1 activeCuffSlot = -1 activeCuffKeySlot = -1 bodySearchState = false bodySearchInventoryOpened = false local panelSize = {350, 15} local font_progress = dxCreateFont("files/font.ttf", 19, false, "cleartype") local bodysearch_progress_tick = 0 local bodysearch_progress_max = panelSize[1] local bodysearch_progress_text = "" function getCursor:O() cX, cY = getCursorPosition() cX, cY = cX*sX, cY*sY return cX, cY end addEventHandler("onClientClick",getRootElement(),function(button,state) if showInventory then if button == "left" and state == "down" then if isInBox(moveX-25, moveY-24, 427, 18) then isMove = true local curX, curY = getCursor:O() local x,y = moveX,moveY defX, defY = curX - x, curY - y end elseif button == "left" and state == "up" then if isMove then isMove = false end end end end) bindKey("b", "down", function() --if not getElementData(localPlayer, "CharLoggedIn") then return end openInventory(localPlayer) if getElementData(localPlayer, "char.showedPlayerInventory") > 0 then setElementData(localPlayer, "char.showedPlayerInventory", 0) end end ) bindKey("m", "down", function() if not movedItem then showCursor(not isCursorShowing()) end end) function removeHex (text) return type(text)=="string" and string.gsub(text, "#%x%x%x%x%x%x", "") or text end function create_tooltip(text) local cx, cy = getCursorPosition() cx, cy = cx * sX, cy * sY if text then local textWidth = dxGetTextWidth(removeHex(text), 1) dxDrawRectangle(cx - textWidth/2, cy - 25/2 -50, textWidth+10, 45, tocolor(0, 0, 0, 255/100*85), true) dxDrawText(text, cx - textWidth/2, cy - 25/2-100, textWidth + cx - textWidth/2+10, 45 + cy - 25/2 , tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true) end end local function tooltip( text, text2 ) local x,y = getCursorPosition( ) local x,y = x * sX, y * sY text = tostring( text ) if text2 then text2 = tostring( text2 ) end if text == text2 then text2 = nil end local width = dxGetTextWidth(text,1,"clear") + 20 if text2 then width = math.max( width, dxGetTextWidth( text2, 1, "clear" ) + 20 ) text = text .. "\n"..text2 end local height = 10 * ( text2 and 5 or 3) x = math.max( 10, math.min( x, sX - width - 10 ) ) y = math.max( 10, math.min( y, sY - height - 10 ) ) dxDrawRectangle(x, y, width, height, tocolor(0,0,0,160), true); dxDrawText( text, x, y, x + width, y + height, tooltip_text_color, 0.5, font, "center", "center", false, false, true,true) end local function tooltipWeapons( text, text2 ) local x,y = getCursorPosition( ) local x,y = x * sX, y * sY text = tostring( text ) if text2 then text2 = tostring( text2 ) end if text == text2 then text2 = nil end local width = dxGetTextWidth( text, 1, "clear" ) + 20 if text2 then width = math.max( width, dxGetTextWidth( text2, 1, "clear" ) + 20 ) text = text .. "\n" .. text2 end local height = 12 * ( text2 and 5 or 3) x = math.max( 10, math.min( x, sX - width - 10 ) ) y = math.max( 10, math.min( y, sY - height - 10 ) ) dxDrawRectangle(x, y, width, height, tocolor(0,0,0,160), true); dxDrawText( text, x, y, x + width, y + height, tooltip_text_color, 0.5, font, "center", "center", false, false, true,true) end local function tooltip_item( x,y,text, text2 ) text = tostring( text ) if text2 then text2 = tostring( text2 ) end if text == text2 then text2 = nil end local width = dxGetTextWidth( text, 0.5, "clear" ) if text2 then width = math.max( width, dxGetTextWidth( text2, 0.5, "clear" )) text = text .. "\n" .. text2 y = y - 20 end local height = 10 * ( text2 and 4 or 2 ) x = x - (width/2) + (itemSize) dxDrawText( text, x+33, y+80, x - width, y + height, tocolor(200, 200, 200, 250), 0.5, font, "center", "center", false, false, false ) end function openInventory(pElement) if (pElement) then showInventory = not showInventory triggerServerEvent("getElementItems", localPlayer, localPlayer, pElement, 2) activeSide = "bag" invMenu = 1 if showInventory then if not isElement(amountBox) then amountBox = guiCreateEdit (moveX+350,moveY-23,50,18,"",false) guiSetAlpha(amountBox,0) end else loadActionItems() if isElement(amountBox) then destroyElement(amountBox) end if bodySearchInventoryOpened then bodySearchInventoryOpened = false end if getElementType(elementSource) == "vehicle" then triggerServerEvent("doorState", elementSource, elementSource, 0) end end end end addEvent("openInventory", true) addEventHandler("openInventory", getRootElement(), openInventory) addEventHandler("onClientElementDataChange", root, function(dataName, oldValue) --if getElementData(localPlayer, "CharLoggedIn") then if source == localPlayer then if dataName == "ID" then local newValue = tonumber(getElementData(source, dataName)) if newValue > 0 then triggerServerEvent("getElementItems", localPlayer, localPlayer, localPlayer, 2) loadActionItems() end end end --end end) triggerServerEvent("getElementItems", localPlayer, localPlayer, localPlayer, 2) function setElementItems(itemsTable, itemValue, pElement) elementSource = pElement if (itemValue == 2) then playerItems = itemsTable end if getElementType(pElement) == "player" then triggerServerEvent("Inventory->checkWeapons", localPlayer, localPlayer, itemsTable) end inventoryItems = itemsTable end addEvent("setElementItems", true) addEventHandler("setElementItems", getRootElement(), setElementItems) function getItemImg(itemID) if (tonumber(itemID)) then if (fileExists("files/img/items/" .. itemID .. ".png")) then return "files/img/items/" .. itemID .. ".png" end return "files/img/items/1.png" end return "files/img/items/1.png" end local inItem = false local actionX, actionY = sX/2 - 269/2,sY local showBar = true local weaponHot = 0 addEventHandler("onClientResourceStart",resourceRoot,function() setTimer(function() loadActionItems() end, 2000, 1) setElementData(localPlayer,"active:itemID",-1) setElementData(localPlayer,"active:itemSlot",-1) end) for i=1, actionSlots do bindKey(i, "down", function() if action_array[i] and action_array[i][1] > -1 and hasItemOnSlot(action_array[i][1]) then useItem(playerItems[action_array[i][3]][action_array[i][1]],action_array[i][1]) if not hasItemOnSlot(action_array[i][1]) then action_array[i] = {-1,-1, -1} end end end) end local categoryTable = { {"bag","objetos","bag"}, {"key","chaves","key"}, {"cards","documentos","cards"}, } function renderInventory() hoverSlot = -1 hoverItem = nil if showBar then --if not getElementData(localPlayer, "CharLoggedIn") then return end actBox = {255,itemSize} dxDrawImage(actPos[1]-25,actPos[2]-23, 300, 80, "files/img/actionbar.png", 0, 0, 0, tocolor(255,255,255,255)) current_action_slot = -1 if isInBox(actPos[1]-10,actPos[2]-10,actBox[1]+20,actBox[2]+20) then isCursorInAction = true else isCursorInAction = false end for i=1,actionSlots do dxDrawRectangle(actPos[1]+(i*((itemSize+4)+2))-40,actPos[2], itemSize, itemSize, tocolor(0,0,0,100)) if (not guiGetInputEnabled() and not isMTAWindowActive() and not isCursorShowing() and getKeyState(i)) or isInBox(actPos[1]+(i*((itemSize+6)+2))-45,actPos[2], itemSize, itemSize) then dxDrawRectangle(actPos[1]+(i*((itemSize+4)+2))-40,actPos[2], itemSize, itemSize, tocolor(65,105,225,200)) current_action_slot = i end if action_array[i] and action_array[i][1] > -1 and not hasItemOnSlot(action_array[i][1]) and action_array[i][3] == activeSide then action_array[i] = {-1, -1, "bag"} end if action_array[i] and action_array[i][1] > -1 and hasItemOnSlot(action_array[i][1]) and action_array[i][3] == activeSide then if isInBox(actPos[1]+(i*((itemSize+6)+2))-45,actPos[2], itemSize, itemSize) then local actItem = playerItems[action_array[i][3]][action_array[i][1]]["id"] local actValue = playerItems[action_array[i][3]][action_array[i][1]]["value"] local actCount = playerItems[action_array[i][3]][action_array[i][1]]["count"] local actState = playerItems[action_array[i][3]][action_array[i][1]]["health"] local actName = items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].name if actItem == 40 or actItem == 41 or actItem == 42 or actItem == 57 then tooltip("#4169E1"..actName.."#ffffff","Identificação: #4169E1"..actValue.."") elseif (actItem >=2 and actItem <= 13) then tooltipWeapons("#4169E1"..actName.."#ffffff","Condição: #4169E1"..actState.."#ffffff%\nPeso: #4169E1"..items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].weight*actCount.." kg") elseif items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].isWeapon then tooltipWeapons("#4169E1"..actName.."#ffffff","Condição: #4169E1"..actState.."#ffffff%\nPeso: #4169E1"..items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].weight*actCount.." kg") elseif actItem == 29 or actItem == 30 or actItem == 129 then tooltip("#4169E1"..actName.." (ID: ".. actValue ..")#ffffff","Peso: #4169E1"..items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].weight*actCount.."") else tooltip("#4169E1"..actName.."#ffffff","Peso: #4169E1"..items[playerItems[action_array[i][3]][action_array[i][1]]["id"]].weight*actCount.." kg") end end dxDrawImage(actPos[1]+(i*((itemSize+4)+2))-40,actPos[2], itemSize, itemSize, "files/img/items/" .. action_array[i][2] .. ".png", 0, 0, 0, tocolor(255,255,255, 255)) --Item IMG tooltip_item(actPos[1]+(i*((itemSize+4)+2))-58,actPos[2]-23,playerItems[action_array[i][3]][action_array[i][1]]["count"]) end end end if not showInventory then return end if isMove then local x, y = getCursor:O() moveX,moveY = x - defX,y - defY end local itemWeight = getAllItemWeight() inItem = false if (isInBox(moveX-6, moveY-5, pW+12, pH+85)) then inItem = true end dxDrawImage(moveX-117, moveY-105, 600, 400, "files/img/panel/inventory.png", 0, 0, 0, tocolor(255,255,255,255)) local catCount = 0 if getElementType(elementSource) == "vehicle" or getElementType(elementSource) == "object" then categoryTable[4] = nil end for k,v in ipairs(categoryTable) do catCount = catCount+1 if isInBox(moveX-70,moveY+40+(catCount*35),22,22) and not movedItem then dxDrawImage(moveX-112, moveY-105, 600, 400, "files/img/panel/"..v[1]..".png", 0, 0, 0, tocolor(65,105,225,250)) if getKeyState("mouse1") and lastClick+200 <= getTickCount() then lastClick = getTickCount() if invMenu ~= k then playSound("files/sounds/bincoselect.mp3") end invMenu = k activeSide = v[3] end else if invMenu == k then dxDrawImage(moveX-112, moveY-105, 600, 400, "files/img/panel/"..v[1]..".png", 0, 0, 0, tocolor(65,105,225,250)) else dxDrawImage(moveX-112, moveY-105, 600, 400, "files/img/panel/"..v[1]..".png", 0, 0, 0, tocolor(200,200,200,250)) end end end local drawRow = 0 local drawColumn = 0 if activeSide == "bag" or activeSide == "cards" or activeSide == "key" then dxDrawText("Quantidade:", moveX+280, moveY-22, 0, 0, tocolor(255, 255, 255, 180), 0.5, font, "left", "top", false, false, false, true) dxDrawText(guiGetText(amountBox),moveX+355,moveY-21,0,0,tocolor(255, 255, 255, 190), 0.5, font, "left", "top", false, false, false, true) if selectedAmount <= 0 then selectedAmount = 1 guiSetText(amountBox,1) end dxDrawRectangle(moveX+350,moveY-22,50,15,tocolor(0,0,0,60)) if isInBox(moveX+330,moveY-22,50,15) then if getKeyState("mouse1") and lastClick+200 <= getTickCount() then lastClick = getTickCount() if isElement(amountBox) then if guiEditSetCaretIndex(amountBox, string.len(guiGetText(amountBox))) then guiBringToFront(amountBox) guiEditSetMaxLength(amountBox, 4) end end end end for i = 1, row * column do if isInBox(moveX + drawColumn * (itemSize + margin) + margin * 1, moveY + drawRow * (itemSize + margin) + margin * 1.6, itemSize, itemSize) then inSlotBox = true dxDrawRectangle(moveX + drawColumn * (itemSize + margin) + margin * 1, moveY + drawRow * (itemSize + margin) + margin * 1.6, itemSize, itemSize, tocolor(65,105,225,200)) -- hoverSlot = i if (inventoryItems[activeSide][i]) then hoverItem = (inventoryItems[activeSide][i]) if inventoryItems[activeSide][i]["id"] == 40 or inventoryItems[activeSide][i]["id"] == 41 or inventoryItems[activeSide][i]["id"] == 42 or inventoryItems[activeSide][i]["id"] == 57 then tooltip("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Identificação: #4169E1"..inventoryItems[activeSide][i]["value"].."") elseif (inventoryItems[activeSide][i]["id"] >=2 and inventoryItems[activeSide][i]["id"] <= 13) then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Condição: #4169E1"..inventoryItems[activeSide][i]["health"].."#ffffff%\nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") elseif items[inventoryItems[activeSide][i]["id"]].isWeapon then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Condição: #4169E1"..inventoryItems[activeSide][i]["health"].."#ffffff%\nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") elseif inventoryItems[activeSide][i]["id"] == 25 then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Valor: #4169E1"..inventoryItems[activeSide][i]["value"].."#ffffff \nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") elseif inventoryItems[activeSide][i]["id"] == 29 or inventoryItems[activeSide][i]["id"] == 30 or inventoryItems[activeSide][i]["id"] == 129 or inventoryItems[activeSide][i]["id"] == 78 then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","ID: #4169E1"..inventoryItems[activeSide][i]["value"].."#ffffff \nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") elseif inventoryItems[activeSide][i]["id"] == 141 then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Condição: #4169E1"..inventoryItems[activeSide][i]["health"].."#ffffff%\nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") elseif inventoryItems[activeSide][i]["id"] == 144 then tooltipWeapons("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Condição: #4169E1"..inventoryItems[activeSide][i]["health"].."#ffffff%\nPeso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") else tooltip("#4169E1"..items[inventoryItems[activeSide][i]["id"]].name.."#ffffff","Peso: #4169E1"..items[inventoryItems[activeSide][i]["id"]].weight*inventoryItems[activeSide][i]["count"].." kg") end else hoverItem = nil end else dxDrawRectangle(moveX + drawColumn * (itemSize + margin) + margin * 1, moveY + drawRow * (itemSize + margin) + margin * 1.6, itemSize, itemSize, tocolor(0,0,0,100)) if inventoryItems[activeSide][i] then if items[inventoryItems[activeSide][i]["id"]].typ == "bag" then if activeAmmoSlot == i or activeWeaponSlot == i or activeMask == i or activeShield == i or activeCuffSlot == i or activeCuffKeySlot == i then dxDrawRectangle(moveX + drawColumn * (itemSize + margin) + margin * 1, moveY + drawRow * (itemSize + margin) + margin * 1.6, itemSize, itemSize, tocolor(65,105,225,200)) end end end inSlotBox = false end local itemData = inventoryItems[activeSide][i] if (itemData) then local itemDbid = itemData["ID"] local itemID = itemData["id"] local itemCount = itemData["count"] local itemHeath = itemData["health"] if ((movedSlot == i)) then inMove = true local cX, cY = getCursorPosition() cX, cY = sX * cX, sY * cY dxDrawImage(cX - itemSize/2, cY - itemSize/2, 36, 36, getItemImg(tonumber(movedItem["id"])), 0, 0, 0, tocolor(255, 255, 255, 255), true) else dxDrawImage(moveX + drawColumn * (itemSize + margin) + margin * 1, moveY + drawRow * (itemSize + margin) + margin * 1.6, 36, 36, getItemImg(tonumber(itemID)), 0, 0, 0, tocolor(255, 255, 255, 255)) tooltip_item(moveX + drawColumn * (itemSize + margin) + margin * 1-18, moveY + drawRow * (itemSize + margin) + margin * 1.5-22,itemCount) if items[itemID] and items[itemID].statusbar then dxDrawRectangle(moveX + drawColumn * (itemSize + margin) + margin * 1 + 2, moveY + drawRow * (itemSize + margin) + margin * 1.5 + itemSize - 6, itemSize - 4, 4, tocolor(0, 0, 0, 255)) dxDrawRectangle(moveX + drawColumn * (itemSize + margin) + margin * 1 + 2, moveY + drawRow * (itemSize + margin) + margin * 1.5 + itemSize - 6, itemHeath / 100 * (itemSize - 4), 4, tocolor(163, 93, 0, 255)) end end end if (inClone) then local cX, cY = getCursorPosition() cX, cY = sX * cX, sY * cY dxDrawImage(cX - itemSize/2, cY - itemSize/2, 36, 36, getItemImg(tonumber(clonedItem["id"])), 0, 0, 0, tocolor(255, 255, 255, 255), true) end drawColumn = drawColumn + 1 if (drawColumn == column) then drawColumn = 0 drawRow = drawRow + 1 end end end end addEventHandler("onClientRender", getRootElement(), renderInventory) addEventHandler("onClientClick", getRootElement(), function(pButton, pState, _, _, _, _, _, clickedElement) if (pButton == "left" and pState == "down" and showInventory) then if (tonumber(hoverSlot) > -1 and hoverItem and not inClone) then if isSlotUsedByAction(hoverSlot) and bodySearchInventoryOpened == false then outputChatBox("#FF0000[Error]: #ffffffEsse item já está sendo usado", 255,255,255,true) return end if itemBugFixOnOff then return end if bodySearchInventoryOpened then return end if activeSide == "bag" and activeWeaponSlot == hoverSlot or activeAmmoSlot == hoverSlot or activeMask == hoverSlot or activeShield == hoverSlot then else startTick = getTickCount() movedItem = hoverItem movedSlot = tonumber(hoverSlot) if guiGetText(amountBox) == "" then else inClone = true clonedItem = hoverItem clonedSlot = tonumber(hoverSlot) end end end if(isCursorInAction and current_action_slot > -1)then action_array[current_action_slot] = {-1, -1, "bag"} saveAction() itemBugFixOn() end elseif (pButton == "left" and pState == "up" and showInventory) then if (not inItem and isCursorInAction and movedItem and movedSlot > -1) then action_array[current_action_slot] = {movedSlot, movedItem["id"], activeSide} saveAction() itemBugFixOn() end if hoverSlot == movedSlot then hideClone() end if not hoverItem then if hoverSlot == -1 then hideClone() end end if (movedSlot > -1 and movedItem and not hoverItem and hoverSlot > -1 and hoverSlot ~= movedSlot and inItem and inMove) then if movedItem["duty"] >= 1 then outputChatBox("#FF0000[Error]: #ffffffVocê não pode colocar esse objeto", 255,255,255,true) return end itemBugFixOn() if guiGetText(amountBox) == "" then setItemSlot(movedSlot, hoverSlot) delItemSlot(movedSlot) else if movedItem["count"] >= selectedAmount then if movedItem["count"] - selectedAmount == 0 then delItem(movedSlot) else setItemCount(movedSlot, movedItem["count"] - selectedAmount) end createNewItem(hoverSlot, clonedItem["ID"], clonedItem["id"], clonedItem["value"], selectedAmount, clonedItem["duty"]) end hideClone() end elseif (movedSlot > -1 and movedItem and hoverItem and hoverSlot > -1 and hoverItem["id"] == movedItem["id"] and hoverSlot ~= movedSlot and inItem and inMove and items[movedItem["id"]].stackable) then itemBugFixOn() if isSlotUsedByAction(hoverSlot) then outputChatBox("#FF0000[Error]: #ffffffEsse item já está sendo usado", 255,255,255,true) hideMove() return end if guiGetText(amountBox) == "" then setItemCount(hoverSlot, hoverItem["count"] + movedItem["count"]) delItem(movedSlot) else if hoverItem["id"] == clonedItem["id"] then if clonedItem["count"] >= selectedAmount then setItemCount(movedSlot, movedItem["count"] - selectedAmount) setItemCount(hoverSlot, hoverItem["count"] + selectedAmount) if clonedItem["count"] == 0 then delItem(clonedSlot) end end hideClone() end end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(clickedElement) == "vehicle" and getElementData(clickedElement, "ID") > 0) and not isCursorInAction then if (getElementModel(clickedElement) == 509 or getElementModel(clickedElement) == 481 or getElementModel(clickedElement) == 510) then return end if not (isVehicleLocked(clickedElement)) then if movedItem["duty"] >= 1 or movedItem["id"] == 66 or movedItem["id"] == 70 or movedItem["id"] == 80 or movedItem["id"] == 84 or movedItem["id"] == 86 or movedItem["id"] == 87 or movedItem["id"] == 96 then outputChatBox("#FF0000[Error]: #ffffffVocê não pode mover esse objeto",255,255,255,true) else if isPedInVehicle(localPlayer) then return end if getDistanceFromElement(elementSource, clickedElement) < 3 then itemBugFixOn() me("colocou um(a): "..items[movedItem["id"]].name .." no porta-malas") triggerServerEvent("tradeItem", localPlayer, localPlayer, clickedElement, elementSource, movedItem) end end else outputChatBox("#4169E1[Error]: #ffffffO veículo selecionado está fechado",255,255,255,true) end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(clickedElement) == "player" and getElementData(clickedElement, "ID") > 0) and not isCursorInAction and clickedElement ~= localPlayer then if movedItem["duty"] >= 1 then outputChatBox("#4169E1[Error]: #ffffffVocê não pode mover esse objeto",255,255,255,true) else if getDistanceFromElement(elementSource, clickedElement) < 5 then if movedItem["id"] == 76 then triggerServerEvent("chat.me", localPlayer, localPlayer, "apresenta seu rg") triggerServerEvent("onServerShowDocument", localPlayer, localPlayer, clickedElement, 1) elseif movedItem["id"] == 111 then triggerServerEvent("chat.me", localPlayer, localPlayer, "apresenta sua cnh") triggerServerEvent("onServerShowDocument", localPlayer, localPlayer, clickedElement, 2) else itemBugFixOn() me("enviou para: "..string.gsub(getPlayerName(clickedElement), "-", "").." um(a): "..items[movedItem["id"]].name .."") triggerServerEvent("itemAnim",localPlayer,localPlayer,clickedElement) triggerServerEvent("tradeItem", localPlayer, localPlayer, clickedElement, elementSource, movedItem) triggerServerEvent("getElementItems", localPlayer, clickedElement, clickedElement, 2) end end end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(clickedElement) == "object") and getElementModel(clickedElement) == 1359 and clickedElement ~= localPlayer and not isCursorInAction then if getDistanceFromElement(elementSource, clickedElement) < 5 then triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(clickedElement) == "ped") and getElementData(clickedElement, "weaponPed") and clickedElement ~= localPlayer and not isCursorInAction then if movedItem["id"] == 130 and getElementData(clickedElement, "givedItem1") == false then setElementData(clickedElement, "givedItem1", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 131 and getElementData(clickedElement, "givedItem2") == false then setElementData(clickedElement, "givedItem2", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 132 and getElementData(clickedElement, "givedItem3") == false then setElementData(clickedElement, "givedItem3", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 133 and getElementData(clickedElement, "givedItem4") == false then setElementData(clickedElement, "givedItem4", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 134 and getElementData(clickedElement, "givedItem5") == false then setElementData(clickedElement, "givedItem5", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 135 and getElementData(clickedElement, "givedItem6") == false then setElementData(clickedElement, "givedItem6", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 136 and getElementData(clickedElement, "givedItem7") == false then setElementData(clickedElement, "givedItem7", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 137 and getElementData(clickedElement, "givedItem8") == false then setElementData(clickedElement, "givedItem8", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil elseif movedItem["id"] == 138 and getElementData(clickedElement, "givedItem9") == false then setElementData(clickedElement, "givedItem9", true) triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, movedItem["ID"]) inventoryItems[activeSide][movedSlot] = nil end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(elementSource) == "object") and clickedElement == localPlayer and not isCursorInAction then if getDistanceFromElement(elementSource, clickedElement) < 5 then itemBugFixOn() triggerServerEvent("tradeItem", localPlayer, localPlayer, localPlayer, elementSource, movedItem) end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(elementSource) == "vehicle") and clickedElement == localPlayer and not isCursorInAction then if getDistanceFromElement(elementSource, clickedElement) < 5 then itemBugFixOn() triggerServerEvent("tradeItem", localPlayer, localPlayer, localPlayer, elementSource, movedItem) me("retirou um(a): "..items[movedItem["id"]].name .." do porta-malas") end elseif (movedSlot > -1 and movedItem and not inAction and inMove and not inItem and clickedElement and getElementType(clickedElement) == "object") and getElementData(clickedElement, "szef") and clickedElement ~= localPlayer and not isCursorInAction then if movedItem["duty"] >= 1 then outputChatBox("#FF0000[Error]: #ffffffEsse objeto não pode ser movido",255,255,255,true) else if getDistanceFromElement(elementSource, clickedElement) < 5 then if hasItem(129,getElementData(clickedElement, "ID")) then itemBugFixOn() triggerServerEvent("tradeItem", localPlayer, localPlayer, clickedElement, elementSource, movedItem) else outputChatBox("#FF0000[Error]: #ffffffVocê não tem a chave para esse cofre",255,255,255,true) end end end end hideMove() elseif (pButton == "right" and pState == "down" and showInventory and not inMove and movedSlot < 0) then if hoverSlot >=1 then if hoverItem then if elementSource == localPlayer then itemBugFixOn() useItem(hoverItem,hoverSlot) end end end elseif (pButton == "right" and pState == "down") then if (clickedElement and getElementType(clickedElement) == "vehicle" and tonumber(getElementData(clickedElement, "ID") or 0) > 0) then -- carro itemBugFixOn() if getDistanceFromElement(localPlayer, clickedElement) < 5 then if isPedInVehicle(localPlayer) then return end if (getElementModel(clickedElement) == 509 or getElementModel(clickedElement) == 481 or getElementModel(clickedElement) == 510) then return end if (isVehicleLocked(clickedElement)) then outputChatBox("#4169E1[FVR]: #ffffffO porta-mala do veículo selecionado está fechado",255,255,255,true) else if getElementData(clickedElement,"veh:use") then outputChatBox("#4169E1[FVR]: #ffffffO porta-mala do veículo selecionado está em uso",255,255,255,true) else invMenu = 1 activeSide = "bag" openInventory(clickedElement) triggerServerEvent("doorState", clickedElement, clickedElement, 1) end end end end if (clickedElement and getElementType(clickedElement) == "object" and tonumber(getElementData(clickedElement, "ID") or 0) > 0) and getElementModel(clickedElement) == 2332 then -- cofre if getDistanceFromElement(localPlayer, clickedElement) < 5 then if hasItem(129,getElementData(clickedElement, "ID")) then invMenu = 1 activeSide = "bag" openInventory(clickedElement) else outputChatBox("#4169E1[FVR]: #ffffffVocê não tem a chave para esse cofre",255,255,2555,true) end end end if (clickedElement and (getElementModel(clickedElement) == 509 or getElementModel(clickedElement) == 481 or getElementModel(clickedElement) == 510) and activeBikeLockSlot > 0) then if getElementData(clickedElement, "veh.locked") == 0 then if getElementData(clickedElement, "veh.owner") == getElementData(localPlayer, "ID") then itemBugFixOn() triggerServerEvent("onServerBikeLockStateChange", localPlayer, clickedElement, false) --exports.vz_vehicle:parkVehicle(clickedElement) delItem(activeBikeLockSlot) activeBikeLockSlot = -1 if not hasItem(78,getElementData(clickedElement, "ID")) then giveItem(78, getElementData(clickedElement, "ID"), 1, 0) end else exports.vz_info:showBox("Essa não é a sua moto/bike", "error") end else exports.vz_info:showBox("A moto/bike já está fechada", "error") activeBikeLockSlot = -1 end else activeBikeLockSlot = -1 end if (clickedElement and (getElementModel(clickedElement) == 509 or getElementModel(clickedElement) == 481 or getElementModel(clickedElement) == 510) and activeBikeLockKeySlot > 0) then if getElementData(clickedElement, "veh.locked") == 1 then if hasItem(78,getElementData(clickedElement, "ID")) then itemBugFixOn() triggerServerEvent("onServerBikeLockStateChange", localPlayer, clickedElement, false) giveItem(75, 1, 1, 0) activeBikeLockKeySlot = -1 else exports.vz_info:showBox("Você não tem a chave para bloquear essa moto/bike", "error") end else exports.vz_info:showBox("A moto/bike não está fechada", "error") activeBikeLockKeySlot = -1 end else activeBikeLockKeySlot = -1 end if (clickedElement and getElementType(clickedElement) == "player") and localPlayer ~= clickedElement then if getElementData(clickedElement, "char.cuff") or getElementData(clickedElement, "handsUp") then itemBugFixOn() addEventHandler("onClientRender", getRootElement(), bodySearch) bodySearchTarget = clickedElement bodysearch_progress_text = "Em andamento" bodySearchState = true else exports.vz_info:showBox("O jogador não está algemado ou levantando a mão", "error") end end elseif (pButton == "left" and pState == "down") then if (clickedElement and getElementType(clickedElement) == "player" and activeCuffSlot > 0) then if getElementData(clickedElement, "char.cuff") == false then itemBugFixOn() triggerServerEvent("cuffPlayer", getLocalPlayer(), getLocalPlayer(), clickedElement) activeCuffSlot = -1 else exports.vz_info:showBox("O jogador já está algemado", "error") end else activeCuffSlot = -1 end if (clickedElement and getElementType(clickedElement) == "player" and activeCuffKeySlot > 0) then if getElementData(clickedElement, "char.cuff") then itemBugFixOn() triggerServerEvent("cuffPlayer", getLocalPlayer(), getLocalPlayer(), clickedElement) activeCuffKeySlot = -1 else exports.vz_info:showBox("O jogador não está algemado", "error") end else activeCuffKeySlot = -1 end elseif (pState == "up") then if bodySearchState then removeEventHandler("onClientRender", getRootElement(), bodySearch) bodySearchState = false bodysearch_progress_tick = 0 bodysearch_progress_text = "" end end end ) function bodySearch() bodysearch_progress_tick = bodysearch_progress_tick + 1 bodySearchProgress() if bodysearch_progress_tick >= bodysearch_progress_max then removeEventHandler("onClientRender", getRootElement(), bodySearch) openInventory(bodySearchTarget) bodySearchInventoryOpened = true bodySearchState = false bodysearch_progress_tick = 0 bodysearch_progress_text = "" end end function bodySearchProgress() if bodySearchState then dxDrawRectangle(sX/2 - panelSize[1]/2, sY - panelSize[2]-65, panelSize[1], panelSize[2]-13,tocolor(0, 0, 0,100),false) dxDrawRectangle(sX/2 - panelSize[1]/2, sY - panelSize[2]-65, bodysearch_progress_tick, panelSize[2]-13,tocolor(254, 119, 29,180), true) dxCreateBorder(sX/2 - panelSize[1]/2, sY - panelSize[2]-66, panelSize[1], panelSize[2]-13,tocolor(0,0,0,255),false) dxDrawText(bodysearch_progress_text, sX/2 - panelSize[1]/2 + panelSize[1]/2, sY - panelSize[2]-80 +panelSize[2]/2 , sX/2 - panelSize[1]/2 + panelSize[1]/2, sY - panelSize[2]-80 +panelSize[2]/2, tocolor(255, 255, 255, 204), 0.5, font_progress, "center", "center", false, false, false, true) end end function dxCreateBorder(x,y,w,h,color) dxDrawRectangle(x,y,w+1,1,color) dxDrawRectangle(x,y+1,1,h,color) dxDrawRectangle(x+1,y+h,w,1,color) dxDrawRectangle(x+w,y+1,1,h,color) end function removeDecimal(number) local num = number local num2 = tostring(num) local found = nil for i=1,100000 do if string.sub(num2,i,i) == "." then found = i end end if type(found) == "number" then num2 = string.sub(num2,1,found-1) end num = tonumber(num2) return num end addEventHandler("onClientGUIChanged", getRootElement(),function() if source == amountBox then local currentAmount = guiGetText (source) if string.len(currentAmount) > 0 then local am = tonumber(currentAmount) if am then selectedAmount = removeDecimal(am) else guiSetText(source, currentAmount) end else --guiSetText(source, 0) --selectedAmount = 0 end end end) addCommandHandler("revistar", function(c, target) if tonumber(getElementData(localPlayer, "char.adminlevel") or 0) >= 9 then local targetPlayer, targetPlayerName = exports.vz_main:findPlayerByPartialNick(localPlayer, target) outputChatBox("#4169E1[Use]#FFFFFF /revistar [ID]", 255, 255, 255, true) if (targetPlayer) then openInventory(targetPlayer) end end end) function createNewItem(newSlot, itemDBID, itemID, itemValue, itemCount, itemDuty) if (newSlot > -1 and itemDBID and itemID and itemValue and itemCount and itemDuty) then triggerServerEvent("createNewItem", localPlayer, localPlayer, elementSource, itemID, newSlot,itemCount) end end function setItemCount(itemSlot, newCount) if (itemSlot > -1 and newCount > -1) then if activeSide == "craft" then newMenu = "bag" else newMenu = activeSide end triggerServerEvent("updateItemCount", localPlayer, localPlayer, elementSource, itemSlot, newCount, inventoryItems[newMenu][itemSlot]["ID"]) inventoryItems[newMenu][itemSlot]["count"] = newCount if (elementSource == localPlayer) then playerItems[newMenu][itemSlot]["count"] = newCount end end end function setItemValue(itemSlot, newValue) if (itemSlot > -1 and newValue > -1) then if activeSide == "craft" then newMenu = "bag" else newMenu = activeSide end triggerServerEvent("updateItemValue", localPlayer, localPlayer, elementSource, itemSlot, newValue, inventoryItems[newMenu][itemSlot]["ID"]) inventoryItems[newMenu][itemSlot]["value"] = newValue if (elementSource == localPlayer) then playerItems[newMenu][itemSlot]["value"] = newValue end end end function delItemSlot(itemSlot) if (itemSlot > -1) then inventoryItems[activeSide][itemSlot] = nil saveAction() if (elementSource == localPlayer) then playerItems[activeSide][itemSlot] = nil end end end function getAllItemWeight() local bagWeight = 0 local keyWeight = 0 local cardsWeight = 0 for i = 1, row * column do if (playerItems["bag"][i]) then bagWeight = bagWeight + (getItemWeight(playerItems["bag"][i]["id"]) * playerItems["bag"][i]["count"]) end end for i = 1, row * column do if (playerItems["key"][i]) then keyWeight = keyWeight + (getItemWeight(playerItems["key"][i]["id"]) * playerItems["key"][i]["count"]) end end for i = 1, row * column do if (playerItems["cards"][i]) then cardsWeight = cardsWeight + (getItemWeight(playerItems["cards"][i]["id"]) * playerItems["cards"][i]["count"]) end end return bagWeight + cardsWeight + keyWeight end function delItem(itemSlot) if (itemSlot > -1) then if activeSide == "craft" then newMenu = "bag" else newMenu = activeSide end triggerServerEvent("deleteItem", localPlayer, localPlayer, elementSource, inventoryItems[newMenu][itemSlot]["ID"]) saveAction() inventoryItems[newMenu][itemSlot] = nil if (elementSource == localPlayer) then playerItems[newMenu][itemSlot] = nil end end end function takeStatus(itemID, statusMinus) if (itemID > -1) then local haveItem, _, _, itemSlot, itemType = hasItem(itemID) if haveItem then if tonumber(inventoryItems["bag"][itemSlot]["health"]) - tonumber(statusMinus) <= 0 then triggerServerEvent("deleteItem", localPlayer, localPlayer, localPlayer, inventoryItems[itemType][itemSlot]["ID"]) if itemID == 141 then giveItem(142, 1, 1, 0) end inventoryItems[itemType][itemSlot] = nil if (elementSource == localPlayer) then playerItems[itemType][itemSlot] = nil end return else triggerServerEvent("takeStatus", localPlayer, localPlayer, localPlayer, inventoryItems["bag"][itemSlot]["ID"], tonumber(inventoryItems["bag"][itemSlot]["health"]) - statusMinus) inventoryItems["bag"][itemSlot]["health"] = tonumber(inventoryItems["bag"][itemSlot]["health"]) - statusMinus return end end end end function takeItem(itemID) if (itemID > -1) then local haveItem, _, _, itemSlot, itemType = hasItem(itemID) if haveItem then triggerServerEvent("deleteItem", localPlayer, localPlayer, localPlayer, inventoryItems[itemType][itemSlot]["ID"]) inventoryItems[itemType][itemSlot] = nil if (elementSource == localPlayer) then playerItems[itemType][itemSlot] = nil end end end end addEvent("takeItemServer",true) addEventHandler("takeItemServer",getRootElement(),takeItem) function setItemSlot(oldSlot, newSlot) if (oldSlot > -1 and newSlot > -1) then inventoryItems[activeSide][newSlot] = inventoryItems[activeSide][oldSlot] if (elementSource == localPlayer) then playerItems[activeSide][newSlot] = inventoryItems[activeSide][oldSlot] end triggerServerEvent("updateItemSlot", localPlayer, localPlayer, elementSource, newSlot, inventoryItems[activeSide][oldSlot]) end end function hideMove() startTick = -1 movedItem = nil movedSlot = -1 inMove = false end function hideClone() clonedItem = nil clonedSlot = -1 inClone = false end function hasActionItem(actionItem) hasTheItem = false if (actionItem) then if (playerItems["bag"] and playerItems["key"] and playerItems["cards"]) then for i = 1, row * column do if (playerItems["bag"][i]) then if (actionItem["ID"] == playerItems["bag"][i]["ID"]) then hasTheItem = true end end end for i = 1, row * column do if (playerItems["key"][i]) then if (actionItem["ID"] == playerItems["key"][i]["ID"]) then hasTheItem = true end end end for i = 1, row * column do if (playerItems["cards"][i]) then if (actionItem["ID"] == playerItems["cards"][i]["ID"]) then hasTheItem = true end end end if hasTheItem then return true else return false end return false end return false end return false end function giveItem(itemID, itemValue, itemCount, itemDuty) triggerServerEvent("giveItem", localPlayer, localPlayer, itemID, itemValue, itemCount, itemDuty) end function hasItem(itemID, itemValue) if (not itemValue) then if (playerItems["bag"] and playerItems["key"] and playerItems["cards"]) then for i = 1, row * column do if (playerItems["bag"][i]) then if (itemID == playerItems["bag"][i]["id"]) then return true, itemID, itemValue, i, "bag", countItemsInInventory(itemID),playerItems["bag"][i]["count"] end end end for i = 1, row * column do if (playerItems["key"][i]) then if (itemID == playerItems["key"][i]["id"]) then return true, itemID, itemValue, i, "key" end end end for i = 1, row * column do if (playerItems["cards"][i]) then if (itemID == playerItems["cards"][i]["id"]) then return true, itemID, itemValue, i, "cards" end end end return false end return false else if (playerItems["bag"] and playerItems["key"] and playerItems["cards"]) then for i = 1, row * column do if (playerItems["bag"][i]) then if (itemID == playerItems["bag"][i]["id"] and tonumber(itemValue) == tonumber(playerItems["bag"][i]["value"])) then return true, itemID, tonumber(itemValue), i end end end for i = 1, row * column do if (playerItems["key"][i]) then if (itemID == playerItems["key"][i]["id"] and tonumber(itemValue) == tonumber(playerItems["key"][i]["value"])) then return true, itemID, tonumber(itemValue), i end end end for i = 1, row * column do if (playerItems["cards"][i]) then if (itemID == playerItems["cards"][i]["id"] and tonumber(itemValue) == tonumber(playerItems["cards"][i]["value"])) then return true, itemID, tonumber(itemValue), i end end end return false end return false end return false end function countItemsInInventory(itemID, count) if (playerItems["bag"]) then local count = 0 for i = 1, row * column do if (playerItems["bag"][i]) then if (itemID == playerItems["bag"][i]["id"]) then count = count + 1 end end end return count end return false end function hasItemOnSlot(slot) if (playerItems["bag"][slot] and tonumber(playerItems["bag"][slot]["id"] or -1) > -1) then return true end return false end function isSlotUsedByAction(slot) if getElementType(elementSource) ~= "player" then return false end for k, v in ipairs(action_array) do if v[1] == slot and v[3] == activeSide then return true end end return false end function loadActionItems() if not fileExists("action.json") then local createFile = fileCreate("action.json") if createFile then for k=1, actionSlots do fileWrite(createFile, toJSON({-1, -1, "bag"}) .. " | ") end fileClose(createFile) end else setTimer(function() local hFile = fileOpen("action.json", true) if hFile then local buffer while not fileIsEOF(hFile) do buffer = fileRead(hFile, 500) local splitted_result = split(buffer, " | ") for k, v in ipairs(splitted_result) do local data = fromJSON(string.gsub(v, " ", "")) if data then action_array[k] = {tonumber(data[1]), tonumber(data[2]), tostring(data[3])} end end end fileClose(hFile) end end, 200, 1) end end function split(s, delimiter) result = {} for match in (s..delimiter):gmatch("(.-)"..delimiter) do table.insert(result, match) end return result end function saveAction() if fileExists("action.json") then fileDelete("action.json") local createFile = fileCreate("action.json") if createFile then for k, v in ipairs(action_array) do fileWrite(createFile, toJSON({v[1] , v[2], v[3]}) .. " | ") end fileClose(createFile) end end end function isInBox(xS,yS,wS,hS) if(isCursorShowing()) then local cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX*sX, cursorY*sY if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then return true else return false end end end function getDistanceFromElement(from, to) if not from or not to then return end local x, y, z = getElementPosition(from) local x1, y1, z1 = getElementPosition(to) return getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(),function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) local activeItemID = getElementData(localPlayer,"active:itemID") local activeitemSlot = getElementData(localPlayer,"active:itemSlot") if(activeItemID>-1) and (activeitemSlot>-1) then local witem = tonumber(getElementData(localPlayer,"active:itemID")) local wslot = tonumber(getElementData(localPlayer,"active:itemSlot")) if (items[witem].isWeapon) then if(tonumber(playerItems["bag"][wslot]["count"] or -1)<=1)then activeWeaponSlot = -1 activeAmmoSlot = - 1 delItem(wslot) setElementData(localPlayer,"active:itemID",-1) setElementData(localPlayer,"active:itemSlot",-1) else setItemCount(wslot,playerItems["bag"][wslot]["count"]-1) end end end end) addEvent("activeWeapon",true) addEventHandler("activeWeapon",getRootElement(),function(slot) activeWeaponSlot = slot end) addEventHandler("onClientResourceStart", resourceRoot, function() receiveOnStart() end) addEventHandler("onClientResourceStop", resourceRoot, function() saveConfigFile() end) local config = {} function createConfigFile() local RootNode = xmlCreateFile("config.xml","action") local Newcode = xmlCreateChild(RootNode, "data") xmlNodeSetAttribute(Newcode, "pos1", sX/2-(300/2)) xmlNodeSetAttribute(Newcode, "pos2", sY/2-(80/2)+375) xmlSaveFile(RootNode) end function saveConfigFile() local RootNode = xmlCreateFile("config.xml","action") local Newcode = xmlCreateChild(RootNode, "data") xmlNodeSetAttribute(Newcode, "pos1", math.round(actPos[1])) xmlNodeSetAttribute(Newcode, "pos2", math.round(actPos[2])) xmlSaveFile(RootNode) end function receiveOnStart() local file = xmlLoadFile ( "config.xml" ) local data = xmlFindChild ( file, "data", 0 ) if file then if data then local wtf = xmlNodeGetAttributes ( data ) actPos = {tonumber(wtf.pos1), tonumber(wtf.pos2)} end else createConfigFile() receiveOnStart() end end function move() if getKeyState("mouse1") and isCursorShowing() then local mx, my = getCursorPosition() local mx, my = mx*sX, my*sY actPos[1] = mx-m[1] actPos[2] = my-m[2] else removeEventHandler("onClientRender", root, move) moving = false end end function moveAction(b, s) if getElementData(localPlayer, "showHUD") == 1 then if b == "left" and s == "down" then if inbox(actPos[1], actPos[2], 300, 80) then local mx, my = getCursorPosition() local mx, my = mx*sX, my*sY m = {mx-actPos[1], my-actPos[2]} moving = true addEventHandler("onClientRender", root, move) end elseif b == "right" and s == "down" then if inbox(actPos[1], actPos[2], 300, 80) then if not moving then actPos = {sX/2-(300/2), sY-50} end end end end end addEventHandler("onClientClick", root, moveAction) function resetAction() if not moving then actPos = {sX/2-(300/2), sY-50} end end addCommandHandler("resetaction", resetAction) function inbox(sx, sy, bx, by) if not isCursorShowing() then return false end local mx, my = getCursorPosition() mx, my = mx*sX, my*sY bx = sx+bx by = sy+by return sx <= mx and bx >= mx and sy <= my and by >= my end function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function itemBugFixOn() toggleAllControls(false) showCursor(false) itemBugFixOnOff = true triggerServerEvent("itemBugFixServer", localPlayer, localPlayer) end addEvent("itemBugFixClient",true) addEventHandler("itemBugFixClient", getRootElement(), function(player) toggleAllControls(true) showCursor(true) itemBugFixOnOff = false end) addEventHandler("onClientPlayerNetworkStatus", getRootElement(), function(status) if tonumber(status) == 0 then toggleAllControls(false) showCursor(false) guiSetInputEnabled(true) triggerServerEvent("sendBugMessageToAdmins", localPlayer, localPlayer) else toggleAllControls(true) guiSetInputEnabled(false) end end )
-
Amigo, fiz as alterações e o resource liga bem, sem erro, só que, assim que eu morro o marker é criado, porém as armas não são dropadas, continuando no inventário, e quando passo sobre o marker diz "você pegou uma Ak47 com munições" porém também não giva nada pro player, alguma ideia ? Código está assim local table_items = { } addEventHandler("onPlayerWasted", root, function ( ) local armas = { } for i=1,12 do if getPedWeapon (source, i) > 0 then local w = getWeaponNameFromID (getPedWeapon ( source, i ) ) local m = getPedTotalAmmo ( source, i ) table.insert ( armas, toJSON( {w, m} ) ) end end if table.concat(armas) ~= "" then local x,y,z = getElementPosition(source) local marker = createMarker( x, y, z -1, "cylinder", 3, 255, 0, 0, 100 ) table_items[marker] = armas end end) addEventHandler("onPlayerMarkerHit", root, function ( hit, d ) if table_items[hit] then for i, v in pairs(table_items[hit]) do local items = fromJSON ( v ) giveWeapon( source, items[1], items[2] ) outputChatBox("Você pegou "..items[1].." com "..items[2].." Munições", source, 255, 255, 255, true) end table.remove(table_items[hit]) destroyElement(hit) end end)
-
Oi amigo, Bom, meu sistema de inventário está em SQLITE e não MySql, neste caso, quais linhas eu deveria alterar ? me desculpe, posso estar sendo meio estupido, más é que sou bem leigo nisto, começei a ler a wiki a algumas semanas, aprendi alguma coisa, más estóu realmente tendo dor de cabeça com isso.. Agradecido de qualquer forma
-
Pode me dar uma ajuda ? como poderia introduzir este sistema ?
-
Bom, como na internet não se acha um sistema de inventário "BOM" em sqlite e funcional, eu peguei um layout de 1 e o adaptei com a loja de outro, fiz alguns arranjos, e voa-la, funcionando PERFEITAMENTE sem nenhum erro no console ou debugscript 3, o Problema é, as armas não estão dropando quando o jogador morre. Quando ele morre, da respawn no hospital com todas as armas, alguém pode me ajudar a resolver este problema ? no caso de eu estar utilizando 1 inventário, eu teria de criar 1 script pra ler e retirar os itens de determinado jogador de dentro do inventário ? estou completamente perdido, nem sei por onde começar, alguém pra me dar uma luz ? Tentei adicionar a função básica ao server.lua : addEventHandler( "onPlayerWasted", getRootElement( ), function() setTimer( spawnPlayer, 2000, 1, source, 0, 0, 3 ) end ) Porém não funciona, eu teria que adicionar algo pra chamar o inventário ? vamos supor que a resource do inventário se chama "inventario". Deveria adicionar alguma call em alguma linha pra chamar a resource ? alguém pode me ajudar ?
-
Bom, fiz umas gambearras em alguns scripts inacabados de inventário e acabou funcionando bem, porém assim que é efetuada a compra de algo como arma, comida, bebida, o item vai normalmente para o inventário, porém não desconta o dinheiro do personagem, e não apresenta nenhum erro no debugscritp, o que me fez vir aqui, visto que não sei o motivo do bug, poderiam me ajudar ? o Script está abaixo Server local shopPed = {} addEventHandler("onResourceStart", root, function() connection = dbConnect("sqlite", "database.db") dbExec(connection, "CREATE TABLE IF NOT EXISTS shops (id INTEGER PRIMARY KEY AUTOINCREMENT, type INTEGER, pos TEXT, skin INTEGER, name TEXT)") loadShop() end) ------------------------------ -- // Shop betöltése ------------------------------ function loadShop() local query = dbQuery( connection, "SELECT * FROM shops") local result, numrows = dbPoll(query, -1) if (result and numrows > 0) then for index, shopTable in pairs(result) do local position = fromJSON(shopTable["pos"]) shopPed[shopTable["id"]] = createPed(shopTable["skin"], position[1], position[2], position[3]) if isElement(shopPed[shopTable["id"]]) then setPedRotation(shopPed[shopTable["id"]], position[6] or 0) setElementDimension(shopPed[shopTable["id"]], position[4]) setElementInterior(shopPed[shopTable["id"]], position[5]) setElementFrozen(shopPed[shopTable["id"]], true) setElementData(shopPed[shopTable["id"]], "shop >> owner", shopTable["owner"]) setElementData(shopPed[shopTable["id"]], "shop >> type", shopTable["type"]) setElementData(shopPed[shopTable["id"]], "shop >> npc", true) setElementData(shopPed[shopTable["id"]], "shop >> id", shopTable["id"]) setElementData(shopPed[shopTable["id"]], "ped >> death", true) setElementData(shopPed[shopTable["id"]], "name:tags", "PED") setElementData(shopPed[shopTable["id"]], "Ped:Name",shopTable["name"]) end end end end ------------------------------100 -- // Shop törlése ------------------------------ addCommandHandler("delshop", function(playerSource, cmd) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Console")) then local x, y, _ = getElementPosition(playerSource) local shopShape = createColCircle ( x, y, 3 ) local shopNumber = 0 for _,v in ipairs(getElementsWithinColShape ( shopShape, "ped" ) ) do local ShopID = getElementData(v,"shop >> id") or 0 shopNumber = shopNumber + 1 destroyElement(shopShape) if ShopID >= 1 then destroyElement(v) end dbPoll ( dbQuery( connection, "DELETE FROM shops WHERE id = '?'", ShopID), 0 ) outputChatBox("#7cc576[SKY~Itens] #ffffffLoja excluída com sucesso. ID: #F7CA18"..ShopID, playerSource, 255, 255, 255, true) return end if(shopNumber == 0) then destroyElement(shopShape) outputChatBox("#D24D57[SKY~Itens] #ffffffNenhuma loja perto de você.", playerSource, 255, 255, 255, true) end end end) ------------------------------ -- // Shop létrehozása ------------------------------ function createShop(element, cmd, skin, type, name) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(element)), aclGetGroup("Console")) then if not (skin) or not type or not name and tonumber(type) < 0 and tonumber(type) < #shopItemList+1 then outputChatBox("#7cc576[use]:#ffffff /".. cmd .." [Olhar NPC] [tipo] [NPC nome]", element,255,255,255,true) outputChatBox("#ffffffTípus: 1: Food Individual 2: Loja de bebidas 3: Loja geral 4: eletrônica 5: Loja de passatempo 6: Burger Shot 7: Cluck'n'Bell 8: Pizza 9: Suprimentos de mineração 10: Suprimentos para lenhadores 11: Vajdaság 12: Loja da máfia 13: pescaria 14: loja Arma", element,255,255,255,true) outputChatBox("15: Lojas de tabaco 16: Mudas ilegais 17: artigos de papelaria 18: Armazem de peixe 19: farmácia 20: pet Store 21: Mascaras", element,255,255,255,true) return end local x, y, z = getElementPosition(element) local dim = getElementDimension(element) local int = getElementInterior(element) local rot = getPedRotation(element) local position = toJSON( {x, y, z, dim, int, rot}) local insertQuery = dbQuery( connection, "INSERT INTO shops (type, pos, skin, name) VALUES(?, ?, ?, ?)", tonumber(type), position, skin, name) local insertQueryData, _, insertID = dbPoll ( insertQuery, -1 ) if (insertQueryData) then shopPed[insertID] = createPed(skin,x,y,z) setPedRotation(shopPed[insertID], rot) setElementDimension(shopPed[insertID], dim) setElementInterior(shopPed[insertID], int) setElementFrozen(shopPed[insertID], true) setElementData(shopPed[insertID], "shop >> type", type) setElementData(shopPed[insertID], "ped >> death", true) setElementData(shopPed[insertID], "shop >> npc", true) setElementData(shopPed[insertID], "shop >> id", insertID) setElementData(shopPed[insertID], "name:tags", "NPC") setElementData(shopPed[insertID], "Ped:Name", name) end end end addCommandHandler('addshop', createShop) addCommandHandler('createshop', createShop) ------------------------------ -- // Item adás ------------------------------ function buyItem(player, item, value, count, amount, duty) money = getPlayerMoney(player) or 0 if money >= amount then if exports.cbr_inventario:giveItem(player, item, value, count, amount, true) then takePlayerMoney(player, amount) outputChatBox("#ffffffVocê conseguiu um #32B3FF".. exports.cbr_inventario:getItemName(item).." #ffffffobjeto.",player,255,0,0,true) end else outputChatBox("#ffffffVocê não possui (#32B3FF".. amount .." #ffffff)$.",player,255,255,255,true) end end addEvent("btcMTA->#buyItem", true) addEventHandler("btcMTA->#buyItem", getRootElement(), buyItem) function kit_vida(source) setElementHealth(source, 100) end addEvent("DS:kit_vida", true) addEventHandler("DS:kit_vida", root, kit_vida) function kit_reparo(source) end addEvent("DS:kit_reparo", true) addEventHandler("DS:kit_reparo", root, kit_reparo) Client local monitorSize = {guiGetScreenSize()} -- // Lekérdezi a monitor méreteit local panelData = {550, 510} -- // Panel szélessége és magassága local panelX, panelY = monitorSize[1]/2-panelData[1]/2, monitorSize[2]/2-panelData[2]/2 -- // X, Y Pozició local font = dxCreateFont("files/Calibri.ttf", 10) -- // Font local showShop = false -- // A panel felvan-e rajzolva local currentShop = 0 -- // Jelenlegi shop local scroll = 0 -- // Görgetés local count = 1 -- // Darabszám local maxDraw = 8 -- // Maximum kirajzolás local createdGuis = {} -- // A guik táblázata local shopElement = nil --// Shop Element ------------------------------ -- // Klikkelés ------------------------------ addEventHandler('onClientClick', root, function (button, state, _, _, _, _, _, element) if button == 'right' and state == 'down' and element and not showShop then if getElementData(element, 'shop >> npc') or false then local x, y, z = getElementPosition(localPlayer) local elementX, elementY, elementZ = getElementPosition(element) if getDistanceBetweenPoints3D(x, y, z, elementX, elementY, elementZ) <= 5 then if tonumber(getElementData(element,"shop:type") or 1) == 14 and not exports['cbr_inventario']:hasItem(localPlayer, 112) then outputChatBox('#D24D57[FVR] #ffffffVocê não tem uma licença de arma!', 255, 255, 255, true) return end getShopDatas(element) else outputChatBox('#D24D57[SKY~Itens] #ffffffVocê não pode falar com o vendedor sobre essa bagunça!', 255, 255, 255, true) end end elseif button == 'left' and state == 'down' and showShop then local elem = 0 for index, value in ipairs(shopItemList[currentShop].itemList) do if (index > scroll and elem < maxDraw) then elem = elem + 1 if isMouseInPosition (panelX+panelData[1]-155, panelY-25+elem*57+56/2-20/2, 77, 20) then if guiEditSetCaretIndex(createdGuis[elem], string.len(guiGetText(createdGuis[elem]))) then guiBringToFront(createdGuis[elem]) end elseif isMouseInPosition (panelX+panelData[1]-45, panelY-25+elem*57+56/2-32/2, 32, 32) then if isElement(createdGuis[elem]) then count = guiGetText(createdGuis[elem]) if tonumber(count) then if count == '' or count == ' ' then count = 1 end else count = 1 guiSetText(createdGuis[elem], '') end else count = 1 end setTimer(function(value, count) triggerServerEvent('btcMTA->#buyItem', localPlayer, localPlayer, value[2], value[3], math.floor(count), value[5]* math.floor(count)) end, 100, 1, value, count) end end end end end) ------------------------------ -- // destoy and draw funkciók ------------------------------ function getShopDatas(element) showShop = not showShop if showShop then currentShop = tonumber(getElementData(element, 'shop >> type')) createGui('create') shopElement = element addEventHandler('onClientRender', root, createShopPanel, true, 'low-5') bindKey('backspace', 'down', desroyPanel) else createGui('destroy') removeEventHandler('onClientRender', root, createShopPanel) unbindKey('backspace', 'down', desroyPanel) end end function desroyPanel () removeEventHandler('onClientRender', root, createShopPanel) showShop = false createGui('destroy') count = 1 scroll = 0 currentShop = 0 unbindKey('backspace', 'down', desroyPanel) end ------------------------------ -- // Edit létrehozása és törlése ------------------------------ function createGui(type) if tostring(type) == "destroy" then for index, value in ipairs(shopItemList[currentShop].itemList) do if isElement(createdGuis[index]) then destroyElement(createdGuis[index]) end end else for index, value in ipairs(shopItemList[currentShop].itemList) do createdGuis[index] = guiCreateEdit(-1000, -1000, 0, 0, "", false) guiSetText(createdGuis[index], value[4]) guiEditSetMaxLength(createdGuis[index], 4) end end end ------------------------------ -- // felrajzolás ------------------------------ function createShopPanel() local x, y, z = getElementPosition(localPlayer) local elementX, elementY, elementZ = getElementPosition(shopElement) if (getDistanceBetweenPoints3D(x, y, z, elementX, elementY, elementZ) > 5 ) then desroyPanel() return end dxDrawRectangle(panelX, panelY, panelData[1], panelData[2], tocolor(0, 0, 0, 150)) -- // background dxDrawRectangle(panelX, panelY, panelData[1], 25, tocolor(0, 0, 0, 200)) dxDrawText("Para sair, pressione a tecla #D24D57'backspace'", panelX+panelData[1]/2, (panelY+panelData[1]-65)+25/2, panelX+panelData[1]/2, (panelY+panelData[1]-65)+25/2, tocolor(255, 255, 255, 255), 1, font, 'center', 'center', false, false, false, true) dxDrawText('#7cc576SKY#FFFFFFMTA - #7cc576'..shopItemList[currentShop].name, panelX+panelData[1]/2, panelY+25/2, panelX+panelData[1]/2, panelY+25/2, tocolor(255, 255, 255, 255), 1, font, 'center', 'center', false, false, false, true) local elem = 0 for index, value in ipairs(shopItemList[currentShop].itemList) do if (index > scroll and elem < maxDraw) then elem = elem + 1 dxDrawRectangle(panelX+5, panelY-25+elem*57, panelData[1]-10, 56, tocolor(0, 0, 0, 150)) dxDrawRectangle(panelX+10, panelY-17+elem*57, 40, 40, tocolor(255, 255, 255, 60)) dxDrawImage(panelX+10+2, panelY-17+elem*57+2, 36, 36, getItemImage(value[2])) if isElement(createdGuis[elem]) then count = guiGetText(createdGuis[elem]) if tonumber(count) then if count == '' or count == ' ' then count = 1 end else count = 1 guiSetText(createdGuis[elem], '') end else count = 1 end dxDrawText('Nome: #7cc576'.. value[1] .. '\n#ffffffPreço: #7cc576R$: '.. formatMoney(value[5]*math.floor(count))..'', panelX+10+2+43, panelY-25+elem*57+2, 36, 36, tocolor(255, 255, 255, 255), 1, font, 'left', 'top', false, false, false, true) dxDrawText('Quantidade: #7cc576'.. math.floor(count), panelX+panelData[1]-155, panelY-25+elem*57+56/2, 36, panelY-25+elem*57+56/2, tocolor(255, 255, 255, 255), 1, font, 'left', 'center', false, false, false, true) if isMouseInPosition (panelX+panelData[1]-45, panelY-25+elem*57+56/2-32/2, 32, 32) then dxDrawImage(panelX+panelData[1]-45, panelY-25+elem*57+56/2-32/2, 32, 32, 'files/shopIcon.png', 0, 0, 0, tocolor(124, 197, 118, 255)) else dxDrawImage(panelX+panelData[1]-45, panelY-25+elem*57+56/2-32/2, 32, 32, 'files/shopIcon.png', 0, 0, 0, tocolor(255, 255, 255, 255)) end end end if #shopItemList[currentShop].itemList > maxDraw then dxDrawRectangle(panelX+panelData[1]+5, panelY+25, 10, panelData[2]-25, tocolor(0, 0, 0, 150)) -- // scrole backfround dxDrawRectangle(panelX+panelData[1]+5+1, panelY+25+1+((panelData[2]-25)/(#shopItemList[currentShop].itemList-maxDraw+1))*scroll, 8, (panelData[2]-25)/(#shopItemList[currentShop].itemList-maxDraw+1)-2, tocolor(124,197,118, 255)) -- // Scros line end end ------------------------------ -- // Görgetés ------------------------------ bindKey("mouse_wheel_down", "down", function() if showShop then if scroll < #shopItemList[currentShop].itemList - maxDraw then scroll = scroll + 1 end end end ) bindKey("mouse_wheel_up", "down", function() if showShop then if scroll > 0 then scroll = scroll - 1 end end end ) ------------------------------ -- // Egyéb ------------------------------ function formatMoney(amount) local formatted = tonumber(amount) if formatted then while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2') if (k==0) then break end end return formatted else return amount end end function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing ( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function getItemImage(item) return fileExists(":btc_items/files/items/"..item..".png") and ":btc_items/files/items/"..item..".png" or ":btc_items/files/items/0.png" end addEventHandler("onClientPedDamage", getRootElement(), function () if (getElementData(source, "ped >> death")) then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill", getRootElement(), function(targetPlayer) if (getElementType(targetPlayer) == 'ped' and getElementData(targetPlayer, "ped >> death")) then cancelEvent() end end)