Well, I've a new idea.
view my code :
It don't work.
Client Side :
addEvent("removeStreamableLocos", true )
function removeStreamableLocos( theElement )
setElementStreamable( getElementByID( "loco1" ), false )
setElementStreamable( getElementByID( "wagon1" ), false )
setElementStreamable( getElementByID( "pilot1" ), false )
setElementStreamable( getElementByID( "pilot2" ), false )
end
addEventHandler("removeStreamableLocos", getRootElement(), removeStreamableLocos )
addEvent("getTrain", true )
function getTrain ()
local x, y, z = getElementPosition(getElementByID( "loco1" ))
local a, b, c = getElementPosition(getElementByID( "wagon1" ))
local g, h, i = getElementPosition(getElementByID( "pilot2" ))
local d, e, f = getElementPosition(getElementByID( "pilot1" ))
triggerServerEvent("setTrainPosition",getRootElement(),x,y,z,a,b,c,g,h,i,d,e,f)
end
addEventHandler("getTrain", getRootElement(), getTrain)
and Server Side :
function makeTrain(source)
loco = createVehicle(537,1725.9,-1954,16)
locool = createVehicle(538,1840,-1954,16)
setElementID( loco, "loco1" )
setElementID( locool, "wagon1" )
setTrainDerailable(loco, false)
setTrainDerailable(locool, false)
local pilot1 = createPed(241,1693.38,-1959,15.6)
local pilot2 = createPed(241,1711,-1959,15.6)
setElementID( pilot1, "pilot1" )
setElementID( pilot2, "pilot2" )
warpPedIntoVehicle (pilot1, loco)
warpPedIntoVehicle (pilot2, locool)
setTimer(setTrain, 5000, 0)
createBlipAttachedTo(loco, 42)
setTrainSpeed(loco, 0)
setTrainSpeed(locool,0.203)
setTimer(assemblage, 10000, 1)
outputChatBox("Train is here", source, 255, 255, 0)
removeStreamable( loco )
setTimer(depart, 20000, 1)
nextgare = 0
end
addCommandHandler("traintest", makeTrain)
function assemblage ()
nextgare = nextgare+1
setTrainSpeed(loco, 0)
setTrainSpeed(locool, 0)
setTimer(depart, 20000,1)
end
function depart ()
nextgare = nextgare+1
setTrainSpeed(loco, 1)
setTrainSpeed(locool, 1)
if nextgare == 0 then
setTimer(assemblage, 88000, 1)
else
if nextgare == 2 then
setTimer(assemblage, 23000, 1)
else
if nextgare == 4 then
setTimer(assemblage, 93000, 1)
else
if nextgare == 6 then
setTimer(assemblage,102000, 1)
else
if nextgare == 8 then
setTimer(assemblage, 50000, 1)
else
if nextgare == 10 then
nextgare = 0
end
end
end
end
end
end
end
function speed ()
setTrainSpeed(loco, 1)
setTrainSpeed(locool, 1)
end
function removeStreamable( theElement )
triggerClientEvent( "removeStreamableLocos", getRootElement() )
end
addEvent("setTrainPosition",true)
function setTrain (x,y,z,a,b,c,g,h,i,d,e,f)
triggerClientEvent( "getTrain", getRootElement())
setElementPosition(loco, x, y, z, false)
setElementPosition(locool, a, b, c, false)
setElementPosition(pilot1, d, e, f, false)
setElementPosition(pilot2, g, h, i, false)
end
addEventHandler("setTrainPosition",getRootElement(),setTrain)