Jump to content

Faltando script para verificar no inventario item


ZDN

Recommended Posts

Queria saber se tem como alguem me ajudar, tenho um arquivo que ta faltando um script para verificar se tem o item (maconha3) no inventario para efetuar a venda no ilegal.

-----------------------------------------------------------------------------------------------------------------------------------------
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
-----------------------------------------------------------------------------------------------------------------------------------------

 

Edited by Lord Henry
Removido código duplicado. Código convertido de C# para Lua.
Link to comment
On 11/02/2022 at 13:25, ZDN said:

Queria saber se tem como alguem me ajudar, tenho um arquivo que ta faltando um script para verificar se tem o item (maconha3) no inventario para efetuar a venda no ilegal.

-----------------------------------------------------------------------------------------------------------------------------------------
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
-----------------------------------------------------------------------------------------------------------------------------------------

 

Qual o exports do seu inventário?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...