BCC Utils

(Docs)

A RedM standalone Development API system.

Initial Setup

  • Place this atop your client file!
local BccUtils = {}
TriggerEvent('bcc:getUtils', function(bccutils)
BccUtils = bccutils
end)

OR

BccUtils = exports['bcc-utils'].initiate()

Blips

You can leverage BCCs built in function for map blips.

Create a Blip

Create a marker (blip) on the players map

ParameterDescription
textWhat the blip will display on the map
bliphashThe hashname of the blip (found here)
scaleHow big the blip is
xThe x coordinate in the game world
yThe y coordinate in the game world
zThe z coordinate in the game world
vector3instead of params send whole vector3 just add nil to x y z

Example Usage:

-- client side only
Citizen.CreateThread(function()
local blip = BccUtils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z, vector3 or nil)
end)

Add Blip Modifier

Add a modifier to a blip, which can change its appearance or behavior.

-- client side only
Citizen.CreateThread(function()
local blip = BccUtils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z, vector3 or nil)
local blipModifier = BccUtils.Blips:AddBlipModifier(blip, 'BLIP_MODIFIER_MP_COLOR_8')
blipModifier:ApplyModifier()
end)

Get Raw Blip

If you want to use any natives that are not yet included, you can utilize the raw blip.

-- client side only
Citizen.CreateThread(function()
local blip = BccUtils.Blip:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vector3 or nil)
local rawblip = blip.rawblip
-- OR
-- local rawblip = blip:Get()
-- use rawblip with any other native.
end)

Delete a Blip

Delete a marker (blip) on the players map

-- client side only
Citizen.CreateThread(function()
local blip = BccUtils.Blip:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vecotr3 or nil)
blip:Remove()
-- OR
--- BccUtils.Blip:RemoveBlip(blip.rawblip)
end)

Add Radius to Blip

Create a Radius blip

ParameterDescription
radiusA decimal radius
bliphahashshThe hashname of the blip (found here) Optional, will default to -1282792512

Example Usage:

-- client side only
Citizen.CreateThread(function()
local blip = BccUtils.Blip:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vector3 or nil)
blip:AddRadius(64.0, -1282792512)
-- OR
-- BccUtils.Blip:AddRadius(64.0, x, y, z, -1282792512)
end)

Prompts

You can leverage BCCs built in function for easy in-game prompts.

Setup a Prompt Group

This sets up the Prompt Group, which will allow you to attach future prompts to this group so that they can be displayed. This is required.

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
end)

Register Prompt

Once you have the Prompt Group setup, you can now register a prompt to display within the group.

ParameterDescription
titleWhat the Prompt group will display next to the press button
buttonThe hash key
enabledIf 0 you cannot click, if 1 you can click
visibleIf 0 you cannot see the prompt, if 1 you can see the group
pulsingIf true prompt will urgently pulse, if false it will not
modeWhat kind of prompt. (Options: click, hold, customhold, mash, timed)
optionsExtra Options for the Mode you select. (See Mode Options below)

Modes Options

ModeKeyOptionsexample
clickNoneNoneNone
holdtimedeventhashSHORT_TIMED_EVENT_MP, SHORT_TIMED_EVENT, MEDIUM_TIMED_EVENT, LONG_TIMED_EVENT, RUSTLING_CALM_TIMING, PLAYER_FOCUS_TIMING, PLAYER_REACTION_TIMING{ timedeventhash = "SHORT_TIMED_EVENT" }
customholdholdtimeMiliseconds{ holdtime = 3000 }
mashmashamount> 0{ mashamount = 20 }
timeddepletiontimeMiliseconds{ depletiontime = 10000}

PromptGroup:RegisterPrompt(title, button, enabled, visible, pulsing, mode, options)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
end
end)

Display Prompt Group

Now that you have a Group setup and a registered Prompt, you can now display the group!

ParameterDescription
textText to display under all the prompts

PromptGroup:ShowGroup(text)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
PromptGroup:ShowGroup("My first prompt group") --Show your prompt group
end
end)

Handle Prompt Completion Events

You can trigger code when a prompt has a completion event triggered (Example: clicked, held, etc)

ParameterDescription
hideoncompleteSome Options may hide or disapear when completed, Set this to false to not hide. This will default to true if nothing is entered

firstprompt:HasCompleted()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
--Show your prompt group
PromptGroup:ShowGroup("My first prompt group")
-- Lets listed for the prompt click and enact some code!
if firstprompt:HasCompleted() then
print("First Prompt Completed!")
end
end
end)

Handle Prompt Failure Events

You can trigger code when a prompt has a failure event triggered (Example: timed, mashed)

ParameterDescription
hideoncompleteSome Options may hide or disapear when completed, Set this to false to not hide. This will default to true if nothing is entered

firstprompt:HasFailed()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
--Show your prompt group
PromptGroup:ShowGroup("My first prompt group")
-- Lets listed for the prompt click and enact some code!
if firstprompt:HasCompleted() then
print("First Prompt Completed!")
end
if firstprompt:HasFailed() then
print("First Prompt Failed!")
end
end
end)

Delete Prompt

Remove a prompt completely

firstprompt:DeletePrompt()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
--Show your prompt group
PromptGroup:ShowGroup("My first prompt group")
Wait(3000)
firstprompt:DeletePrompt()
end
end)

Toggle Prompt Visibility

Make a prompt visible or hidden

ParameterDescription
toggletrue or false; true = visible, false = hidden

firstprompt:TogglePrompt(toggle)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Group
local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
while true do
Citizen.Wait(0)
--Show your prompt group
PromptGroup:ShowGroup("My first prompt group")
Wait(3000)
firstprompt:TogglePrompt(false)
end
end)

Pedestrians (Peds)

You can leverage BCCs built in function for easy spawn and manipulate in-game pedestrian entities.

Create Ped

This will spawn a pedestrian in your game world

ParameterDescription
modelhashThe hash of the model you want the ped to be
xx world position coordinate
yy world position coordinate
zz world position coordinate
headingThe heading of the ped (Which way it is facing)
locationWhere to spawn ped. (world, vehicle, mount)
safegroundShould the ped spawn in a known ok location (default true, disable for more dine accuracy of ped placement)
optionsExtra Options for the Location you select. (See Mode Options below)

Modes Options

LocationKeyOptionsexample
worldNoneNoneNone
vehiclevehiclevehicle entity{ vehicle = yourvehicle }
vehicleseatVS_ANY_PASSENGER, VS_DRIVER, VS_FRONT_RIGHT, VS_BACK_LEFT, VS_BACK_RIGHT, VS_EXTRA_LEFT_1, VS_EXTRA_RIGHT_1, VS_EXTRA_LEFT_2, VS_EXTRA_RIGHT_2, VS_EXTRA_LEFT_3, VS_EXTRA_RIGHT_3, VS_NUM_SEATS{ seat = "VS_FRONT_RIGHT" }
mountmountmount entity{ mount = yourmount }

BccUtils.Peds:Create()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false, isnetwork or false)
end)

Freeze Ped

Freeze a ped where they stand

ParameterDescription
statefreeze or unfreeze (true/false), default true

ped:Freeze()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:Freeze()
end)

Invincible Ped

Make a ped Invincible

ParameterDescription
stateInvincible (true/false), default true

ped:Invincible()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:Invincible()
end)

Ped CanBeDamaged

Make a ped not take damage

ParameterDescription
stateCanBeDamaged (true/false), default true

ped:CanBeDamaged()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:CanBeDamaged()
end)

Set Ped Heading

change the directon a ped is facing

ParameterDescription
headthe game world direction to face

ped:SetHeading()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:SetHeading(0)
end)

Set Ped Seeing Range

Change how far the ped can see

ParameterDescription
range0.0 - 100.0

ped:SeeingRange()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:SeeingRange(70.0)
end)

Set Ped Hearing Range

Change how far the ped can hear

ParameterDescription
range0.0 - 100.0

ped:HearingRange()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:HearingRange(80.0)
end)

Set Ped Can Mount

Change if a ped can mount something.

ParameterDescription
statetrue/false

ped:CanBeMounted(true)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:CanBeMounted(true)
end)

Add Ped to Group

Add ped to a group

ParameterDescription
groupindex of the group to add to

ped:AddPedToGroup(group)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:AddPedToGroup(GetPedGroupIndex(PlayerPedId()))
end)

Clear a ped task

Clear any active tasks

ped:ClearTasks()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:ClearTasks()
end)

Get Task Status

Check the status of a ped task

ped:GetTaskStatus(taskid)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
while (ped:GetTaskStatus(0x4924437d) ~= 8) do
Wait(1000)
end
print("Ped task done!")
end)

Follow to offset

Add ped to a group

ParameterDescription
pedidid of ped to follow

ped:FollowToOffsetOfEntity(pedid)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:FollowToOffsetOfEntity(PlayerPedId(), 0.0, -1.5, 0.0, 1.0, -1, 10, 1, 1)
end)

Follow to offset

Add ped to a group

ParameterDescription
skinhashhash of skin meta cloth

ped:ChangeOutfit(skinhash)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('A_C_DogBluetickCoonhound_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:ChangeOutfit(0xDC567AF8)
end)

Set Ped Blip

Set a blip on ped that follows

ParameterDescription
bliphashWhat the blip should show on the map
titleWhat the blip should say

ped:SetBlip(bliphash, title)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:SetBlip(953018525, 'Person')
end)

Give Ped Weapon

Give a ped a weapon (they will only use it if they are set to be agro)

ParameterDescription
weaponhashWhat the weapon will be
ammocounthow much ammo
forceinhandForce the weapon to be held
forceinholsterForce the weapon to be holstered
attachpointWhere to attach to the body
allowmultiplecopiesHow many of this gun can the ped have
ignoreunlocksIngore unlockables
permanentdegredationpermanent degredation

ped:GiveWeapon(weaponhash, ammocount, forceinhand, forceinholster, attachpoint, allowmultiplecopies, ignoreunlocks, permanentdegredation)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:AttackTarget(PlayerPedId())
ped:GiveWeapon(0x64356159, 500, true, true, 3, false, true, true)
end)

Set Ped Flee Attribute

Enable or disable pedestrian flee attributes

ParameterDescription
flagWhat flee attribute to enable/disable
enabledis active of not (true/false)

ped:FleeAtribute(flag, enabled)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:FleeAtribute('DISABLE_ENTER_VEHICLES', true)
end)

Set Ped Combat Attributes

Enable or disable pedestrian combat attributes

ParameterDescription
attributesThis is a list of attributes you want to change Example { {flag = 1, enabled = false}, {flag = 2, enabled = false} }
attackrangeThe distance for aggro
abilitylevelhow good or not the ped is at fighting
movementWhat kind of movement (0: Stationary (Will just stand in place), 1: Defensive (Will try to find cover and very likely to blind fire), 2: Offensive (Will attempt to charge at enemy but take cover as well), 3: Suicidal Offensive (Will try to flank enemy in a suicidal attack))

ped:SetPedCombatAttributes(attributes, attackrange, abilitylevel, movement)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:SetPedCombatAttributes({
{flag = 0, enabled = false}
}, 1, 0, 2)
end)

Set Ped Combat Style

Set the pedestrians combat style

ParameterDescription
combathashThe combat style for the ped
durationHow long the ped has this combat style

ped:SetCombatStyle(combathash, duration)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:SetCombatStyle('SituationAllStop', 240.0)
end)

Clear Ped Combat Style

Clear the pedestrians combat style

ped:ClearCombatStyle()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:ClearCombatStyle()
end)

Attack Target

Set a target for the ped to attack

ParameterDescription
targetthe ped to attack (can be player)
styleHow long the ped has this combat style (GUARD, COMBAT_ANIMAL, LAW, LAW_SHERIFF)

ped:AttackTarget(target, style)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:AttackTarget(PlayerPedId(), 'LAW')
end)

Remove Ped

Remove a Ped

ped:Remove()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
ped:Remove()
end)

Get Ped

If there are natives this util does not yet support, you can use this to get the ped to utilize against any native.

ped:GetPed()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local ped = BccUtils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
local rawped = ped:GetPed()
-- Use rawped with whatever native required the ped entity
end)

Objects

You can leverage BCCs built in function for easy spawn and manipulate in-game Object entities.

Create Object

This will spawn an object in your game world

ParameterDescription
modelhashThe hash of the model you want the ped to be
xx world position coordinate
yy world position coordinate
zz world position coordinate
headingThe heading of the ped (Which way it is facing)
networkedWhere to spawn ped. (world, vehicle, mount)
methodstandard or custom - Standard will run place on ground and a few other house keeping

BccUtils.Objects:Create()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
end)

Pickup Light

Add a light to the object

ParameterDescription
stateTrue/False

obj:PickupLight(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:PickupLight(true)
end)

Freeze

Freeze Object

ParameterDescription
stateTrue/False

obj:Freeze(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:Freeze(true)
end)

Set Heading

Set the heading of an object

ParameterDescription
headingnumber coord relative to the game world

obj:SetHeading(heading)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:SetHeading(0)
end)

Place On Ground

place the object on the groun properly

ParameterDescription
statetrue/false

obj:PlaceOnGround(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:PlaceOnGround(true)
end)

Set As Mission

The engine will keep object when players leave the area

ParameterDescription
statetrue/false

obj:SetAsMission(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:SetAsMission(true)
end)

Set As No Longer Needed

The engine will remove when players leave the area

obj:SetAsNoLongerNeeded()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:SetAsNoLongerNeeded()
end)

Invincible

Set object as invincible

ParameterDescription
statetrue/false

obj:Invincible(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:Invincible(true)
end)

Horse Jumpable

Sets object as not jumpable by horse.

ParameterDescription
statetrue/false

obj:SetNotHorseJumpable(state)

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
obj:SetNotHorseJumpable(true)
end)

Remove

Remove Object

obj:Remove()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
Wait(5000)
obj:Remove()
end)

Get Object

Remove Object

obj:GetObj()

Example Usage:

-- client side only
Citizen.CreateThread(function()
local coords = {
z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
}
local obj = BccUtils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
Wait(5000)
local tobj = obj:GetObj()
end)

DataView

A DataView utility

Example Usage:

-- client side only
local view = DataView.ArrayBuffer(512)
if Citizen.InvokeNative(0x79923CD21BECE14E, 1, view:Buffer(), Citizen.ReturnResultAnyway()) then
local dlc = {
validCheck = view:GetInt64(0),
weaponHash = view:GetInt32(8),
val3 = view:GetInt64(16),
weaponCost = view:GetInt64(24),
ammoCost = view:GetInt64(32),
ammoType = view:GetInt64(40),
defaultClipSize = view:GetInt64(48),
nameLabel = view:GetFixedString(56, 64),
descLabel = view:GetFixedString(120, 64),
simpleDesc = view:GetFixedString(184, 64),
upperCaseName = view:GetFixedString(248, 64),
}
end

Files

An easy to use file manipulation system.

Open

Open a file from a given file path

ParameterDescription
resourcenamethe string name of your resource
filepaththe path to the file you with to open or create

BccUtils.Files:Open(resourcename, filepath))

Example Usage:

-- Server side
Citizen.CreateThread(function()
local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt')
end)

Read

Read the file that you have openned.

ParameterDescription
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

file:Read(mode)

Example Usage:

-- Server side
Citizen.CreateThread(function()
local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt')
local filedata = file:Read()
end)

Save

Save data to the file that you have opened.

ParameterDescription
contentThe data you with to save to the file
modeif nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly

file:Save(content, mode)

Example Usage:

-- Server side
Citizen.CreateThread(function()
local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt')
local filedata = file:Read()
local data = "Some Awesome stuff!"
file:Save(data)
end)

Update

Instead of needing to open and save a file, you can update data directly to the file.

ParameterDescription
contentThe data you with to save to the file
modeif nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly

file:Update(content, mode)

Example Usage:

-- Server side
Citizen.CreateThread(function()
local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt')
file:Update("Some Awesome stuff!")
end)

Lazy Functions

There is a way to use these functions without needing to call the Open() function, this can be used for quick usage or prototyping, but is non-optimal and slower than the above.

Load File

Read the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

BccUtils.Files:Load(resourcename, filepath, mode)

Example Usage:

-- Server side
-- Lazy functions, not as optimized
Citizen.CreateThread(function()
local file = BccUtils.Files:Load(GetCurrentResourceName(), 'data.txt')
end)
Save File

Save the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
contentdata to save to the file
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

BccUtils.Files:Load(resourcename, filepath, mode)

Example Usage:

-- Server side
-- Lazy functions, not as optimized
Citizen.CreateThread(function()
BccUtils.Files:Save(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)
Update File

Update the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
contentdata to update to the file
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

BccUtils.Files:Update(resourcename, filepath, content, mode)

Example Usage:

-- Server side
-- Lazy functions, not as optimized
Citizen.CreateThread(function()
BccUtils.Files:Update(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)

BCC Utils provides an enhanced print functionality to the default Lua.

Features

  • Table printing support
  • ANSI Color and text formatting support

Setup

-- Server and Client
local BccUtils = {}
TriggerEvent("getUtils", function(utils)
BccUtils = utils
print = BccUtils.Print:initialize(print) --Initial setup
end)
Citizen.CreateThread(function()
--Use print as you normally would.
print('%{bold} %{red}TEST', {
hello = "world"
})
-- Print Output: TEST, { "hello" = "world"}
end)

Colors

Colors and backgrounds can be used usilizing the %{attribute} format

TypeformatDescription
Text Format%{bold}Make Text Font weight heavier
Text Color%{reset}Set back to default color
Text Color%{red}
Text Color%{green}
Text Color%{orange}
Text Color%{navy}
Text Color%{magenta} or %{purple}
Text Color%{cyan}
Text Color%{gray} or %{grey}
Text Color%{lightgray} or %{lightgrey}
Text Color%{peach}
Text Color%{lightgreen}
Text Color%{yellow}
Text Color%{blue}
Text Color%{pink}
Text Color%{babyblue}
Background Color%{highlight red}
Background Color%{highlight green}
Background Color%{highlight orange}
Background Color%{highlight navy}
Background Color%{highlight magenta}
Background Color%{highlight cyan}
Background Color%{highlight gray} or %{highlight grey}
Background Color%{highlight lightgray} or %{highlight lightgrey}
Background Color%{highlight peach}
Background Color%{highlight lightgreen}
Background Color%{highlight yellow}
Background Color%{highlight blue}
Background Color%{highlight pink}
Background Color%{highlight babyblue}

Example Usage:

print('%{blue}moon over the rainbow')

image

Advanced Classes

Many Programming languages, including Lua, provide a method to use a programing methedology called classes.

Lua, unfortunately does this in a way that is very non-standard to other languages, and can make it a bit confusing for some. This is an attempt to make it more in-line with other languages.

Benefits

Classes are nice for developers as it allows you to have a single, contained context (self) for the class to utilize.

Example Usage:

-- Server and Client
Citizen.CreateThread(function()
local myClass = BccUtils.General:CreateClass(function(setup, register)
-- Setup is a constructor, meaning it is used to setup your default variables than can then be used in the following fuctions.
setup({
message = "Initial Text"
})
-- return the functions that you wish to register to the class.
return {
ChangeText = function(self, t) --This can now be called anywhere as myClass:ChangeText(t)
-- self is always in the first paramater above, this is required to manipulate the setup data.
self.message = t
end,
GetText = function(self) --This can now be called anywhere as myClass:GetText()
return self.message
end
}
end)
print(myClass:GetText()) -- Prints: Initial Text
myClass:ChangeText('HELLO WORLD!')
print(myClass:GetText()) -- Prints: HELLO WORLD!
end

Destruction

Objects (ymaps) can have built in destruction thanks to the engines use of RayFire, which is a tool for dynamic destruction.

This allows for things like like bank walls being blown out, railroad bridge blown up, trees falling over, etc.

Note that they are not networked and you'll need to sync clients manually.

Get Destruction Object

Get nearby RawFire map Objects

ParameterDescription
xin-game x coordinate
yin-game y coordinate
zin-game z coordinate
radiusthe radius from the coordinate
objectnamedestruction object name with RayFire attached

BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')

Example Usage:

-- Client
RegisterCommand('trigger', function()
local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
end)

Check if the Destruction Object Exists

Check if the RayFire Destruction Object exists.

object:DoesExist()

Example Usage:

-- Client
RegisterCommand('trigger', function()
local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
if object:DoesExist() then
--Exists!
end
end)

Reset State

Reset the RayFire Destruction Objects state.

object:resetState()

Example Usage:

-- Client
RegisterCommand('trigger', function()
local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
if object:DoesExist() then
object:resetState()
end
end)

Reset State

Reset the RayFire Destruction Objects state.

ParameterDescription
statethe state of the object. (6 will trigger most objects)

object:resetState()

Example Usage:

-- Client
RegisterCommand('trigger', function()
local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
if object:DoesExist() then
object:resetState()
Wait(3000)
object:SetState(6)
end
end)

Render

Render is an API to help with in-world and on screen drawing. (Text, Sprites, etc.)

WorldToScreen

Converts an in-world coordinate to a screen position

ParameterDescription
pos (vector3)in-world position

Returns vector 2 screen coords.

Returns Bool if its on screen

object:WorldToScreen(vector3(x, y, z))

Example Usage:

-- Client
RegisterCommand('trigger', function()
local coords, onscreen = BccUtils.Render:WorldToScreen(GetEntityCoords(PlayerPedId()))
print(coords.x, coords.y, onscreen)
end)

WorldToHud

Converts in-world coordinate to a hud position (bounded to screen)

ParameterDescription
pos (vector3)in-world position

Returns vector 2 screen coords

Returns Bool if its on screen

object:WorldToHud(vector3(x, y, z))

Example Usage:

-- Client
RegisterCommand('trigger', function()
local coords, onscreen = BccUtils.Render:WorldToHud(GetEntityCoords(PlayerPedId()))
print(coords.x, coords.y, onscreen)
end)

DrawSprite

Draw Sprites on screen

ParameterDescription
pos (vector2)table containing x and y coords of sprite position on screen
size (vector2)table containing x and y sizes (relative to screen x and y size, ranges from 0.0-1.0)
rotation (float)number of sprite rotation in degrees
color (vector3)table of rgba values
texturedictName of texture dictionary to load texture from (e.g. "CommonMenu", "MPWeaponsCommon", etc.)
texturenameName of texture to load from texture dictionary (e.g. "last_team_standing_icon", "tennis_icon", etc.)

BccUtils.Render:DrawSprite(pos, size, rotation, color, texturedict, texturename)

Example Usage:

-- Client
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
if onScreen then
BccUtils.Render:DrawSprite(vector2(_x, _y), vector2(0.2, 0.2), 190.0, {r: 255, g: 0, b: 0, a: 255}, "feeds", "hud_menu_4a")
end
end
end)

Draw Rectangle

Draw a rectangle on screen

ParameterDescription
pos (vector2)table containing x and y coords of sprite position on screen (ranges from 0.0-1.0)
size (vector2)table containing x and y sizes (ranges from 0.0-1.0)
color (vector3)table of rgba values

BccUtils.Render:DrawRectangle(pos, size, color)

Example Usage:

-- Client
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
if onScreen then
BccUtils.Render:DrawRectangle(vector2(_x, _y), vector2(0.2, 0.2), {r: 255, g: 0, b: 0, a: 255})
end
end
end)

Draw Marker

Draw a Marker in-world

ParameterDescription
type
postable containing x y and z coords
dirtable containing x y and z coords
rotrotation of the marker
scaletable containing x y and z scale
colortable of rgba values
bobupanddowndoes it bounce (true/false)
facecamerashould it face the camera (true/false)
rotatedoes the marker rotate (true/false)
drawonents(true/false)

BccUtils.Render:DrawMarker(type, pos, dir, rot, scale, color, bob, facevamera, rotate, drawonents)

Example Usage:

-- Client
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
BccUtils.Render:DrawMarker(0x50638AB9, GetEntityCoords(PlayerPedId()), vector3(0.0, 0.0, 0.0), vector3(0.0, 0.0, 0.0), vecotr3(0.15, 0.15, 0.15), {r: 255, g: 0, b: 0, a: 255}, false, false, false, false)
end
end)

Draw Text

Draw a Text on screen

ParameterDescription
postable containing x and y coords of text position (0-1, 0-1)
texttable containing x y and z coords
colortable of rgba values
scalescale of the text
shadowif shadow is enabled (true/false)

BccUtils.Render:DrawText(pos, text, color, scale, shadow)

Example Usage:

-- Client
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
if onScreen then
BccUtils.Render:DrawText(vector2(_x, _y), 'BCC Rules!', {r: 255, g: 0, b: 0, a: 255}, 1.0, false)
end
end
end)

Game Events

BCC Utils has a built-in network and entity event watcher that can be utilized by other scripts easily.

Register Event Listener

Register a callback that will be triggered whenever an in-game client event triggers.

ParameterDescription
eventnamename of the event to watch/listen to
callbackfucntion to be triggered when an event is triggered

BccUtils.Events:RegisterEventListener(eventname, callback)

Example Usage:

-- Client
Citizen.CreateThread(function()
BccUtils.Events:RegisterEventListener('EVENT_PICKUP_CARRIABLE', function(args)
print("EVENT TRIGGERED: EVENT_PICKUP_CARRIABLE", args[1], args[2])
end)
end)

Remove Event Listener

Removes an event from the listener queue, listener will no longer listen once removed. This frees up in-game memory andis best practice if using listeners in a dynamic, or temporary way.

ParameterDescription
listenerobject returns from RegisterEventListener

BccUtils.Events:RenoveEventListener(listener)

Example Usage:

-- Client
Citizen.CreateThread(function()
local listener = BccUtils.Events:RegisterEventListener('EVENT_PICKUP_CARRIABLE', function(args)
print("EVENT TRIGGERED: EVENT_PICKUP_CARRIABLE", args[1], args[2])
end)
Wait(40000)
BccUtils.Events:RenoveEventListener(listener)
end)

DevMode

This provides the ability to print every in-game event for development purpose.

ParameterDescription
stateobject returns from RegisterEventListener
type(optional, will default to all) the type of event to listen too (entities, network, or all)

BccUtils.Events:DevMode(listener)

Example Usage:

-- Client
Citizen.CreateThread(function()
BccUtils.Events:DevMode(true, 'entities')
-- BccUtils.Events:DevMode(true, 'network')
end)

Audio Player Documentation

  • To play audio from youtube in your code! (This is not network synces, client specific)
function playsound()
BccUtils.YtAudioPlayer.PlayAudio(embedlink , videoid, volume, looped)
end
--Filled out example
function playsound()
BccUtils.YtAudioPlayer.PlayAudio("https://www.youtube.com/embed/TMeP3kI_2ng" , "TMeP3kI_2ng", 50, 0)
end
-- To Stop Audio
function stopaudio()
BccUtils.YtAudioPlayer.StopAudio()
end
  • Make sure you stop all audio before trying to play a new bit of audio!

Versioner Documentation

Create a Release and tag with the version number

Correct: 1.0.0

Wrong: v1.1.0

Add the following contents to your lua server

local repo = 'https://github.com/BryceCanyonCounty/bcc-anticheat'
BccUtils.Versioner.checkRelease(GetCurrentResourceName(), repo)
  • Github File Based Checks

Create a file called version with the following contents

<1.3> - More awesome updates <1.1> - Some awesome updates <1.0> - My first Update

Add the following contents to your lua server

local repo = 'https://github.com/BryceCanyonCounty/bcc-anticheat'
BccUtils.Versioner.checkFile(GetCurrentResourceName(), repo)

Discord Webhooks

This API allows you to easily add Discord webhooks messages to your scripts.

Send One Time Message

-- (webhookurl, webhookname, webhookavatar, name, description, embeds)
BccUtils.Discord.sendMessage('webhookurl', 'My Script', 'https://cdn2.iconfinder.com/data/icons/frosted-glass/256/Danger.png', 'user123', 'this user is awesome')

Create Discord Re-usable instance

-- (webhookurl, webhookname, webhookavatar)
local discord = BccUtils.Discord.setup('webhookurl', 'My Script', 'https://cdn2.iconfinder.com/data/icons/frosted-glass/256/Danger.png')
-- (name, description, embeds)
discord:sendMessage('user123', 'this user is awesome')
discord:sendMessage('user456', 'this user is ALSO awesome')
discord:sendMessage('user789', 'this user kinda really awesome', {
{
color = 11342935,
title = 'Embed Item 1',
description = 'Items awesome description?'
},
{
color = 11342935,
title = 'Embed Item 2',
description = 'Item 2 awesome description!'
},
})

Custom Embeds

Add custom embeds

-- (webhookurl, webhookname, webhookavatar, name, description, embeds)
BccUtils.Discord.sendMessage('webhookurl', 'My Script', 'https://cdn2.iconfinder.com/data/icons/frosted-glass/256/Danger.png', 'user123', 'this user is awesome'{
{
{
color = 11342935,
title = 'some times',
description = 'awesomesauce'
},
{
color = 11342935,
title = 'some other time',
description = 'awesomesauce'
},
}
})

Misc API

DrawText3D

BccUtils.Misc.DrawText3D(x, y, z, 'your text')

Distance Check for an entity

-- This will detect the distance between the entity and the x,y,z coords and when you are within the set dist it will break the loop
BccUtils.Misc.DistanceCheckEntity(x, y, z, entity, dist, usez)

Set GPS Waypoin

--This will place a gps waypoint on the players map to the coords set
BccUtils.Misc.SetGps(x, y, z)

Remove GPS Waypoint

BccUtils.Misc.RemoveGps()