Queria uma ajuda, preciso colocar um script para verificar se tem o item (maconha3) no inventario antes de fazer a trocar por dinheiro sujo
-----------------------------------------------------------------------------------------------------------------------------------------
assaltada = {}
markers = {}
tempoBind = {}
-----------------------------------------------------------------------------------------------------------------------------------------
function onHit(playerSource)
if not isPedInVehicle(playerSource) then
if getPedWeapon(playerSource) == 0 or getPedWeapon(playerSource) == 0 or getPedWeapon(playerSource) == 0 then
for i, v in pairs(markers) do
if v == source then
if not assaltada[i] then
if not isTimer(tempoBind[playerSource]) then
exports._infobox:addNotification(playerSource, "Pressione 'K' para vender as drogas.", "info")
bindKey(playerSource, "k", "down", startAssalto)
tempoBind[playerSource] = setTimer(unbindKey, 10000, 1, playerSource, "k", "down", startAssalto)
end
end
end
end
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------------
function startAssalto(playerSource)
if not isPedInVehicle(playerSource) then
if getPedWeapon(playerSource) == 0 or getPedWeapon(playerSource) == 0 or getPedWeapon(playerSource) == 0 then
for i, v in pairs(markers) do
if isElementWithinMarker(playerSource, v) then
local count = 0
for _, players in pairs(getElementsByType("player")) do
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(players)), aclGetGroup(ACL_Policial)) then
count = count + 1
end
end
if count >= minPolices then
setElementAlpha(v, 0)
if isTimer(tempoBind[playerSource]) then
killTimer(tempoBind[playerSource])
tempoBind[playerSource] = nil
end
unbindKey(playerSource, "k", "down", startAssalto)
assaltada[i] = true
local x, y, z = positions[i][1], positions[i][2], positions[i][3]
setElementPosition(playerSource, x, y, z)
setElementRotation(playerSource, 0, 0, positions[i][4])
setElementFrozen(playerSource, true)
toggleAllControls(playerSource, false, true, false)
setPedAnimation(playerSource, "INT_SHOP", "shop_cashier", positions[i][6], true, false, false, false, 0, false)
triggerClientEvent(playerSource, "progressBar", playerSource, positions[i][6])
for _, players in pairs(getElementsByType("player")) do
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(players)), aclGetGroup(ACL_Policial)) then
exports._infobox:addNotification(players, "[COPOM]: Suspeita de venda de drogas na cracolandia "..positions[i][5], "warning")
end
end
setTimer(function()
setElementFrozen(playerSource, false)
toggleAllControls(playerSource, true)
local money = math.random(positions[i][7], positions[i][8])
exports["[MOD]Inventario"]:GiveAndTakeAndGetItem("take", playerSource, "maconha3", 1)
exports["[MOD]Inventario"]:GiveAndTakeAndGetItem("give", playerSource, "dinheirosujo", money)
exports._infobox:addNotification(playerSource, "Você recebeu "..money.." Dinheiro Sujo", "money")
local wanted = getPlayerWantedLevel(playerSource)
if wanted <= 3 then
setPlayerWantedLevel(playerSource, wanted + 3)
else
setPlayerWantedLevel(playerSource, 6)
end
local name = getPlayerName(playerSource)
local id = getElementData(playerSource, "ID") or "N/A"
exports["[Scripts]Logs"]:CreateLog("[LOJINHA]\nAssaltante: "..name.." ["..id.."]\nMercadinho: "..positions[i][5].."\nValor roubado: $"..money)
end, positions[i][6], 1)
setTimer(function()
setElementAlpha(v, 35)
assaltada[i] = false
end, respawnTime, 1)
else
exports._infobox:addNotification(playerSource, "É preciso ter pelo menos "..minPolices.." policiais na cidade para realizar o assaltos", "error")
end
end
end
else
exports._infobox:addNotification(playerSource, "Você precisa estar com maconha na mochila para vender", "error")
end
else
exports._infobox:addNotification(playerSource, "Você não vender dentro de um veículo", "error")
end
end
-----------------------------------------------------------------------------------------------------------------------------------------
for i, v in pairs(positions) do
markers[i] = createMarker(positions[i][1], positions[i][2], positions[i][3] -1, "cylinder", 1.2, 255, 255, 255, 0)
addEventHandler("onMarkerHit", markers[i], onHit)
end
-----------------------------------------------------------------------------------------------------------------------------------------