Jump to content

[HELP] fixar a função para todos


Recommended Posts

opa! é o seguinte... meu script está com um unpack para pegar as posições dos carros e criar com a função createvehicle...

então, quero estabelecer uma função que funcione para todos os veiculos criados no script. No entanto, ela só está funcionando no último veículo do meu array...

me ajudem, porfavor <3

vejam o code:

local vehicles = { 
{477, 2205.8999,  -1176.9, 25.4, 0, 0, 270 },--posição
{402, 2206.3,  -1172.9,  25.7, 0, 0, 268 }, 
{494, 2206.3999, -1169.1, 25.7, 0, 0, 270 }, 
{502, 2206.3, -1164.9,25.7, 0, 0, 270 },
{503, 2206.5,1160.6, 25.7, 0, 0, 270 }, 
{522, 2206, -1156.9 ,25.4, 0, 0, 272 }, 
{587,2206.3,-1152.9,25.5, 0, 0, 272 },
{521, 2227.7,-1177.2,25.4, 0, 0, 86 }, 
{400, 2227.8999,-1173.6,25.9 , 0, 0, 90}, 
{603, 2228.3999,-1170.1, 25.7  , 0, 0, 90 }, 
{429,2228,-1166.3,25., 0, 0, 88 }, 
{566, 2227.8999,-1162.9,25.7, 0, 0, 90 }, -- a função só funciona nesse
}

vehicle = createVehicle( unpack(vehicles))

setVehicleDamageProof(vehicle, true) -- blidao
setVehicleColor ( vehicle, 255, 255, 255, 0, 0, 0 )  -- cor do carro
setVehicleHeadLightColor ( vehicle, 255, 0, 0 )-- luzes com cor
setVehicleDoorState ( vehicle, 1,1) -- portas

--
    function  lockPrivate( player,seat, jacked )    
        if ( source == vehicle ) and (seat == 0) then
            local account = getPlayerAccount( player )
            local accountName = ( account and getAccountName ( account ) or "" )
            if not( accountName == "") then -- accountName == "Nome_da_Conta" or accountName == "accountName == "Nome_da_Conta"
                cancelEvent()
                outputChatBox("  #ffff00* #ff0000Esse veículo está a venda! #00ff00[Execute: F1/Compras]#ff0000[Consulte um ADM]", player, 255, 0, 0, true)
            else
                outputChatBox("", player, 0, 255, 0, true)
            end
        end
    end
addEventHandler ( "onVehicleStartEnter", getRootElement(), lockPrivate )

430x73_FFFFFF_FF9900_000000_000000.png

Edited by MarcosMix99
Link to comment

Você está utilizando a função unpack() de maneira incorreta.

local pos = { 
{477, 2205.8999,  -1176.9, 25.4, 0, 0, 270 },--posição
{402, 2206.3,  -1172.9,  25.7, 0, 0, 268 }, 
{494, 2206.3999, -1169.1, 25.7, 0, 0, 270 }, 
{502, 2206.3, -1164.9,25.7, 0, 0, 270 },
{503, 2206.5,1160.6, 25.7, 0, 0, 270 }, 
{522, 2206, -1156.9 ,25.4, 0, 0, 272 }, 
{587,2206.3,-1152.9,25.5, 0, 0, 272 },
{521, 2227.7,-1177.2,25.4, 0, 0, 86 }, 
{400, 2227.8999,-1173.6,25.9 , 0, 0, 90}, 
{603, 2228.3999,-1170.1, 25.7  , 0, 0, 90 }, 
{429,2228,-1166.3,25., 0, 0, 88 }, 
{566, 2227.8999,-1162.9,25.7, 0, 0, 90 }, -- a função só funciona nesse
}
local vehicles = {}

for index,veiculo in pairs(pos) do
	table.insert(vehicles,createVehicle(unpack(veiculo)))
	setVehicleDamageProof(vehicles[index], true) -- blidao
	setVehicleColor ( vehicles[index], 255, 255, 255, 0, 0, 0 )  -- cor do carro
	setVehicleHeadLightColor ( vehicles[index], 255, 0, 0 )-- luzes com cor
	setVehicleDoorState ( vehicles[index], 1,1) -- portas
end

--
    function  lockPrivate( player,seat, jacked )    
		for _,veiculo in pairs(vehicles) do
			if (source == veiculo) and (seat == 0) then
				local account = getPlayerAccount( player )
				local accountName = ( account and getAccountName ( account ) or "" )
				if not( accountName == "") then -- accountName == "Nome_da_Conta" or accountName == "accountName == "Nome_da_Conta"
					cancelEvent()
					outputChatBox("  #ffff00* #ff0000Esse veículo está a venda! #00ff00[Execute: F1/Compras]#ff0000[Consulte um ADM]", player, 255, 0, 0, true)
				else
					outputChatBox("", player, 0, 255, 0, true)
				end
				break
			end
		end
    end
addEventHandler ( "onVehicleStartEnter", getRootElement(), lockPrivate )

 

Link to comment
13 hours ago, MaligNos said:

Você está utilizando a função unpack() de maneira incorreta.


local pos = { 
{477, 2205.8999,  -1176.9, 25.4, 0, 0, 270 },--posição
{402, 2206.3,  -1172.9,  25.7, 0, 0, 268 }, 
{494, 2206.3999, -1169.1, 25.7, 0, 0, 270 }, 
{502, 2206.3, -1164.9,25.7, 0, 0, 270 },
{503, 2206.5,1160.6, 25.7, 0, 0, 270 }, 
{522, 2206, -1156.9 ,25.4, 0, 0, 272 }, 
{587,2206.3,-1152.9,25.5, 0, 0, 272 },
{521, 2227.7,-1177.2,25.4, 0, 0, 86 }, 
{400, 2227.8999,-1173.6,25.9 , 0, 0, 90}, 
{603, 2228.3999,-1170.1, 25.7  , 0, 0, 90 }, 
{429,2228,-1166.3,25., 0, 0, 88 }, 
{566, 2227.8999,-1162.9,25.7, 0, 0, 90 }, -- a função só funciona nesse
}
local vehicles = {}

for index,veiculo in pairs(pos) do
	table.insert(vehicles,createVehicle(unpack(veiculo)))
	setVehicleDamageProof(vehicles[index], true) -- blidao
	setVehicleColor ( vehicles[index], 255, 255, 255, 0, 0, 0 )  -- cor do carro
	setVehicleHeadLightColor ( vehicles[index], 255, 0, 0 )-- luzes com cor
	setVehicleDoorState ( vehicles[index], 1,1) -- portas
end

--
    function  lockPrivate( player,seat, jacked )    
		for _,veiculo in pairs(vehicles) do
			if (source == veiculo) and (seat == 0) then
				local account = getPlayerAccount( player )
				local accountName = ( account and getAccountName ( account ) or "" )
				if not( accountName == "") then -- accountName == "Nome_da_Conta" or accountName == "accountName == "Nome_da_Conta"
					cancelEvent()
					outputChatBox("  #ffff00* #ff0000Esse veículo está a venda! #00ff00[Execute: F1/Compras]#ff0000[Consulte um ADM]", player, 255, 0, 0, true)
				else
					outputChatBox("", player, 0, 255, 0, true)
				end
				break
			end
		end
    end
addEventHandler ( "onVehicleStartEnter", getRootElement(), lockPrivate )

 

Muito obrigado!

430x73_FFFFF_F9900_00000_00000.png

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