function onResourceStart ( name, root )
vehBar = getElementByID ( "vehbar" )
origX, origY, origZ = getElementPosition ( vehBar )
end
function closeVehicleBar ( playerSource, commandName )
local preX, preY, preZ = getObjectRotation( vehBar )
if preY == 0.0 then
local rotY = 90.0
moveObject ( vehBar, 4000, origX, origY, origZ, 0.0, rotY, 0.0 )
end
end
function openVehicleBar ( playerSource, commandName )
local preX, preY, preZ = getObjectRotation( vehBar )
if preY == 90.0 then
local rotY = -90.0
moveObject ( vehBar, 4000, origX, origY, origZ, 0.0, rotY, 0.0 )
end
end
addEventHandler ( "onResourceStart", getRootElement(), onResourceStart )
addCommandHandler ( "closebar", closeVehicleBar )
addCommandHandler ( "openbar", openVehicleBar )
Can anyone tell me why I have to write the commands two times everytime I want to use it to make it work?
Explanation: I go ingame, write /openbar, ntohing happens, I write /openbar again, it works. I then want to close it, I use the command /closebar, ntohing happens, I do it again there it goes down. I have tested it lots of times it always works on the second use of the commands, and yes, I even tried waiting a few seconds after that it closed/opened all the way, still the same result.