Jump to content

[Ajuda] Combustivel - WARNING


Recommended Posts

Posted
Quote

[2019-04-19 13:35:48] WARNING: [KIT]Combustivel\AirNew_s.lua:34: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean]
[2019-04-19 13:35:48] WARNING: [KIT]Combustivel\AirNew_s.lua:34: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean]  [DUP x19]
[2019-04-19 13:39:58] WARNING: [KIT]Combustivel\AirNew_s.lua:34: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean]
[2019-04-19 13:40:04] WARNING: [KIT]Combustivel\AirNew_s.lua:34: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean]  [DUP x19]

 

Quote

--[[



 ################################################
 #                                              #
 #              Script Criado Por               #
 #           FACEBOOK.COM/AIRNEWSCR             #
 #                                              #
 #                                              #
 ################################################   



--]]

-------------------------------------------------

local VeiculosGasolina = { 581, 462, 521, 463, 522, 461, 448, 468, 586, 602, 496, 401, 518, 527, 589, 419, 587, 533, 526, 474, 545, 517, 410, 600, 436, 439, 549, 491, 445, 604, 507, 585, 466, 492, 546, 551, 516, 467, 426, 547, 405, 580, 409, 550, 566, 540, 421, 529, 485, 431, 438, 437, 574, 420, 525, 408, 552, 416, 433, 427, 490, 528, 407, 544, 523, 470, 596, 598, 599, 597, 428, 499, 609, 498, 524, 532, 578, 486, 406, 573, 455, 588, 423, 414, 443, 531, 456, 459, 422, 482, 605, 530, 418, 572, 582, 413, 440, 543, 483, 478, 554, 579, 400, 404, 489, 505, 479, 442, 458, 536, 575, 534, 567, 535, 576, 412, 402, 542, 603, 475, 429, 541, 415, 480, 562, 565, 434, 494, 502, 503, 411, 559, 561, 560, 506, 451, 558, 555, 477, 568, 424, 504, 457, 483, 508, 571, 500, 444, 556, 557, 471, 495, 539 }
local VeiculosAVGAS = { 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 497, 563, 447, 469 }
local VeiculosDiesel = { 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 432, 601, 403, 515, 514, 538, 570, 537, 449 }
local VeiculosSemCombustivel = { 509, 481, 510, 441, 464, 594, 501, 465, 564, 606, 607, 610, 584, 611, 608, 435, 450, 591, 590, 569 }

AVGAS_STATUS = "Desativado"

function VerificarSemCombustivel ()
    for i,v in ipairs ( getElementsByType ( "player" ) ) do
	    if getElementData ( v, "AirNew_Logado" ) == true then
	        if isPedInVehicle ( v ) then
			    local Piloto = getPedOccupiedVehicleSeat ( v )
				if Piloto == 0 then
			        for _, Veiculos in ipairs ( VeiculosSemCombustivel ) do			
		                local Veiculo = getPedOccupiedVehicle ( v )
				        local ID = getElementModel ( Veiculo )
				        if ID == Veiculos then
							setElementData ( v, "AirNew_Combustivel", "Nenhum" )
		                end
				    end
		        end
	        end
        end
    end
end
setTimer ( VerificarSemCombustivel, 1000, 0 )

function ProcessarCombustivelGasolina ()
    for i,v in ipairs ( getElementsByType ( "player" ) ) do
	    if getElementData ( v, "AirNew_Logado" ) == true then
	        if isPedInVehicle ( v ) then
			    local Piloto = getPedOccupiedVehicleSeat ( v )
				if Piloto == 0 then
			        for _, Veiculos in ipairs ( VeiculosGasolina ) do			
		                local Veiculo = getPedOccupiedVehicle ( v )
				        local ID = getElementModel ( Veiculo )
				        if ID == Veiculos then
	                        local Gasolina = getElementData ( v, "Combustivel_Gasolina" ) or 0
		                    if getVehicleEngineState ( Veiculo ) and Gasolina > 0 then
				                VelocidadeX, VelocidadeY, VelocidadeZ = getElementVelocity ( Veiculo )
				                VelocidadeAtual = ( VelocidadeX ^ 2 + VelocidadeY ^ 2 + VelocidadeZ ^ 2 ) ^ ( 0.5 )
				                KMH = math.floor ( VelocidadeAtual * 180 )
				                if KMH == 0 then
				    	            GasolinaPorSegundo = 0
				                elseif KMH > 0 then
				    	            GasolinaPorSegundo = 0.1
                                end
			                    Gasolina = Gasolina - GasolinaPorSegundo				
			                end
			                if Gasolina <= 0.50 then
			                    Gasolina = 0
			                    setVehicleEngineState ( Veiculo, false )
			                end
			                setElementData ( v, "Combustivel_Gasolina", Gasolina )
							setElementData ( v, "AirNew_Combustivel", "Gasolina" )
		                end
				    end
		        end
	        end
        end
    end
end
setTimer ( ProcessarCombustivelGasolina, 3000, 0 )

function ProcessarCombustivelAVGAS ()
    for i,v in ipairs ( getElementsByType ( "player" ) ) do
	    if getElementData ( v, "AirNew_Logado" ) == true then
	        if isPedInVehicle ( v ) then
			    local Piloto = getPedOccupiedVehicleSeat ( v )
				if Piloto == 0 then
			        for _, Veiculos in ipairs ( VeiculosAVGAS ) do			
		                local Veiculo = getPedOccupiedVehicle ( v )
				        local ID = getElementModel ( Veiculo )
				        if ID == Veiculos then
	                        local AVGAS = getElementData ( v, "Combustivel_AVGAS" ) or 0
							
							if AVGAS_STATUS == "Desativado" then
							    setElementData ( v, "Combustivel_AVGAS", 100 )
							end
							
		                    if getVehicleEngineState ( Veiculo ) and AVGAS > 0 then
				                VelocidadeX, VelocidadeY, VelocidadeZ = getElementVelocity ( Veiculo )
				                VelocidadeAtual = ( VelocidadeX ^ 2 + VelocidadeY ^ 2 + VelocidadeZ ^ 2 ) ^ ( 0.5 )
				                KMH = math.floor ( VelocidadeAtual * 180 )
				                if KMH == 0 then
				    	            AVGASPorSegundo = 0
				                elseif KMH > 0 then
				    	            AVGASPorSegundo = 0.1
                                end
			                    AVGAS = AVGAS - AVGASPorSegundo				
			                end
			                if AVGAS <= 0.50 then
			                    AVGAS = 0
			                    setVehicleEngineState ( Veiculo, false )
			                end
			                setElementData ( v, "Combustivel_AVGAS", AVGAS )
							setElementData ( v, "AirNew_Combustivel", "AVGAS" )
		                end
				    end
		        end
	        end
        end
    end
end
setTimer ( ProcessarCombustivelAVGAS, 3000, 0 )

function ProcessarCombustivelDiesel ()
    for i,v in ipairs ( getElementsByType ( "player" ) ) do
	    if getElementData ( v, "AirNew_Logado" ) == true then
	        if isPedInVehicle ( v ) then
			    local Piloto = getPedOccupiedVehicleSeat ( v )
				if Piloto == 0 then
			        for _, Veiculos in ipairs ( VeiculosDiesel ) do			
		                local Veiculo = getPedOccupiedVehicle ( v )
				        local ID = getElementModel ( Veiculo )
				        if ID == Veiculos then
	                        local Diesel = getElementData ( v, "Combustivel_Diesel" ) or 0
		                    if getVehicleEngineState ( Veiculo ) and Diesel > 0 then
				                VelocidadeX, VelocidadeY, VelocidadeZ = getElementVelocity ( Veiculo )
				                VelocidadeAtual = ( VelocidadeX ^ 2 + VelocidadeY ^ 2 + VelocidadeZ ^ 2 ) ^ ( 0.5 )
				                KMH = math.floor ( VelocidadeAtual * 180 )
				                if KMH == 0 then
				    	            DieselPorSegundo = 0
				                elseif KMH > 0 then
				    	            DieselPorSegundo = 0.1
                                end
			                    Diesel = Diesel - DieselPorSegundo
			                end
			                if Diesel <= 0.50 then
			                    Diesel = 0
			                    setVehicleEngineState ( Veiculo, false )
			                end
			                setElementData ( v, "Combustivel_Diesel", Diesel )
							setElementData ( v, "AirNew_Combustivel", "Diesel" )
		                end
				    end
		        end
	        end
        end
    end
end
setTimer ( ProcessarCombustivelDiesel, 3000, 0 )

--- Salvamento / Carregamento ---

addEventHandler ( "onPlayerLogin", root,
  function ( _, acc )
	setTimer ( CarregarCombustiveis, 50, 1, acc )
  end
)

function CarregarCombustiveis ( conta )
	if not isGuestAccount ( conta ) then
		if conta then	
			local source = getAccountPlayer ( conta )	
			local Gasolina = getAccountData ( conta, "Combustivel_Gasolina" ) or 100
			setElementData ( source, "Combustivel_Gasolina", Gasolina )
			local AVGAS = getAccountData ( conta, "Combustivel_AVGAS" ) or 100
			setElementData ( source, "Combustivel_AVGAS", AVGAS )
			local Diesel = getAccountData ( conta, "Combustivel_Diesel" ) or 100
			setElementData ( source, "Combustivel_Diesel", Diesel )
			setElementData ( source, "AirNew_Logado", true )
		end
	end	
end

function IniciarCombustivelResource ( res )
	if res == getThisResource ( ) then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				CarregarCombustiveis ( acc )
			end
		end
	end
end
addEventHandler ( "onResourceStart", getRootElement ( ), IniciarCombustivelResource )

function SalvarCombustiveis ( conta )
	if conta then
		local source = getAccountPlayer ( conta )
		local Gasolina = getElementData ( source, "Combustivel_Gasolina" ) or 100
		setAccountData ( conta, "Combustivel_Gasolina", Gasolina )
		local AVGAS = getElementData ( source, "Combustivel_AVGAS" ) or 100
		setAccountData ( conta, "Combustivel_AVGAS", AVGAS )
		local Diesel = getElementData ( source, "Combustivel_Diesel" ) or 100
		setAccountData ( conta, "Combustivel_Diesel", Diesel )
	end
end

function DesligarCombustivelResource ( res )
    if res == getThisResource ( ) then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				SalvarCombustiveis ( acc )
			end
		end
	end
end 
addEventHandler ( "onResourceStop", getRootElement(), DesligarCombustivelResource )

function SairServidor ( quitType )
	local acc = getPlayerAccount(source)
	if not isGuestAccount ( acc ) then
		if acc then
			SalvarCombustiveis ( acc )
		end
	end
end
addEventHandler ( "onPlayerQuit", getRootElement(), SairServidor )

--- Trigger / Client ---

function AbastecerGD (v)
    local Combustivel = getElementData ( source, "AirNew_Combustivel" )
	local Dinheiro = getPlayerMoney ( source )
	if Combustivel == "Gasolina" then
		if Dinheiro < 4 then return end
		local Gasolina = getElementData ( source, "Combustivel_Gasolina" )
		setElementData ( source, "Combustivel_Gasolina", Gasolina + 1 )
		takePlayerMoney ( source, 4 )
	elseif Combustivel == "Diesel" then
		if Dinheiro < 6 then return end
		local Diesel = getElementData ( source, "Combustivel_Diesel" )
		setElementData ( source, "Combustivel_Diesel", Diesel + 1 )
		takePlayerMoney ( source, 6 )
	end
end
addEvent ( "AirNew_AbastecerGasolinaOuDiesel", true )
addEventHandler ( "AirNew_AbastecerGasolinaOuDiesel", root, AbastecerGD )

function AbastecerAVG (v)
    local Combustivel = getElementData ( source, "AirNew_Combustivel" )
	local Dinheiro = getPlayerMoney ( source )
	if Combustivel == "AVGAS" then
		if Dinheiro < 10 then return end
		local AVGAS = getElementData ( source, "Combustivel_AVGAS" )
		setElementData ( source, "Combustivel_AVGAS", AVGAS + 1 )
		takePlayerMoney ( source, 10 )
	end
end
addEvent ( "AirNew_AbastecerAVGAS", true )
addEventHandler ( "AirNew_AbastecerAVGAS", root, AbastecerAVG )

 

 

[BR] • VIDA DE JOVEM • ~ ROLEPLAY ~ [ CORPS, VOICE, GANGS, VIPS ]

VENHA CONHECER NOSSO SERVIDOR ~ R O L E P L A Y ~ SERVIDOR NOVO
BEM CONFIGURADO COMPACTADO LEVE COM UM BOM PING Obs: Depende da Sua NET!
Staff Sempre Online Vagas Abertas Para todos tipo de trabalhos CORPS, GANGS,
SAMU, MECANICOS e Muitos Outros Trabalhos Vale a pena Visita passe seus 10Minutos
Aqui e venha conhecer a verdadeira diversão de um R O L E P L A Y

ID: mtasa://54.39.244.81:22853
DISCORD: discord.gg/jEyd4J3 
PAGINA: https://www.facebook.com/VidaDeJovemBR/
WhatsApp: 71 987647252

Posted

Alguém me ajuda por favor?

[BR] • VIDA DE JOVEM • ~ ROLEPLAY ~ [ CORPS, VOICE, GANGS, VIPS ]

VENHA CONHECER NOSSO SERVIDOR ~ R O L E P L A Y ~ SERVIDOR NOVO
BEM CONFIGURADO COMPACTADO LEVE COM UM BOM PING Obs: Depende da Sua NET!
Staff Sempre Online Vagas Abertas Para todos tipo de trabalhos CORPS, GANGS,
SAMU, MECANICOS e Muitos Outros Trabalhos Vale a pena Visita passe seus 10Minutos
Aqui e venha conhecer a verdadeira diversão de um R O L E P L A Y

ID: mtasa://54.39.244.81:22853
DISCORD: discord.gg/jEyd4J3 
PAGINA: https://www.facebook.com/VidaDeJovemBR/
WhatsApp: 71 987647252

Posted

Tente substituindo esta função:


function VerificarSemCombustivel ()
	for i,v in ipairs ( getElementsByType ( "player" ) ) do
		if getElementData ( v, "AirNew_Logado" ) == true then
			local Veiculo = getPedOccupiedVehicle ( v )
			if Veiculo and getPedOccupiedVehicleSeat ( v ) == 0 then
				for _, Veiculos in ipairs ( VeiculosSemCombustivel ) do
					local ID = getElementModel ( Veiculo )
					if ID == Veiculos then
						setElementData ( v, "AirNew_Combustivel", "Nenhum" )
					end
				end
			end
		end
	end
end
setTimer ( VerificarSemCombustivel, 1000, 0 )

Você vai precisar fazer o mesmo com as outras se também acontecer esse erro.

Please do not PM me with scripting related question nor support, use the forums instead.

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