Jump to content

تصحيح كود الى المنرمجين + عناد الله وفقكم شباب


yaza034

Recommended Posts

تصحيح الكود

من قبل عناد يلي سوا الكود

حطتة كليت وحطيتة سيرفر

بس ما زبط والمشكلة لما اكتب سباق ما يروح للسباق

وذا الكود ارجوا المساعدة

Race = { 
    Players = { }; 
    Vehicles = { }; 
    Position = { 
        [1] = { x, y, z }; 
        [2] = { x, y, z }; 
        [3] = { x, y, z }; 
        [4] = { x, y, z }; 
        [5] = { x, y, z }; 
    }; 
    Cars = { 
        { 432 }; 
        { 432 }; 
    }; 
}; 
  
setRaceStats = function ( stats ) 
    if stats then 
        setElementData ( resourceRoot, "RaceStarted", true ) 
    else 
        Race.Players = { }; 
        setElementData ( resourceRoot, "RaceStarted", false ) 
        outputChatBox ( "* تم إفتتاح السباق", root, 255, 255, 0, true ) 
    end 
end 
  
addEventHandler ( "onPlayerChat", root, 
    function ( msg ) 
        if string.find ( msg, "سباق" ) then 
            if getElementData ( resourceRoot, "RaceStarted" ) then 
                return outputChatBox ( "* لم ينتهي السباق بعد", source, 255, 0, 0, true ) 
            end     
            if #Race.Players < 5 then 
                if not Race.Vehicles[source] then 
                    if #Race.Players == 4 then 
                        setRaceStats ( true ) 
                    end 
                    Race.Vehicles[source] = createVehicle ( Race.Cars[math.random(#Race.Cars)][1], Race.Position[#Race.Players][1], Race.Position[#Race.Players][2], Race.Position[#Race.Players][3] ) 
                    setTimer ( warpPedIntoVehicle, 100, 1, source, Race.Vehicles[source] ) 
                    table.insert { Race.Players, { source, Race.Vehicles[source], #Race.Players } } 
                end 
            else 
                outputChatBox ( "* أكتمل العدد", source, 255, 0, 0, true ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        for i, v in ipairs ( Race.Players ) do 
            if v[2] == source then 
                if #Race.Players == 1 then 
                    if isElement ( v[1] ) then 
                        givePlayerMoney ( v[1], 5000 ) 
                        outputChatBox ( "* $5000 لقد ربحت", v[1], 255, 255, 0, true ) 
                    end 
                    setTimer ( setRaceStats, 2000, 1, false ) 
                else 
                    table.remove { Race.Players, v[3] } 
                end 
                if isElement ( v[1] ) then 
                    Race.Vehicles[v[1]] = nil 
                end             
                break 
            end 
        end 
    end 
) 
  
addEventHandler ( "onElementDestroy", resourceRoot, 
    function ( ) 
        if getElementType ( source ) == "vehicle" then 
            for i, v in ipairs ( Race.Players ) do 
                if v[2] == source then 
                    if #Race.Players == 1 then 
                        if isElement ( v[1] ) then 
                            givePlayerMoney ( v[1], 5000 ) 
                            outputChatBox ( "* $5000 لقد ربحت", v[1], 255, 255, 0, true ) 
                        end 
                        setTimer ( setRaceStats, 2000, 1, false ) 
                    else 
                        table.remove { Race.Players, v[3] } 
                    end 
                    if isElement ( v[1] ) then 
                        Race.Vehicles[v[1]] = nil 
                    end 
                    break 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if Race.Vehicles[source] then 
            if isElement ( Race.Vehicles[source] ) then 
                destroyElement ( Race.Vehicles[source] ) 
            else 
                for i, v in ipairs ( Race.Players ) do 
                    if v[1] == source then 
                        if #Race.Players == 1 then 
                            setTimer ( setRaceStats, 2000, 1, false ) 
                        else 
                            table.remove { Race.Players, v[3] } 
                        end 
                        break 
                    end 
                end         
            end 
            Race.Vehicles[source] = nil 
        end 
    end 
) 
  
setRaceStats ( false ) 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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