🖥️Functions

GetPlayerData

Function Description

This function will simply return the value of UgCore.PlayerData.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function PrintPlayerName()
    local playerData = UgCore.Functions.GetPlayerData()
    print(playerData.firstName .. ' ' .. playerData.lastName)
end

Function Return


SetPlayerData

Function Description

This function will insert or replace a player data. This is useful to insert more data to the player for custom scripts.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function HandcuffPlayer()
    local playerData = UgCore.Functions.GetPlayerData()
    if not playerData.handcuffed then
        UgCore.Functions.SetPlayerData('handcuffed', true)
        print('Player handcuffed!')
    else
        UgCore.Functions.SetPlayerData('handcuffed', false)
        print('Player uncuffed!')
    end
end

Function Arguments

ArgumentTypeRequiredDescription

key

string

yes

Data that you want to insert or replace.

value

string

yes

Value of the data you want to attribute.


IsPlayerLoaded

Function Description

This function will basically return the state of the player. In this case, if he has loaded or not.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function CheckIfPlayerHasLoaded()
    return UgCore.Functions.IsPlayerLoaded()
end

Function Return

  • UgCore.PlayerLoaded - boolean


CreateProgressBar

Function Description

This function will use the ug-progressBar script and create a progress bar. It can be used for example when you are using items, reviving players or others. This supports callbacks and has animations too.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function UseItem()
    local progressBarSettings = {
        Movement = {
            disableMovement = false,
            disableCarMovement = false,
            disableMouse = false,
            disableCombat = true
        },
        Animation = {
            animDict = 'mp_player_inteat@burger',
            anim = 'mp_player_int_eat_burger',
            flags = 49
        },
        Prop = {
            model = 'prop_cs_burger_01',
            bone = 60309,
            coords = vector3(0.0, 0.0, -0.02),
            rotation = vector3(30, 0.0, 0.0)
        }
    }
    UgCore.Functions.CreateProgressBar('use_item_sandwich', 'Eating a Sandwich',     5000, false, true, progressBarSettings.Movement, progressBarSettings.Animation, progressBarSettings.Prop, {}, function ()
	print('You eated a sandwich!')
    end, function ()
	print('You didn\'t finished eating!')
    end)
end

Function Arguments

ArgumentTypeRequiredDescription

name

string

yes

Name of the progressbar.

label

string

yes

Label that will show in the progressbar.

duration

number

yes

Duration of the progressbar in ms.

useWhileDead

boolean

yes

If the player can use the progressbar while dead.

canCancel

boolean

yes

If the player can cancel the progressbar.

disableControls

table

yes

Table of the controls to disable when in the progressbar.

animation

table

yes

Table of the animation that will be played.

prop

table

yes

Table of the prop that the player will have.

propTwo

table

yes

Table of the second prop that the player will have.

onFinish

function

yes

Callback of when the progressbar is finished successfully.

onCancel

function

yes

Callback of when the progressbar is cancelled.


GetItem

Function Description

This function will get the player inventory and will simply search for a specified item.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function CheckForItem(itemName)
    local item = UgCore.Functions.GetItem(itemName, 1)
    if item >= 1 then
        return true
    end
    return false
end

CreateThread(function ()
    while true do
        Wait(5000) -- Waiting 5 seconds.
        if CheckForItem('phone') then
            print('Player has a phone!')
        else
            print('Player doesn\'t have a phone!')
        end
    end
end)

-- Works with a table too --
local items = {
    'phone',
    'burger'
}

CreateThread(function ()
    while true do
        Wait(5000) -- Waiting 5 seconds.
        if CheckForItem(items) then
            print('Player has a phone and a bread!')
        else
            print('Player doesn\'t have a phone or a burger!')
        end
    end
end)

Function Arguments

ArgumentTypeRequiredDescription

item

string/table

yes

Items to search for.

amount

number

yes

Amount that will be searched.


Notify

Function Description

This function will send a notification to the player. This function is responsible to make the notify event working.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function NotifyPlayer(title, description, type, length)
    return UgCore.Functions.Notify(title, description, type, length)
end

Function Arguments

ArgumentTypeRequiredDescription

title

string

yes

Title that will show in the notification.

description

string

yes

Message that will show in the notification.

type

string

yes

Type of the notification.

length

number

yes

Duration of the notification in ms.


Notify

Function Description

This function will send a notification to the player. This function is responsible to make the notify event working.

Function Example

local UgCore = exports['ug-core']:GetCore()

local function NotifyPlayer(title, description, type, length)
    return UgCore.Functions.Notify(title, description, type, length)
end

Function Arguments

ArgumentTypeRequiredDescription

title

string

yes

Title that will show in the notification.

description

string

yes

Message that will show in the notification.

type

string

yes

Type of the notification.

length

number

yes

Duration of the notification in ms.


Last updated