السلام عليكم ورحمة الله وبركاته
بقالى كام يوم بحاول أشوف شروحات
واقرأ فى مواضيع المنتدى
وبستفيد جداً وبتعلم شكراً ليكم
لاكن عندى استفسار صغير
ازاى اضيف للكود دة امر
ان السيارة الى تتحجز تتنقل لاماكن محددة
اتمنى تكونوا فهمتو قصدي
function UnlockVehicle(element, matchingdimension)
if (getElementType(element) == "vehicle" and getVehicleOccupant(element) and getElementData(getVehicleOccupant(element),"faction") == 4 and getElementModel(element) == 525 and getVehicleTowedByVehicle(element)) then
local temp = element
while (getVehicleTowedByVehicle(temp)) do
temp = getVehicleTowedByVehicle(temp)
local owner = getElementData(temp, "owner")
local faction = getElementData(temp, "faction")
local dbid = getElementData(temp, "dbid")
local impounded = getElementData(temp, "Impounded")
local thePlayer = getVehicleOccupant(element)
if (owner > 0) then
if (faction > 3 or faction < 0) then
if (source == towSphere2) then
--PD make sure its not marked as impounded so it cannot be recovered and unlock/undp it
setVehicleLocked(temp, false)
exports.anticheat:changeProtectedElementDataEx(temp, "Impounded", 0)
exports.anticheat:changeProtectedElementDataEx(temp, "enginebroke", 0, false)
setVehicleDamageProof(temp, false)
setVehicleEngineState(temp, false)
outputChatBox("((تم حجز المركبة بنجاح))", thePlayer, 255, 194, 14)
else
if (getElementData(temp, "faction") ~= 4) then
if (impounded == 0) then
--unlock it and impound it
exports.anticheat:changeProtectedElementDataEx(temp, "Impounded", getRealTime().yearday)
setVehicleLocked(temp, false)
exports.anticheat:changeProtectedElementDataEx(temp, "enginebroke", 1, false)
setVehicleEngineState(temp, false)
local time = getRealTime()
-- fix trailing 0's
local hour = tostring(time.hour)
local mins = tostring(time.minute)
if ( time.hour < 10 ) then
hour = "0" .. hour
end
if ( time.minute < 10 ) then
mins = "0" .. mins
end
local datestr = time.monthday .. "/" .. time.month .." " .. hour .. ":" .. mins
local theTeam = exports.pool:getElement("team", 4)
local factionRanks = getElementData(theTeam, "ranks")
local factionRank = factionRanks[ getElementData(thePlayer, "factionrank") ] or ""
exports.global:giveItem(temp, 72, "Towing Notice: Impounded by ".. factionRank .." '".. getPlayerName(thePlayer) .."' at "..datestr)
insertTowRecord(thePlayer, temp)
outputChatBox("((تم حجز المركبة بنجاح))", thePlayer, 255, 194, 14)
--notifications
--exports.global:sendLocalDoAction(source, "Vehicle "..vehName.." has been impounded to "..factionName.."'s impound lot at lane #"..freeLane.lane..".")
local factionName = getTeamName(theTeam)
local owner = getElementData(temp, "owner")
local account = exports.cache:getAccountFromCharacterId(owner) or {id = 0, username="No-one"}
local characterName = exports.cache:getCharacterNameFromID(owner) or "No-one"
if owner > 0 and account then
exports.announcement:makePlayerNotification(account.id, factionName.."has impounded your "..exports.global:getVehicleName(temp).." (owned by "..characterName..").")
end
end
end
end
else
outputChatBox("هذة المركبة لايمكن حجزها لانها خاصة باحد الجهات الحكومية", thePlayer, 255, 194, 14)
end
end
end
end
end
addEventHandler("onColShapeHit", towImpoundSphere, UnlockVehicle)
addEventHandler("onColShapeHit", towSphere2, UnlockVehicle)