Sziasztok. Valaki el tudja magyarázni az
Addevent
AddEventHandler
és a TriggerServerEvent működését?
Próbáltam átszerkeszteni a zeró mta-t de nem tudok triggerelni.
function toggleLock(source, key, keystate)
local veh = getPedOccupiedVehicle(source)
local inVehicle = getElementData(source, \"realinvehicle\")
if (veh) and (inVehicle==1) then
triggerEvent(\"lockUnlockInsideVehicle\", source, veh)
elseif not veh then
if getElementDimension(source) >= 19000 then
local vehicle = exports.pool:getElement(\"vehicle\", getElementDimension(source) - 20000)
if vehicle and exports[\'vehicle-interiors\']:isNearExit(source, vehicle) then
local model = getElementModel(vehicle)
local owner = getElementData(vehicle, \"owner\")
local dbid = getElementData(vehicle, \"dbid\")
if (owner ~= -2) then
if ( getElementData(vehicle, \"Impounded\") or 0 ) == 0 then
local locked = isVehicleLocked(vehicle)
if (locked) then
setVehicleLocked(vehicle, false)
exports.global:sendLocalMeAction(source, \"kinyitja a járművet.\")
else
setVehicleLocked(vehicle, true)
exports.global:sendLocalMeAction(source, \"bezárja a járművet.\")
end
else
outputChatBox(\"(( Lefoglalt kocsit nem tudsz bezárni. ))\", source, 255, 195, 14)
end
else
outputChatBox(\"(( Civil kocsit nem tudsz bezárni. ))\", source, 255, 195, 14)
end
return
end
end
if not triggerEvent(\"lockUnlockHouse\", source) then
local x, y, z = getElementPosition(source)
local nearbyVehicles = exports.global:getNearbyElements(source, \"vehicle\", 30)
if #nearbyVehicles < 1 then return end
local found = nil
local shortest = 31
for i, veh in ipairs(nearbyVehicles) do
local dbid = tonumber(getElementData(veh, \"dbid\"))
local distanceToVehicle = getDistanceBetweenPoints3D(x, y, z, getElementPosition(veh))
if shortest > distanceToVehicle and ( getElementData(source, \"adminduty\") == 1 or exports.global:hasItem(source, 3, dbid) or (getElementData(source, \"faction\") > 0 and getElementData(source, \"faction\") == getElementData(veh, \"faction\")) ) then
shortest = distanceToVehicle
found = veh
end
end
if found then
triggerEvent(\"lockUnlockOutsideVehicle\", source, found)
end
end
end
end
addEvent(\"amikornyitzar\", false)
addEventHandler(\"amikornyitzar\", getRootElement(), toggleLock)
function hang()
triggerServerEvent(\"amikornyitzar\", getRootElement(), source, key, keystate)
outputChatBox(\"lefutott\")
end