جرب ورد خبر ضض1 &
Server
addEvent("spawningVehicle", true)
local groupName = '[s.S]'
local activeVehicles = {}
local playersVehicles = {}
local occupiedVehicles = {}
local activeTimers = {}
local Intruders = {}
local function addVehicleToDestroyList(vehicleNumber)
activeTimers[vehicleNumber] = setTimer(
function(vehicleNumber)
destroyElement(activeVehicles[vehicleNumber])
activeVehicles[vehicleNumber] = nil
activeTimers[vehicleNumber] = nil
for i,v in pairs(playersVehicles) do
if v == vehicleNumber then
playersVehicles[i] = nil
break
end
end
end, 30000, 1, vehicleNumber
)
end
local function removeVehicleFromDestroyList(vehicleNumber)
if isTimer(activeTimers[vehicleNumber]) then
killTimer(activeTimers[vehicleNumber])
activeTimers[vehicleNumber] = nil
end
end
addEventHandler("spawningVehicle", root,
function(model, planes)
local poo = {
{779.74615,1402.28125,66.32813},
{736.00775,1401.18469,66.32813}
}
local x, y, z = 0, 0, 0
local rx, ry, rz = 0, 0, 0
if planes then
x, y, z = unpack(poo[math.random(#poo)])
rx, ry, rz = 0.3275146484375, 359.78839111328, 271.46984863281
else
x, y, z = 751.25323,1260.12549,36.08281
rx, ry, rz = 359.54382324219, 359.99975585938, 3.48193359375
end
if playersVehicles[client] then
destroyElement(activeVehicles[playersVehicles[client]])
removeVehicleFromDestroyList(playersVehicles[client])
playersVehicles[client] = nil
end
local vehicle = #activeVehicles + 1
activeVehicles[vehicle] = createVehicle(model, x, y, z, rx, ry, rz)
setVehicleColor(activeVehicles[vehicle], 255, 255, 255)
warpPedIntoVehicle(client, activeVehicles[vehicle])
addVehicleUpgrade(activeVehicles[vehicle], 1010)
playersVehicles[client] = vehicle
occupiedVehicles[vehicle] = nil
end
)
addEventHandler("onVehicleExit", root,
function(player, seat)
if seat == 0 then
if playersVehicles[player] then
addVehicleToDestroyList(playersVehicles[player])
occupiedVehicles[playersVehicles[player]] = nil
else
for i,v in pairs(activeVehicles) do
if v == source then
addVehicleToDestroyList(i)
occupiedVehicles[i] = nil
end
end
end
end
end
)
addEventHandler("onVehicleEnter", root,
function(player, seat)
if seat == 0 then
if playersVehicles[player] then
removeVehicleFromDestroyList(playersVehicles[player])
occupiedVehicles[playersVehicles[player]] = true
else
for i,v in pairs(activeVehicles) do
if v == source then
removeVehicleFromDestroyList(i)
occupiedVehicles[i] = true
break
end
end
end
end
end
)
addEventHandler("onVehicleStartEnter", root,
function(player, seat)
for i,v in pairs(activeVehicles) do
if v == source then
if getElementData(player, "Group") ~= groupName then
outputChatBox("This vehicle is only for "..groupName.." group!", player, 255, 0, 0)
cancelEvent()
else
if seat == 0 and occupiedVehicles[i] then
outputChatBox("You cannot take this vehicle as someone in it already!", player, 255, 0, 0)
cancelEvent()
end
end
break
end
end
end
)
addEventHandler("onVehicleExplode", root,
function()
for i,v in pairs(activeVehicles) do
if v == source then
removeVehicleFromDestroyList(i)
activeVehicles[i] = nil
occupiedVehicles[i] = nil
setTimer(destroyElement, 2000, 1, source)
for k,s in pairs(playersVehicles) do
if i == s then
playersVehicles[k] = nil
break
end
end
break
end
end
end
)
Client
local groupName = '[s.S]'
local sx, sy = guiGetScreenSize()
mainWindow = guiCreateWindow((sx-438)/2, (sy-487)/2, 438, 487, "[s.S] Vehicles{تمت البرمجة من قبل شراف}", false)
guiWindowSetSizable(mainWindow, false)
guiSetAlpha(mainWindow, 1.00)
guiSetVisible(mainWindow, false)
mainTab = guiCreateTabPanel(0.02, 0.04, 0.96, 0.90, true, mainWindow)
local vehicles = {
cars = {
tab = guiCreateTab("Cars", mainTab),
list = {
{"Cheetah", 415},
{"Bullet", 541},
{"Infernus", 411},
{"Sultan", 560},
{"Turismo", 451},
{"Comet", 480},
{"Huntley", 579},
{"Bandito", 568},
{"Coach", 437},
{"Hotring Racer", 494},
{"Monster3", 557},
}
},
bikes = {
tab = guiCreateTab("Bikes", mainTab),
list = {
{"NRG-511", 522},
{"PCJ-600", 461},
{"Sanchez", 468}
}
},
planes = {
tab = guiCreateTab("Planes", mainTab),
list = {
{"Sparrow", 469},
{"Maverick", 487}
}
}
}
vehicles.cars.gridlist = guiCreateGridList(0.05, 0.02, 0.89, 0.95, true, vehicles.cars.tab)
table.insert(vehicles.cars, guiGridListAddColumn(vehicles.cars.gridlist, "Cars", 0.9))
vehicles.bikes.gridlist = guiCreateGridList(0.05, 0.02, 0.89, 0.95, true, vehicles.bikes.tab)
table.insert(vehicles.bikes, guiGridListAddColumn(vehicles.bikes.gridlist, "Bikes", 0.9))
vehicles.planes.gridlist = guiCreateGridList(0.05, 0.02, 0.89, 0.95, true, vehicles.planes.tab)
table.insert(vehicles.planes, guiGridListAddColumn(vehicles.planes.gridlist, "Planes", 0.9))
notice = guiCreateLabel(0.02, 0.94, 0.96, 0.03, " اختر سيارة ثم اضغط على الزر (Entrée) ", true, mainWindow)
guiLabelSetColor(notice, 255, 255, 0)
guiLabelSetHorizontalAlign(notice, "center", false)
guiLabelSetVerticalAlign(notice, "center")
for i,v in pairs(vehicles) do
for _,k in ipairs(v.list) do
local row = guiGridListAddRow(v.gridlist)
guiGridListSetItemText(v.gridlist, row, v[1], k[1], false, false)
end
end
local vehiclesMarker = createColSphere(733.99054,1264.04980,36.08281, 1)
createMarker(733.99054,1264.04980,36.08281,"cylinder",2,0,255,0,255)
addEventHandler("onClientColShapeHit", vehiclesMarker,
function(hitElement)
if hitElement == localPlayer and getElementData(hitElement, "Group") == groupName and not isPedInVehicle(hitElement) then
guiSetVisible(mainWindow, true)
showCursor(true)
bindKey("enter", "down", selectVehicle)
end
end,false
)
addEventHandler("onClientColShapeLeave", vehiclesMarker,
function(leaveElement)
if leaveElement == localPlayer and getElementData(leaveElement, "Group") == groupName and not isPedInVehicle(leaveElement) then
guiSetVisible(mainWindow, false)
showCursor(false)
unbindKey("enter", "down", selectVehicle)
end
end, false
)
function selectVehicle()
for i,v in pairs(vehicles) do
local tab = v.tab
if guiGetSelectedTab(mainTab) == tab then
local gridlist = v.gridlist
if guiGridListGetSelectedItem(gridlist) ~= -1 then
local row = guiGridListGetSelectedItem(gridlist)
local vehName = guiGridListGetItemText(gridlist, row, v[1])
for _,k in ipairs(v.list) do
if k[1] == vehName then
if i == "planes" then
triggerServerEvent("spawningVehicle", localPlayer, k[2], true)
else
triggerServerEvent("spawningVehicle", localPlayer, k[2], false)
end
unbindKey("enter", "down", selectVehicle)
break
end
end
guiSetVisible(mainWindow, false)
showCursor(false)
break
end
end
end
end
. .