Jump to content

تصحيح كود


Recommended Posts

السلام عليكم 

لدي ماركر سيارات للقروب يشتغل وكل شي

 

بس في مشكلة انو لما اجي اخذ سيارة او طيارة ما يرسبن ليش ممكن تصلحولي اياه 

 

السيرفر

addEvent("spawningVehicle", true)
local groupName = '[ARMY]'
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 = {
                  {1529.85669, 25.99903, 42.6171},
                  {1529.85669, 25.99903, 42.6171}
                  }
        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 = 1598.17749, -262.16455, 51.722
            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], 0, 0, 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") ~= "[ARMY]" then
                    outputChatBox("This vehicle is only for "..[ARMY].." group!", player, 0, 0, 255)
                    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
)

 

 

الكلنت
 

local groupName = '[ARMY]'
local sx, sy = guiGetScreenSize()
 
mainWindow = guiCreateWindow((sx-438)/2, (sy-487)/2, 438, 487, " 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 = {
            {"Patriot", 470},
            {"Enforcer", 433},
            {"Cheetah", 415},
            {"Bullet", 541},
            {"Infernus", 411},
            {"Sultan", 560},
            {"Turismo", 451},
            {"Comet", 480},
            {"Huntley", 579},
            {"Flash", 565},
        }
    },
    bikes = {
        tab = guiCreateTab("Bikes", mainTab),
        list = {
            {"NRG-511", 522},
            {"PCJ-600", 461},
            {"Sanchez", 468}
        }
    },
    planes = {
        tab = guiCreateTab("Planes", mainTab),
        list = {
            {"Sparrow", 488},
            {"Maverick", 487}
           ,{"Leviathan", 417}
        }
    }
}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, "Press (Enter) to take your vehicle", true, mainWindow)
guiLabelSetColor(notice, 0, 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(1599.05750,-276.72305,50.7229, 2)
createMarker(1599.05750,-276.72305,50.7229,"cylinder",2,0,255,255,255)
 
addEventHandler("onClientColShapeHit", vehiclesMarker,
    function(hitElement)
        if hitElement == localPlayer and getElementData(hitElement, "Group") == "[ARMY]" 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") == "[ARMY]" 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

والسلام عليكم ورحمة الله وبركاتو

يعني بأختصار انو اخذ السيارة او طيارةة او الدباب ما بس ما تظهر او تبين

Link to comment

كخبير في اللغة احنا مو شغالين عندك

ولا تعتبرني احطمك

كخبير في اللغة حاول بنفسك بالأول، واحنا نصحح لك

أنت معطينا مود كامل يعني لازم نجربه ونصححه بنفسنا

xD

Link to comment

ب

13 minutes ago, #BrosS said:

كخبير في اللغة احنا مو شغالين عندك

ولا تعتبرني احطمك

كخبير في اللغة حاول بنفسك بالأول، واحنا نصحح لك

أنت معطينا مود كامل يعني لازم نجربه ونصححه بنفسنا

xD

 

-_- Luaبلله , يعني ماركر سيارات ما تعرف ايش مشكلتو يا متخصص لغة ال

Link to comment
addEvent("spawningVehicle", true)
local groupName = '[ARMY]'
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 = {
                  {1529.85669, 25.99903, 42.6171},
                  {1529.85669, 25.99903, 42.6171}
                  }
        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 = 1598.17749, -262.16455, 51.722
            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], 0, 0, 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") ~= "[ARMY]") then
            
                    outputChatBox("This vehicle is only for "..groupName.." group!", player, 0, 0, 255)
                    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
)

سيرفر

Link to comment

ياريت لما يكون عندك مشكلة

تكتب في اف 8

debugscript 3

وبعدين تجيب السطر الي فيه المشكلة وتطرحه هنا و نصححه لك او نطلب الكود كامل وليس المود كامل

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...