Jump to content

تجميد سيارة عند عدم الاستخدام


Micro

Recommended Posts

سلام عليكم

وظيفة الكود تجميد سيارة عند عدم الاستخدام وفك تجميد عند الاستخدام

فقمت بكتابة الكود

 players = getElementsByType ( "player" )  
  
 veh = getElementsByType( "vehicle" )  
local function freeze (player) 
for thePlayer,theVehicle in ipairs(veh) do 
 for pla,player in ipairs( players) do 
playername = getPlayerName(player) 
if(isPlayerInVehicle(player)) then 
 playerVehicle = getPlayerOccupiedVehicle (player) 
        setVehicleFrozen(playerVehicle,false) 
        else 
playername = getPlayerName(player) 
numseats = getVehicleMaxPassengers (theVehicle) 
    setVehicleFrozen(theVehicle,true) 
        end 
  
end 
end 
end 
setTimer(freeze,100,-1) 

فهي شغالة 100 % عندما يكون لاعب واحد بسيرفر

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

Link to comment

جرب

function freeze() 
    for i, vehicle in ipairs (getElementsByType("vehicle")) do 
        if isVehicleEmpty(vehicle) then 
            setElementFrozen(vehicle, true) 
        else 
            setElementFrozen(vehicle, false) 
        end 
    end 
end 
setTimer(freeze, 500, 0) 
  
function isVehicleEmpty( vehicle ) 
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then 
        return true 
    end 
  
    local passengers = getVehicleMaxPassengers( vehicle ) 
    if type( passengers ) == 'number' then 
        for seat = 0, passengers do 
            if getVehicleOccupant( vehicle, seat ) then 
                return false 
            end 
        end 
    end 
    return true 
end 

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...