Skip to content

Release 1.6.3

Choose a tag to compare

@MateHUNAa MateHUNAa released this 19 Jul 03:45
· 49 commits to main since this release

Update Overview

GitBook Documentation

Our documentation is now available on GitBook! You can access it here.

Transition to Open Source

We are excited to announce that our project is now open source! Stay tuned for more updates and contributions from the community.

Version 1.6.3 Update

New Client-Side Functions

The latest update introduces a range of new client-side functions to enhance your scripting capabilities. Below are the new functions added in version 1.6.3:

mCore.loadModel

Loads a 3D model into the game. Requires ox_lib.

mCore.loadModel = function(model)
    if GetResourceState("ox_lib") ~= "missing" then
        return lib.requestModel(model, 1000)
    end
    mCore.error("^6ox_lib^7 ^1NOT FOUND !^7")
end

mCore.unloadModel

Unloads a previously loaded model.

mCore.unloadModel = function(model)
    mCore.debug.log("^2Removing Model^7: '^6" .. model .. "^7'")
    SetModelAsNoLongerNeeded(model)
end

mCore.loadAnimDict

Loads an animation dictionary.

mCore.loadAnimDict = function(dict)
    if not HasAnimDictLoaded(dict) then
        mCore.debug.log("^2Loading Anim Dictionary^7: '^6" .. dict .. "^7'")
        while not HasAnimDictLoaded(dict) do
            RequestAnimDict(dict)
            Wait(5)
        end
    end
end

mCore.unloadAnimDict

Unloads an animation dictionary.

mCore.unloadAnimDict = function(dict)
    mCore.debug.log("^2Removing Anim Dictionary^7: '^6" .. dict .. "^7'")
    RemoveAnimDict(dict)
end

mCore.loadPtfxDict

Loads a particle effects dictionary.

mCore.loadPtfxDict = function(dict)
    if not HasNamedPtfxAssetLoaded(dict) then
        mCore.debug.log("^2Loading Ptfx Dictionary^7: '^6" .. dict .. "^7'")
        while not HasNamedPtfxAssetLoaded(dict) do
            RequestNamedPtfxAsset(dict)
            Wait(5)
        end
    end
end

mCore.unloadPtfxDict

Unloads a particle effects dictionary.

mCore.unloadPtfxDict = function(dict)
    mCore.debug.log("^2Removing Ptfx Dictionary^7: '^6" .. dict .. "^7'")
    RemoveNamedPtfxAsset(dict)
end

mCore.makeProp

Creates a new prop in the world.

mCore.makeProp = function(data, freeze, synced)
    Functions.loadModel(data.prop)
    local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z - 1.03, synced or false, false, false)
    SetEntityHeading(prop, data.coords.w + 180.0)
    FreezeEntityPosition(prop, freeze or false)
    if mCore.isDebug() then
        local coords = {
            string.format("%.2f", data.coords.x),
            string.format("%.2f", data.coords.y),
            string.format("%.2f", data.coords.z),
            string.format("%.2f", data.coords.w or 0.0)
        }
        mCore.debug.log("^1Prop ^2Created^7: '^6" .. prop .. "^7' | ^2Hash^7: ^7'^6" .. data.prop .. "^7' | ^2Coord^7: ^5vec4^7(^6" .. coords[1] .. "^7, ^6" .. coords[2] .. "^7, ^6" .. coords[3] .. "^7, ^6" .. coords[4] .. "^7)")
    end
    return prop
end

mCore.makeBlip

Creates a blip on the map.

mCore.makeBlip = function(data)
    local blip = AddBlipForCoord(data.coords.x, data.coords.y, data.coords.z)
    SetBlipAsShortRange(blip, true)
    SetBlipSprite(blip, data.sprite or 1)
    SetBlipColour(blip, data.col or 0)
    SetBlipScale(blip, data.scale or 0.7)
    SetBlipDisplay(blip, (data.disp or 6))
    if data.category then SetBlipCategory(blip, data.category) end
    BeginTextCommandSetBlipName('STRING')
    AddTextComponentString(tostring(data.name))
    EndTextCommandSetBlipName(blip)
    mCore.debug.log("^6Blip ^2created for location^7: '^6" .. data.name .. "^7'")
    return blip
end

mCore.makePed

Spawns a pedestrian with optional behaviors.

mCore.makePed = function(model, coords, freeze, collision, scenario, anim)
    Functions.loadModel(model)
    local ped = CreatePed(0, model, coords.x, coords.y, coords.z - 1.03, coords.w, false, true)
    SetEntityInvincible(ped, true)
    SetBlockingOfNonTemporaryEvents(ped, true)
    FreezeEntityPosition(ped, freeze or true)
    if collision then
        SetEntityNoCollisionEntity(ped, PlayerPedId(), false)
    end
    if scenario then
        TaskStartScenarioInPlace(ped, scenario, 0, true)
    end
    if anim then
        Functions.loadAnimDict(anim[1])
        TaskPlayAnim(ped, anim[1], anim[2], 1.0, 1.0, -1, 1, 0.2, false, false, false)
    end
    mCore.debug.log(("^6Ped  ^2created for location^7: '^6%s^7'"):format(model))
    return ped
end

mCore.destoryProp

Destroys a specified prop.

mCore.destoryProp = function(entity)
    mCore.debug.log("^2Destroying Prop^7: '^6" .. entity .. "^7'")
    SetEntityAsMissionEntity(entity)
    Wait(5)
    DetachEntity(entity, true, true)
    Wait(5)
    DeleteObject(entity)
end

mCore.loadDrillSound

Loads drill sound banks for heists.

mCore.loadDrillSound = function()
    mCore.debug.log("^2Loading Drill Sound Banks^7")
    RequestAmbientAudioBank("DLC_HEIST_FLEECA_SOUNDSET", false)
    RequestAmbientAudioBank("DLC_MPHEIST\\HEIST_FLEECA_DRILL", false)
    RequestAmbientAudioBank("DLC_MPHEIST\\HEIST_FLEECA_DRILL_2", false)
end

mCore.unloadScriptHostedSounds

Releases sounds banks to free up resources.

mCore.unloadScriptHostedSounds = function()
    mCore.debug.log("^2Releasing Sounds Banks^7")
    ReleaseScriptAudioBank()
end

mCore.lookAtMe

Directs an entity to look at the player.

mCore.lookAtMe = function(entity)
    if DoesEntityExist(entity) then
        if not IsPedHeadingTowardsPosition(entity, GetEntityCoords(PlayerPedId()), 30.0) then
            TaskTurnPedToFaceCoord(entity, GetEntityCoords(PlayerPedId()), 1500)
            mCore.debug.log("^2Turning Player to^7: '^6" .. entity .. "^7'")
            Wait(1500)
        end
    end
end

mCore.lookEnt

Directs the player to face a specific entity or position.

mCore.lookEnt = function(entity)
    if type(entity) == "vec3" then
        if not IsPedHeadingTowardsPosition(PlayerPedId(), entity, 10.0) then
            TaskTurnPedToFaceCoord(PlayerPedId(), entity, 1500)
            mCore.debug.log("^2Turning Player to^7: '^6" .. json.encode(entity) .. "^7'")
            Wait(1500)
        end
    else
        if DoesEntityExist(entity) then
            if not IsPedHeadingTowardsPosition(PlayerPedId(), GetEntityCoords(entity), 30.0) then
                TaskTurnPedToFaceCoord(PlayerPedId(), GetEntityCoords(entity), 1500)
                mCore.debug.log("^2Turning Player to^7: '^6" .. entity .. "^7'")
                Wait(1500)
            end
        end
    end
end

mCore.lockInv

Locks or unlocks the player's inventory.

mCore.lockInv = function(toggle)
    FreezeEntityPosition(PlayerPedId(), toggle)
    LocalPlayer.state:set("inv_busy", toggle, true)
    TriggerEvent("inventory:client:busy:status", toggle)
    TriggerEvent("canUseInventoryAndHotbar:toggle", toggle)
end

mCore.progressBar

Displays a progress bar with the ability to cancel.

mCore.progressBar = function(data)
    if GetResourceState("ox_lib") ~= "missing" then
        local result = nil
        if exports["

ox_lib"]:progressBar({
            duration = data.time,
            label = data.label,
            useWhileDead = data.dead or false,
            canCancel = data.cancel or true,
            anim = { dict = data.dict, clip = data.anim, flag = (data.flag == 8 and 32 or data.flag) or nil, scenario = data.task },
            disable = { combat = true }
        }) then
            result = true
            Functions.lockInv(false)
        else
            result = false
            Functions.lockInv(false)
        end
        while result == nil do Wait(10) end
        return result
    end
    mCore.error("^6ox_lib^7 ^1NOT FOUND^7")
end

mCore.HasItem

Checks if the player has a specified amount of an item.

mCore.HasItem = function(items, amount)
    if GetResourceState("ox_inventory") ~= "missing" then
        local count = exports["ox_inventory"]:Search("count", items)
        local amount = amount or 1
        if count >= amount then
            mCore.debug.log("^3HasItem^7: ^5FOUND^7 ^3     %s ^7/^3 %s %s^7"):format(count, amount, items)
            return true
        else
            mCore.debug.log("^3HasItem^7: ^1NOT FOUND ^2 %s ^7"):format(tostring(items))
            return false
        end
    end
    mCore.error("^6ox_inventory^7 ^1NOT FOUND^7")
end

mCore.pairsByKeys

Returns key-value pairs of a table sorted by keys.

mCore.pairsByKeys = function(t)
    local a = {}
    for n in pairs(t) do a[#a + 1] = n end
    table.sort(a)
    local i = 0
    local iter = function()
        i = i + 1
        if a[i] == nil then return nil else return a[i], t[a[i]] end
    end
    return iter
end