Спасибо огромное, это работает! Начинаю по-тихоньку понимать логику =)
Вот готовый код (объект 2000 это из ресурса ParticlеObjects, а именно CamFlash)
Получились очень забавные стробоскопы ))
on = 0
function checkModel( theVehicle )
Car = getElementModel ( theVehicle )
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), checkModel )
function onEnterVehicle ( theVehicle, seat, jacked )
if ( getElementModel ( theVehicle ) == 598 ) then
bindKey ( source, "F12", "down", createStrab )
end
end
local Object, timer1, x, y, z;
function createStrab ( player )
if Car == 598 then
if on == 0 then
on = 1
local veh = getPedOccupiedVehicle (player)
x, y, z = getElementPosition (veh)
timer1 = setTimer(function()
Object1 = createObject ( 2000, x, y, z );
setElementCollisionsEnabled ( Object1, false );
attachElements ( Object1, veh, 0.555, 2.4, 0.08);
setTimer(function() destroyElement(Object1) end, 100, 1)
end, 500, 0);
timer2 = setTimer(function()
Object2 = createObject ( 2000, x, y, z );
setElementCollisionsEnabled ( Object2, false );
attachElements ( Object2, veh, 0.555, 2.4, 0.08);
setTimer(function() destroyElement(Object2) end, 100, 1)
end, 600, 0);
timer3 = setTimer(function()
Object3 = createObject ( 2000, x, y, z );
setElementCollisionsEnabled ( Object3, false );
attachElements ( Object3, veh, -0.555, 2.4, 0.08);
setTimer(function() destroyElement(Object3) end, 100, 1)
end, 550, 0);
timer4 = setTimer(function()
Object4 = createObject ( 2000, x, y, z );
setElementCollisionsEnabled ( Object4, false );
attachElements ( Object4, veh, -0.555, 2.4, 0.08);
setTimer(function() destroyElement(Object4) end, 100, 1)
end, 650, 0);
else
on=0
--- destroyElement(Object1);
--- destroyElement(Object2);
--- destroyElement(Object3);
--- destroyElement(Object4);
killTimer(timer1);
killTimer(timer2);
killTimer(timer3);
killTimer(timer4);
end
end
end
function destroyStrab()
---destroyElement(Object1);
---destroyElement(Object2);
---destroyElement(Object3);
---destroyElement(Object4);
killTimer(timer1);
killTimer(timer2);
killTimer(timer3);
killTimer(timer4);
end
addEventHandler ( "onVehicleExplode", getRootElement(), destroyStrab )
function onExitVehicle ( theVehicle, seat, jacked )
if ( getElementModel ( theVehicle ) == 598 ) then
unbindKey ( source, "F12", "down", createStrab )
if on == 1 then
---destroyElement(Object1);
---destroyElement(Object2);
---destroyElement(Object3);
---destroyElement(Object4);
killTimer(timer1);
killTimer(timer2);
killTimer(timer3);
killTimer(timer4);
end
end
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), onExitVehicle )
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle )
Теперь у меня появилась новая забавная идея и снова у меня пара вопросов )
вот код
on = 0
function checkModel( theVehicle )
Car = getElementModel ( theVehicle )
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), checkModel )
function onEnterVehicle ( theVehicle, seat, jacked )
if ( getElementModel ( theVehicle ) == 598 ) then
bindKey ( source, "u", "down", createObject )
end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle )
function createOblect ( player )
if Car == 598 then
if on == 0 then
on = 1
local veh = getPedOccupiedVehicle (player)
x, y, z = getElementPosition (veh)
object = createObject ( 1973, x, y, z )
attachElements ( object, veh, 0, 0, 3)
else
on=0
destroyElement(object)
end
end
end
function onBind ()
bindKey ( source, "n", "down", move )
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onBind )
function offBind ()
unbindKey ( source, "n", "down", move )
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), offBind )
function move()
moveObject (object, 1000, 1, 0, 3)
end
Идея скрипта в том чтобы в момент когда персонаж садится в авто, к авто аттачился объект, и этот объект двигался относительно авто по кнопке. У меня не получилось сделать чтобы объект аттачился сразу при посадке (без кнопки), и вместо того чтобы двигаться он исчезает.. Очень прошу направьте на путь истинный )