السلام عليكوم ورحمت الله وبركاتو
انا عمل وظيفتان الطيران و نقل البضائع بس لما اشغلهة الاثنان بيشتغلو مع بعض ليش ؟؟
كود الطيران
الكلنت
local pilotMarkers = { {-1332.38671875,-134.22721862793,13.1484375},{243.10000610352,2500,16.5},{1644.1884765625,-2468.0930175781,12.5546875} ,{1338.9278564453,1346.7908935547,9.8203125}}
jobMarker1 = createMarker(1956.73291,-2183.64063,13.54688,"cylinder",2,0,0,0,0)
jobPed = createPed(61,1956.73291,-2183.64063,13.54688,-90)
jobBlip = createBlip(1956.73291,-2183.64063,13.54688,56)
setBlipVisibleDistance(jobBlip,170)
setElementFrozen(jobPed,true)
addEventHandler("onClientPedDamage",root,
function ()
if source == jobPed then
cancelEvent()
end
end)
local x,y = guiGetScreenSize()
addEventHandler("onClientMarkerHit",root,
function (hit)
if source == jobMarker1 then
if getElementType(hit) == "player" and getPlayerTeam(hit) ~= getTeamFromName("Pilot") then
if isPedInVehicle(hit) then return end
if localPlayer == hit then
guiSetVisible(GUIEditor.window[1],true)
showCursor(true)
end
end
end
end)
GUIEditor = {
gridlist = {},
window = {},
button = {}
}
local x = x - 332
local y = y - 333
GUIEditor.window[1] = guiCreateWindow(x/2,y/2,332,333, "Pilot Job", false)
guiWindowSetSizable(GUIEditor.window[1], false)
guiSetVisible(GUIEditor.window[1],false)
GUIEditor.button[1] = guiCreateButton(9, 272, 94, 41, "Take Job", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
GUIEditor.button[2] = guiCreateButton(233, 272, 89, 41, "Cancel", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
Memo1 = guiCreateMemo(13, 30, 318, 70, "اذهب لماركر الطيارات واحصل على طائرة لتوصيل الركآب إلى وجهتهم والحصول على نقود.", false, GUIEditor.window[1])
guiMemoSetReadOnly(Memo1, true)
GUIEditor.gridlist[1] = guiCreateGridList(12, 120, 310, 140, false, GUIEditor.window[1])
guiGridListAddColumn(GUIEditor.gridlist[1], "#", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Number", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.3)
for i = 1, 3 do
guiGridListAddRow(GUIEditor.gridlist[1])
end
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "1", false, false)
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "61", false, false)
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 3, "Pilot", false, false)
addEventHandler("onClientGUIClick",root,
function ()
if source == GUIEditor.button[1] then
local skin = guiGridListGetItemText( GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),2)
if skin ~= "" then
triggerServerEvent("startJob",localPlayer,skin)
guiSetVisible(GUIEditor.window[1],false)
showCursor(false)
end
elseif source == GUIEditor.button[2] then
guiSetVisible(GUIEditor.window[1],false)
showCursor(false)
end
end)
addEventHandler("onClientRender", getRootElement(),
function()
local x, y, z = getElementPosition(jobPed)
local x2, y2, z2 = getElementPosition(localPlayer)
if(isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) then
local sx, sy = getScreenFromWorldPosition(x, y, z+1.3)
if(sx) and (sy) then
local distance = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if(distance < 30) then
dxDrawText("Pilot Job", sx+2, sy+2, sx, sy, tocolor(0,0,0), 2-(distance/20), "arial", "center", "center")
dxDrawText("Pilot Job", sx, sy, sx, sy, tocolor(255,255,0), 2-(distance/20), "arial", "center", "center")
end
end
end
end)
function N9()
local num = math.random (#pilotMarkers)
local x = pilotMarkers [num][1]
local y = pilotMarkers [num][2]
local z = pilotMarkers [num][3]
pilotMark = createMarker(x,y,z,"cylinder",11.0,255,255,0,255)
pilotBlip = createBlip(x,y,z,41)
end
addEvent("createPilotMarkers",true)
addEventHandler("createPilotMarkers",root,N9)
addEvent("returnMarkers",true)
addEventHandler("returnMarkers",root,N9)
addEventHandler("onClientMarkerHit",root,
function (hitting)
if source == pilotMark then
if getElementType(hitting) == "player" and getPlayerTeam(hitting) == getTeamFromName("Pilot") and isPedInVehicle(hitting) then
triggerServerEvent("giveMoney",localPlayer)
destroyElement(pilotMark)
destroyElement(pilotBlip)
triggerServerEvent("returnJob",localPlayer)
end
end
end
)
fileDelete('jobClient.lua')
السيرفر
pilotTeam = createTeam("Pilot",255,255,0)
setTeamFriendlyFire(pilotTeam, false)
addEvent("startJob",true)
addEventHandler("startJob",root,
function (skin)
setElementModel(client,tonumber(skin))
setPlayerTeam(client,pilotTeam)
triggerClientEvent(client,"createPilotMarkers",client)
end
)
addEvent("giveMoney",true)
addEventHandler("giveMoney",root,
function ()
local r = math.random(1000,2000)
givePlayerMoney(client,r)
outputChatBox("* You've got "..tonumber(r).."$ for arriving to your destination.",client,60,255,60)
end
)
addEvent("returnJob",true)
addEventHandler("returnJob",root,
function()
triggerClientEvent(client,"returnMarkers",client)
end
)
كود نقل البضائع
الكلنت
local TruckerMarkers = { {2706.15894,861.65997,9.84375},{349.65457,889.39380,20.40625},{-330.21341,1517.79688,75.35938} ,{-2270.38770,2297.00513,4.82021},{349.65457,889.39380,20.40625},{-2745.32764,-284.79349,7.03906} ,{-1390.05420,-337.18057,14.14844},{349.65457,889.39380,20.40625},{-1556.82446,-2744.44385,48.54116} ,{1642.57263,-2241.28394,13.49379},{2685.51099,-1673.63757,9.43895},{1355.05957,-1752.38184,13.36764},{2132.25073,-2090.87695,13.54688}}
jobMarker1 = createMarker(2591.03369,-2206.21191,13.54688,"cylinder",2,0,0,0,0)
jobPed = createPed(1,2591.03369,-2206.21191,13.54688,270)
jobBlip = createBlip(2591.03369,-2206.21191,13.54688,56)
setBlipVisibleDistance(jobBlip,170)
setElementFrozen(jobPed,true)
addEventHandler("onClientPedDamage",root,
function ()
if source == jobPed then
cancelEvent()
end
end)
local x,y = guiGetScreenSize()
addEventHandler("onClientMarkerHit",root,
function (hit)
if source == jobMarker1 then
if getElementType(hit) == "player" and getPlayerTeam(hit) ~= getTeamFromName("Trucker") then
if isPedInVehicle(hit) then return end
if localPlayer == hit then
guiSetVisible(GUIEditor.window[1],true)
showCursor(true)
end
end
end
end)
GUIEditor = {
gridlist = {},
window = {},
button = {}
}
local x = x - 332
local y = y - 333
GUIEditor.window[1] = guiCreateWindow(x/2,y/2,332,333, "Trucker Job", false)
guiWindowSetSizable(GUIEditor.window[1], false)
guiSetVisible(GUIEditor.window[1],false)
GUIEditor.button[1] = guiCreateButton(9, 272, 94, 41, "Take Job", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
GUIEditor.button[2] = guiCreateButton(233, 272, 89, 41, "Cancel", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
Memo1 = guiCreateMemo(13, 30, 318, 70, "اذهب لماركر الطيارات واحصل على طائرة لتوصيل الركآب إلى وجهتهم والحصول على نقود.", false, GUIEditor.window[1])
guiMemoSetReadOnly(Memo1, true)
GUIEditor.gridlist[1] = guiCreateGridList(12, 120, 310, 140, false, GUIEditor.window[1])
guiGridListAddColumn(GUIEditor.gridlist[1], "#", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Number", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.3)
for i = 1, 3 do
guiGridListAddRow(GUIEditor.gridlist[1])
end
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "1", false, false)
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "1", false, false)
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 3, "truth", false, false)
addEventHandler("onClientGUIClick",root,
function ()
if source == GUIEditor.button[1] then
local skin = guiGridListGetItemText( GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),2)
if skin ~= "" then
triggerServerEvent("startJob",localPlayer,skin)
guiSetVisible(GUIEditor.window[1],false)
showCursor(false)
end
elseif source == GUIEditor.button[2] then
guiSetVisible(GUIEditor.window[1],false)
showCursor(false)
end
end)
function N9()
local num = math.random (#TruckerMarkers)
local x = TruckerMarkers [num][1]
local y = TruckerMarkers [num][2]
local z = TruckerMarkers [num][3]
TruckerMark = createMarker(x,y,z,"cylinder",8.0,255,255,0,255)
TruckerBlip = createBlip(x,y,z,41)
end
addEvent("createTruckerMarkers",true)
addEventHandler("createTruckerMarkers",root,N9)
addEvent("returnMarkers",true)
addEventHandler("returnMarkers",root,N9)
addEventHandler("onClientMarkerHit",root,
function (hitting)
if source == TruckerMark then
if getElementType(hitting) == "player" and getPlayerTeam(hitting) == getTeamFromName("Trucker") and isPedInVehicle(hitting) then
triggerServerEvent("giveMoney",localPlayer)
destroyElement(TruckerMark)
destroyElement(TruckerBlip)
triggerServerEvent("returnJob",localPlayer)
end
end
end
)
fileDelete('jobClient.lua')[/code]
[u]السيرفر[/u]
[lua]TruckerTeam = createTeam("Trucker",255,255,0)
setTeamFriendlyFire(TruckerTeam, false)
addEvent("startJob",true)
addEventHandler("startJob",root,
function (skin)
setElementModel(client,tonumber(skin))
setPlayerTeam(client,TruckerTeam)
triggerClientEvent(client,"createTruckerMarkers",client)
end
)
addEvent("giveMoney",true)
addEventHandler("giveMoney",root,
function ()
local r = math.random(2000,5000)
givePlayerMoney(client,r)
outputChatBox("* You've got "..tonumber(r).."$ for arriving to your destination.",client,60,255,60)
end
)
addEvent("returnJob",true)
addEventHandler("returnJob",root,
function()
triggerClientEvent(client,"returnMarkers",client)
end
)