--server
outputChatBox("#610B0B.:#585858[ #610B0BDrift_Mission By |M.r|LooFe|#585858 ]#610B0B:.",root,255,255,0,true)
addEventHandler( 'onPlayerCommand', getRootElement( ),
function( cmd )
if ( getElementData( source,"Mission" ) == true and cmd == 'admin' ) then
cancelEvent( )
outputChatBox("* Admin : لايمكنك إستخدام اللوحة في المهمات",source,255,0,0)
end
end )
spawns = {}
setElementData(resourceRoot,"map1","no")
setElementData(resourceRoot,"winMoney1","0")
addEventHandler("onPlayerChat",getRootElement(),function(message)
if tostring(message) == "دخول" and checkDuel(source) == "prestart" and ( not checkExistPlrOnDuel(source) ) then
triggerClientEvent("openGuiDrift",localPlayer)
online = countPlayersOnDerby()
if tonumber(online)+1 < 32 then
setData(source,"Mission","yes")
setData(source,"onCrossMap1","yes")
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA تم اضافتك في المهمة , انتظر حتى يبدأ القيم #800000#",source,255,255,0,true)
setD(source)
spawnOnMap(source)
else
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA امتلئت المهمة , الرجاء انتظار القيم القآدم #800000#",source,0,255,0,true)
end
end end)
function checkDuel(p)
if tostring(getElementData(resourceRoot,"map1")) == "yes" then
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA المهمة شغالة حاليا #800000#",p,255,255,0,true)
elseif tostring(getElementData(resourceRoot,"map1")) == "no" then
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA المهمة غير شغالة حاليا #800000#",p,255,255,0,true)
end
return tostring(getElementData(resourceRoot,"map1"))
end
function checkExistPlrOnDuel(p)
per = getElementData(p,"onCrossMap1")
if tostring(per) == "yes" then
return true
else
return false
end
end
function setData(element,key,vlr)
setElementData(element,key,vlr)
end
function setD(element)
setElementDimension(element,140)
end
function spawnOnMap(p)
count = countPlayersOnDerby()
spawned = "no"
for i,data in pairs(spawns)do
if tonumber(data.id) == tonumber(count) then
spawned = "yes"
v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz)
setElementDimension(v,140)
setElementFrozen(v,true)
setElementData(v,"creatorShoter","yes")
break
end
end
if spawned == "no" then
randomS = math.random("1","32")
for i,data in pairs(spawns)do
if tonumber(data.id) == tonumber(randomS) then
v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz)
setElementDimension(v,140)
setElementFrozen(v,true)
setElementData(v,"creatorShoter","yes")
break
end end
end
toggleControl(p,"enter_exit", false )
warpPedIntoVehicle(p,v)
setCameraTarget(p,p)
end
function countPlayersOnDerby()
c = -1
for i,p in pairs(getElementsByType("player"))do
if checkExistPlrOnDuel(p) then
c = c+1
end
end
return tonumber(c)
end
function eventCheck ()
if checkExistPlrOnDuel(source) then
toggleControl(source,"enter_exit",true )
setData(source,"onCrossMap1","no")
checkEnd()
end
end
addEventHandler("onPlayerWasted",getRootElement(),eventCheck)
addEventHandler("onPlayerQuit",getRootElement(),eventCheck)
addEventHandler("onPlayerJoin",getRootElement(),function()
setData(source,"onCrossMap1","no")
end)
for i,p in pairs(getElementsByType("player"))do
setData(p,"onCrossMap1","no")
end
function checkEnd()
c = 0
for i,p in pairs(getElementsByType("player"))do
if checkExistPlrOnDuel(p) then
c = c+1
winner = p
end end
if tonumber(c) == 1 then
givePlayerMoney(winner,tonumber(getElementData(resourceRoot,"winMoney1")))
n = string.gsub(getPlayerName(winner), "#%x%x%x%x%x%x", "")
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF: #610B0B[ #6E6E6E" .. n .. " #610B0B] #FFFAAA مبروك للفائز في مهمة الدرفت",root,255,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
setElementData(resourceRoot,"map1","no")
endDerby()
setTimer(newDuel,30000,1)
end
end
function newDuel()
for i,p in pairs(getElementsByType("player"))do
setData(p,"onCrossMap1","no")
end
setElementData(resourceRoot,"map1","prestart")
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA للدخول الى مهمة الدرفت اكتب في الشات دخول",getRootElement(),255,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
RMoney = math.random("50000","300000")
setElementData(resourceRoot,"winMoney1",tonumber(RMoney))
setTimer(checkPlrs,30000,1)
end
function checkPlrs ()
c = 0
for i,p in pairs(getElementsByType("player"))do
if checkExistPlrOnDuel(p) then
c = c+1
end end
if tonumber(c) > 1 then
setElementData(resourceRoot,"map1","yes")
for i,p in pairs(getElementsByType("player"))do
if checkExistPlrOnDuel(p) then
setElementCollisionsEnabled(getPedOccupiedVehicle(p),true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA لقد بدأ الدرفت يمكنك الانطلاق",p,0,255,0,true)
outputChatBox(" ",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
setElementFrozen(getPedOccupiedVehicle(p),false)
end end
else
endDerby()
setElementData(resourceRoot,"map1","no")
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#FFFAAA ! لم يبدأ الدرفت لعدم توفر لاعبين",getRootElement(),255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:",root,255,255,0,true)
outputChatBox("#585858[ #610B0BDrift_Mission #585858] #FFFFFF:#610B0B =====================================",root,255,255,0,true)
setTimer(newDuel,60000,1)
end
end
setTimer(newDuel,3000,1)
function onStartLoadSpawns ()
file = fileOpen("map1.map")
localFile = fileOpen("map1.xml")
fileWrite(localFile,"")
data = fileRead(file,999999)
fileWrite(localFile,data)
fileClose(localFile)
xml = xmlLoadFile("map1.xml")
c = 0
for i,data in pairs(xmlNodeGetChildren(xml)) do
if xmlNodeGetName(data) == "spawnpoint" then
c = c+1
v,xx,yy,zz,rxx,ryy,rzz = xmlNodeGetAttribute(data,"vehicle"),xmlNodeGetAttribute(data,"posX"),xmlNodeGetAttribute(data,"posY"),xmlNodeGetAttribute(data,"posZ"),xmlNodeGetAttribute(data,"rotX"),xmlNodeGetAttribute(data,"rotY"),xmlNodeGetAttribute(data,"rotZ")
table.insert(spawns,{id = c,model = v,x = xx,y = yy,z = zz,rx = rxx,ry = ryy,rz = rzz})
end
end
for i,data in pairs(xmlNodeGetChildren(xml)) do
if xmlNodeGetName(data) == "object" then
m,xx,yy,zz,rxx,ryy,rzz = xmlNodeGetAttribute(data,"model"),xmlNodeGetAttribute(data,"posX"),xmlNodeGetAttribute(data,"posY"),xmlNodeGetAttribute(data,"posZ"),xmlNodeGetAttribute(data,"rotX"),xmlNodeGetAttribute(data,"rotY"),xmlNodeGetAttribute(data,"rotZ")
object = createObject(m,xx,yy,zz,rxx,ryy,rzz)
setElementDimension(object,140)
end end
end
setTimer(onStartLoadSpawns,3000,1)
function endDerby()
for i,p in pairs(getElementsByType("player"))do
if checkExistPlrOnDuel(p) then
killPed(p)
end end
for i,v in pairs(getElementsByType("vehicle"))do
if getElementData(v,"creatorShoter") then
destroyElement(v)
end end
end
setTimer(function()
for i,p in pairs(getElementsByType("player"))do
sea(p)
resetHan(p)
checkVeh(p)
checkModel(p)
end
end,1000,0)
function sea(p)
if checkExistPlrOnDuel(p) then
x,y,z = getElementPosition(p)
if tonumber(z) <= 0 then
killPed(p)
end
end
end
function checkVeh(p)
if (tonumber(getElementDimension(p)) == 140) and not (isPedInVehicle(p))then
killPed(p)
end
end
function resetHan(p)
if checkExistPlrOnDuel(p) then
setVehicleHandling (getPedOccupiedVehicle(p), true )
end
end
function checkModel(p)
if checkExistPlrOnDuel(p) and isPedInVehicle(p) then
if tonumber(getElementModel(getPedOccupiedVehicle(p))) ~= 411 then
killPed(p)
end end
end
--------------------
-- client
addEventHandler("onClientRender",getRootElement(),function()
if tostring(getElementData(getLocalPlayer(),"onCrossMap1")) == "yes" then
setWorldSpecialPropertyEnabled("aircars", false)
setWorldSpecialPropertyEnabled("extrajump", false)
setWorldSpecialPropertyEnabled("hovercars", false)
end
end)
local Keys,Dim = {"F1","F2","F3","F4","F5","F6","F7","F9","F10","p","m","j","`","]","[","/","F","enter","shift","x","b","k","o"} , 140 ;
addEventHandler ( "onClientKey" , root , function ( key , press )
if ( press and getElementDimension ( localPlayer ) == Dim ) then
for k,v in ipairs ( Keys ) do
if ( v == key ) then
cancelEvent()
end
end
end
end ) ;
addEvent("openGuiDrift",true)
addEventHandler("openGuiDrift",root,
function ()
guiSetVisible(wnd, not guiGetVisible ( wnd ) )
showCursor ( guiGetVisible ( wnd ) )
end
)
addEventHandler("onClientGUIClick",root,
function ()
if source == ex then
if(guiGetVisible(اسم اللوحة) == false)then end
guiSetVisible(اسم اللوحة,false)
showCursor(false)
guiSetInputEnabled(false)
end end)