Jump to content

Race trailer-towing-type vehicle


acp___(PL)

Recommended Posts

no errors/warnings, but doesn't work

in console sea only line: 8, 36

local g_rot = getRootElement()
local trailerList = {}
local vehicleList = {}
local timerBlowList = {}
addEventHandler ( "onPlayerSpawn", g_rot,
function ()
	vehicleList[source] = getPedOccupiedVehicle(source)
outputConsole("addEventHandler ( onPlayerSpawn, g_rot,: " ..getPlayerName(source))
if vehicleList[source] and getElementModel(vehicleList[source]) == 515 then
local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicleList[source])
local vehicleRX, vehicleRY, vehicleRZ = getElementRotation(vehicleList[source])
local trailerX = vehicleX + 5
local trailerY = vehicleY + 5
local trailerZ = vehicleZ + 1
		trailerList[source] = createVehicle(435, trailerX, trailerY, trailerZ, vehicleRX, vehicleRY, vehicleRZ)
attachTrailerToVehicle(vehicleList[source], trailerList[source])
outputConsole("if vehicleList[source] and getElementModel(vehicleList[source]) == 515 then:" ..getPlayerName(source))
end
end
)
function blowTheVehicle(the_vehicle,the_player)
blowVehicle(the_vehicle, true)
end
function checkIsVehicleTowedByVehicle()
for i, k_player in ipairs(getElementsByType("Player")) do
local k_vehicle = getPedOccupiedVehicle(k_player)
if k_vehicle and not getVehicleTowedByVehicle(k_vehicle) then
		timerBlowList[k_player] = setTimer(blowTheVehicle, 5000, 1, k_vehicle, k_player)
outputConsole("if k_vehicle and not getVehicleTowedByVehicle(k_vehicle) then:" ..getPlayerName(k_player).. " petla:" ..i)
end
outputConsole("for i, k_player in ipairs(getElementsByType(Player)) do:" ..getPlayerName(k_player).. " petla:" ..i)
end
end
function timerIsVehicleTowedByVehicle()
setTimer(checkIsVehicleTowedByVehicle, 1000, 0)
outputConsole("function timerIsVehicleTowedByVehicle()")
end
addEvent('onMapStarting')
addEventHandler('onMapStarting', g_rot , timerIsVehicleTowedByVehicle)

<map edf:definitions="race">
   <spawnpoint id="spawnpoint (NRG-500) (1)" vehicle="515" interior="0" posX="2179.8828125" posY="-1926.6389160156" posZ="16.185919761658" rotX="0" rotY="0" rotZ="141" />
   <checkpoint id="checkpoint (1)" type="ring" color="#00F9" size="20" interior="0" posX="1754.7119140625" posY="-2656.4423828125" posZ="266" rotX="0" rotY="0" rotZ="0" />
</map>

Link to comment

I added a timer

local g_rot = getRootElement()
local trailerList = {}
local vehicleList = {}
function atachTrailerToPlayerVehicle(the_source)
vehicleList[the_source] = getPedOccupiedVehicle(the_source)
outputConsole("function atachTrailerToPlayerVehicle(the_source): " ..getPlayerName(the_source))
if vehicleList[the_source] and getElementModel(vehicleList[the_source]) == 515 then
	local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicleList[the_source])
	local vehicleRX, vehicleRY, vehicleRZ = getVehicleRotation(vehicleList[the_source])
	local trailerX = vehicleX + 5
	local trailerY = vehicleY + 5
	local trailerZ = vehicleZ + 1
	trailerList[the_source] = createVehicle(435, trailerX, trailerY, trailerZ, vehicleRX, vehicleRY, vehicleRZ)
	attachTrailerToVehicle(vehicleList[the_source], trailerList[the_source])
	outputConsole("if vehicleList[the_source] and getElementModel(vehicleList[the_source]) == 515 then:" ..getPlayerName(the_source))
end
end
addEventHandler ( "onPlayerSpawn", g_rot,
function ()
	setTimer(atachTrailerToPlayerVehicle, 500, 10, source)
	outputConsole("addEventHandler ( onPlayerSpawn, g_rot,: " ..getPlayerName(source))
end
)

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