Jump to content

Need helicopters and cars limit not a vehicles


Recommended Posts

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
            setElementPosition(hitElement,TeleportLocation[1],TeleportLocation[2],TeleportLocation[3])
                        setElementFrozen(hitElement, true)
            outputChatBox("Przekroczyles Limit Bazy",getVehicleOccupant(hitElement),255,255,255)
                        setElementFrozen(hitElement, false)
        else 
            outputChatBox("Twoj Limit: "..limit.." Masz Pojazdow: "..vehAmount,getVehicleOccupant(hitElement),255,255,255)
        end
            end
        end

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]
    else
        RestricLocation["maxx"] = RestricLocation["location2"][1]
        RestricLocation["minx"] = RestricLocation["location1"][1]
    end
    if(RestricLocation["location1"][2] > RestricLocation["location2"][2]) then
        RestricLocation["maxy"] = RestricLocation["location1"][2]
        RestricLocation["miny"] = RestricLocation["location2"][2]
    else
        RestricLocation["maxy"] = RestricLocation["location2"][2]
        RestricLocation["miny"] = RestricLocation["location1"][2]
    end
    if(RestricLocation["location1"][3] > RestricLocation["location2"][3]) then
        RestricLocation["maxz"] = RestricLocation["location1"][3]
        RestricLocation["minz"] = RestricLocation["location2"][3]
    else
        RestricLocation["maxz"] = RestricLocation["location2"][3]
        RestricLocation["minz"] = RestricLocation["location1"][3]
    end
end
LoadLocations()

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

function ResourceStop( )
    destroyElement ( ColCuboid )
end
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 comment
  • 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:
https://wiki.multitheftauto.com/wiki/GetVehicleType

Understanding loops:
https://forum.multitheftauto.com/topic/121619-lua-for-absolute-beginners/

 

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