Jump to content

Need helicopters and cars limit not a vehicles

Recommended Posts

Posted (edited)

RestricLocation = {}
TeleportLocation = {}

RestricLocation["location1"] = {1920.3017578125,1018.3994140625,12.11952495575}  --Координты верхнего противоположного угла
RestricLocation["location2"] = {1894.4609375,968.177734375,10.8203125}  --Координаты нижнего угла 
TeleportLocation = {1914.9658203125,960.185546875,10.8203125} --Куда телепортирует машину
local limit = 1 -- Максимальное колчество машин на базе всего / false - бесканечно
vehicleAcces = {

function enterZone(hitElement,thePlayer)
    if getElementType( hitElement ) == "vehicle" then 
        if limit == false then return end
        local model = getElementModel(hitElement)
        local vehiclesInBase = getElementsWithinColShape(ColCuboid,"vehicle")
        local vehAmount = table.maxn(vehiclesInBase)
        if vehAmount > limit then
                        setElementFrozen(hitElement, true)
            outputChatBox("Przekroczyles Limit Bazy",getVehicleOccupant(hitElement),255,255,255)
                        setElementFrozen(hitElement, false)
            outputChatBox("Twoj Limit: "..limit.." Masz Pojazdow: "..vehAmount,getVehicleOccupant(hitElement),255,255,255)

function LoadLocations()
    local RX, RY, RZ, WRX, WRX, WRX
    if(RestricLocation["location1"][1] > RestricLocation["location2"][1]) then
        RestricLocation["maxx"] = RestricLocation["location1"][1]
        RestricLocation["minx"] = RestricLocation["location2"][1]
        RestricLocation["maxx"] = RestricLocation["location2"][1]
        RestricLocation["minx"] = RestricLocation["location1"][1]
    if(RestricLocation["location1"][2] > RestricLocation["location2"][2]) then
        RestricLocation["maxy"] = RestricLocation["location1"][2]
        RestricLocation["miny"] = RestricLocation["location2"][2]
        RestricLocation["maxy"] = RestricLocation["location2"][2]
        RestricLocation["miny"] = RestricLocation["location1"][2]
    if(RestricLocation["location1"][3] > RestricLocation["location2"][3]) then
        RestricLocation["maxz"] = RestricLocation["location1"][3]
        RestricLocation["minz"] = RestricLocation["location2"][3]
        RestricLocation["maxz"] = RestricLocation["location2"][3]
        RestricLocation["minz"] = RestricLocation["location1"][3]

function CreateCollision()
    ColCuboid = createColCuboid (1894.46, 968.18, 9.82, 27.33, 51.19, 5.67)
    if ColCuboid then
        addEventHandler ( "onColShapeHit", ColCuboid, enterZone )

function ResourceStop( )
    destroyElement ( ColCuboid )
addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ),ResourceStop)



How i can add limits to helicopters and cars because now i have limit only for "vehicles" i want limit heli on 1-2 and cars 1-5 etc

Edited by Piktadarys
add info on down
Link to post
  • Scripting Moderators

Hi :)
As first you need table with your vehicles which is returned by getElementsWithinColShape function.
Then you would need to use loop and getVehicleType function in order to verify whether is a helicopter or a simple vehicle. This will allow you to count certain vehicles type, and process logic based on result.

getVehicleType function:

Understanding loops:


Link to post

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