Добрый вечер! Хотел сделать скрипт, чтобы при нажатии на кнопку включалась/выключалась защита, не дающая пассажирам сидеть в вашей машине. Но скрипт не работает, помогите, пожалуйста.
antipas = {}
function switchAntiPas(thePlayer)
local veh = getPedOccupiedVehicle (thePlayer)
if veh then
if not antipas[veh] then
antipas[veh] = true
outputChatBox("#FFFF00Анти-Пассажир #00FF00Включен#FFFF00!",thePlayer,255,255,255,true)
else
antipas[veh] = false
outputChatBox("#FFFF00Анти-Пассажир #00FF00Выключен#FFFF00!",thePlayer,255,255,255,true)
end
end
end
function testPas ( thePlayer )
local Vehicle = getPedOccupiedVehicle ( thePlayer )
local controller = getVehicleController ( Vehicle )
if Vehicle and controller then
for id, player in ipairs(getElementsByType("player")) do
local Vehicle2 = getPedOccupiedVehicle ( player )
local controller2 = getVehicleController ( Vehicle2 )
if Vehicle2 and not controller2 then
if Vehicle == Vehicle2 then
if antipas[Vehicle] then
removePedFromVehicle ( player )
outputChatBox("#FF0000Этот игрок запрещает садится кому-либо пассажиром в свою машину!",player,255,255,255,true)
end
end
end
end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(),
function(thePlayer)
bindKey(thePlayer, "u", "down", switchAntiPas)
setTimer ( testPas, 1000, 1, thePlayer )
end)
addEventHandler ( "onVehicleExit", getRootElement(),
function(thePlayer)
unbindKey(thePlayer, "u", "down", switchAntiPas)
end)