A RedM standalone Development API system.
local BccUtils = {}TriggerEvent('bcc:getUtils', function(bccutils) BccUtils = bccutilsend)
OR
BccUtils = exports['bcc-utils'].initiate()
You can leverage BCCs built in function for map blips.
Create a marker (blip) on the players map
Parameter | Description |
---|---|
text | What the blip will display on the map |
bliphash | The hashname of the blip (found here) |
scale | How big the blip is |
x | The x coordinate in the game world |
y | The y coordinate in the game world |
z | The z coordinate in the game world |
vector3 | instead of params send whole vector3 just add nil to x y z |
Example Usage:
-- client side onlyCitizen.CreateThread(function() local blip = BccUtils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z, vector3 or nil)end)
Add a modifier to a blip, which can change its appearance or behavior.
-- client side onlyCitizen.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)
If you want to use any natives that are not yet included, you can utilize the raw blip.
-- client side onlyCitizen.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 marker (blip) on the players map
-- client side onlyCitizen.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)
Create a Radius blip
Parameter | Description |
---|---|
radius | A decimal radius |
bliphahashsh | The hashname of the blip (found here) Optional, will default to -1282792512 |
Example Usage:
-- client side onlyCitizen.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)
You can leverage BCCs built in function for easy in-game prompts.
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 onlyCitizen.CreateThread(function() local PromptGroup = BccUtils.Prompt:SetupPromptGroup() --Setup Prompt Groupend)
Once you have the Prompt Group setup, you can now register a prompt to display within the group.
Parameter | Description |
---|---|
title | What the Prompt group will display next to the press button |
button | The hash key |
enabled | If 0 you cannot click, if 1 you can click |
visible | If 0 you cannot see the prompt, if 1 you can see the group |
pulsing | If true prompt will urgently pulse, if false it will not |
mode | What kind of prompt. (Options: click, hold, customhold, mash, timed) |
options | Extra Options for the Mode you select. (See Mode Options below) |
Modes Options
Mode | Key | Options | example |
---|---|---|---|
click | None | None | None |
hold | timedeventhash | SHORT_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" } |
customhold | holdtime | Miliseconds | { holdtime = 3000 } |
mash | mashamount | > 0 | { mashamount = 20 } |
timed | depletiontime | Miliseconds | { depletiontime = 10000} |
PromptGroup:RegisterPrompt(title, button, enabled, visible, pulsing, mode, options)
Example Usage:
-- client side onlyCitizen.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) endend)
Now that you have a Group setup and a registered Prompt, you can now display the group!
Parameter | Description |
---|---|
text | Text to display under all the prompts |
PromptGroup:ShowGroup(text)
Example Usage:
-- client side onlyCitizen.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 endend)
You can trigger code when a prompt has a completion event triggered (Example: clicked, held, etc)
Parameter | Description |
---|---|
hideoncomplete | Some 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 onlyCitizen.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 endend)
You can trigger code when a prompt has a failure event triggered (Example: timed, mashed)
Parameter | Description |
---|---|
hideoncomplete | Some 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 onlyCitizen.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 endend)
Remove a prompt completely
firstprompt:DeletePrompt()
Example Usage:
-- client side onlyCitizen.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() endend)
Make a prompt visible or hidden
Parameter | Description |
---|---|
toggle | true or false; true = visible, false = hidden |
firstprompt:TogglePrompt(toggle)
Example Usage:
-- client side onlyCitizen.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) endend)
You can leverage BCCs built in function for easy spawn and manipulate in-game pedestrian entities.
This will spawn a pedestrian in your game world
Parameter | Description |
---|---|
modelhash | The hash of the model you want the ped to be |
x | x world position coordinate |
y | y world position coordinate |
z | z world position coordinate |
heading | The heading of the ped (Which way it is facing) |
location | Where to spawn ped. (world, vehicle, mount) |
safeground | Should the ped spawn in a known ok location (default true, disable for more dine accuracy of ped placement) |
options | Extra Options for the Location you select. (See Mode Options below) |
Modes Options
Location | Key | Options | example |
---|---|---|---|
world | None | None | None |
vehicle | vehicle | vehicle entity | { vehicle = yourvehicle } |
vehicle | seat | VS_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" } |
mount | mount | mount entity | { mount = yourmount } |
BccUtils.Peds:Create()
Example Usage:
-- client side onlyCitizen.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 a ped where they stand
Parameter | Description |
---|---|
state | freeze or unfreeze (true/false), default true |
ped:Freeze()
Example Usage:
-- client side onlyCitizen.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)
Make a ped Invincible
Parameter | Description |
---|---|
state | Invincible (true/false), default true |
ped:Invincible()
Example Usage:
-- client side onlyCitizen.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)
Make a ped not take damage
Parameter | Description |
---|---|
state | CanBeDamaged (true/false), default true |
ped:CanBeDamaged()
Example Usage:
-- client side onlyCitizen.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)
change the directon a ped is facing
Parameter | Description |
---|---|
head | the game world direction to face |
ped:SetHeading()
Example Usage:
-- client side onlyCitizen.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)
Change how far the ped can see
Parameter | Description |
---|---|
range | 0.0 - 100.0 |
ped:SeeingRange()
Example Usage:
-- client side onlyCitizen.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)
Change how far the ped can hear
Parameter | Description |
---|---|
range | 0.0 - 100.0 |
ped:HearingRange()
Example Usage:
-- client side onlyCitizen.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)
Change if a ped can mount something.
Parameter | Description |
---|---|
state | true/false |
ped:CanBeMounted(true)
Example Usage:
-- client side onlyCitizen.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 a group
Parameter | Description |
---|---|
group | index of the group to add to |
ped:AddPedToGroup(group)
Example Usage:
-- client side onlyCitizen.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 any active tasks
ped:ClearTasks()
Example Usage:
-- client side onlyCitizen.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)
Check the status of a ped task
ped:GetTaskStatus(taskid)
Example Usage:
-- client side onlyCitizen.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)
Add ped to a group
Parameter | Description |
---|---|
pedid | id of ped to follow |
ped:FollowToOffsetOfEntity(pedid)
Example Usage:
-- client side onlyCitizen.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)
Add ped to a group
Parameter | Description |
---|---|
skinhash | hash of skin meta cloth |
ped:ChangeOutfit(skinhash)
Example Usage:
-- client side onlyCitizen.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 a blip on ped that follows
Parameter | Description |
---|---|
bliphash | What the blip should show on the map |
title | What the blip should say |
ped:SetBlip(bliphash, title)
Example Usage:
-- client side onlyCitizen.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 a ped a weapon (they will only use it if they are set to be agro)
Parameter | Description |
---|---|
weaponhash | What the weapon will be |
ammocount | how much ammo |
forceinhand | Force the weapon to be held |
forceinholster | Force the weapon to be holstered |
attachpoint | Where to attach to the body |
allowmultiplecopies | How many of this gun can the ped have |
ignoreunlocks | Ingore unlockables |
permanentdegredation | permanent degredation |
ped:GiveWeapon(weaponhash, ammocount, forceinhand, forceinholster, attachpoint, allowmultiplecopies, ignoreunlocks, permanentdegredation)
Example Usage:
-- client side onlyCitizen.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)
Enable or disable pedestrian flee attributes
Parameter | Description |
---|---|
flag | What flee attribute to enable/disable |
enabled | is active of not (true/false) |
ped:FleeAtribute(flag, enabled)
Example Usage:
-- client side onlyCitizen.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)
Enable or disable pedestrian combat attributes
Parameter | Description |
---|---|
attributes | This is a list of attributes you want to change Example { {flag = 1, enabled = false}, {flag = 2, enabled = false} } |
attackrange | The distance for aggro |
abilitylevel | how good or not the ped is at fighting |
movement | What 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 onlyCitizen.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 the pedestrians combat style
Parameter | Description |
---|---|
combathash | The combat style for the ped |
duration | How long the ped has this combat style |
ped:SetCombatStyle(combathash, duration)
Example Usage:
-- client side onlyCitizen.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 the pedestrians combat style
ped:ClearCombatStyle()
Example Usage:
-- client side onlyCitizen.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)
Set a target for the ped to attack
Parameter | Description |
---|---|
target | the ped to attack (can be player) |
style | How long the ped has this combat style (GUARD, COMBAT_ANIMAL, LAW, LAW_SHERIFF) |
ped:AttackTarget(target, style)
Example Usage:
-- client side onlyCitizen.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 a Ped
ped:Remove()
Example Usage:
-- client side onlyCitizen.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)
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 onlyCitizen.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 entityend)
You can leverage BCCs built in function for easy spawn and manipulate in-game Object entities.
This will spawn an object in your game world
Parameter | Description |
---|---|
modelhash | The hash of the model you want the ped to be |
x | x world position coordinate |
y | y world position coordinate |
z | z world position coordinate |
heading | The heading of the ped (Which way it is facing) |
networked | Where to spawn ped. (world, vehicle, mount) |
method | standard or custom - Standard will run place on ground and a few other house keeping |
BccUtils.Objects:Create()
Example Usage:
-- client side onlyCitizen.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)
Add a light to the object
Parameter | Description |
---|---|
state | True/False |
obj:PickupLight(state)
Example Usage:
-- client side onlyCitizen.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 Object
Parameter | Description |
---|---|
state | True/False |
obj:Freeze(state)
Example Usage:
-- client side onlyCitizen.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 the heading of an object
Parameter | Description |
---|---|
heading | number coord relative to the game world |
obj:SetHeading(heading)
Example Usage:
-- client side onlyCitizen.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 the object on the groun properly
Parameter | Description |
---|---|
state | true/false |
obj:PlaceOnGround(state)
Example Usage:
-- client side onlyCitizen.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)
The engine will keep object when players leave the area
Parameter | Description |
---|---|
state | true/false |
obj:SetAsMission(state)
Example Usage:
-- client side onlyCitizen.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)
The engine will remove when players leave the area
obj:SetAsNoLongerNeeded()
Example Usage:
-- client side onlyCitizen.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)
Set object as invincible
Parameter | Description |
---|---|
state | true/false |
obj:Invincible(state)
Example Usage:
-- client side onlyCitizen.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)
Sets object as not jumpable by horse.
Parameter | Description |
---|---|
state | true/false |
obj:SetNotHorseJumpable(state)
Example Usage:
-- client side onlyCitizen.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 Object
obj:Remove()
Example Usage:
-- client side onlyCitizen.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)
Remove Object
obj:GetObj()
Example Usage:
-- client side onlyCitizen.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)
A DataView utility
Example Usage:
-- client side onlylocal 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
An easy to use file manipulation system.
Open a file from a given file path
Parameter | Description |
---|---|
resourcename | the string name of your resource |
filepath | the path to the file you with to open or create |
BccUtils.Files:Open(resourcename, filepath))
Example Usage:
-- Server sideCitizen.CreateThread(function() local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt')end)
Read the file that you have openned.
Parameter | Description |
---|---|
mode | if 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 sideCitizen.CreateThread(function() local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt') local filedata = file:Read()end)
Save data to the file that you have opened.
Parameter | Description |
---|---|
content | The data you with to save to the file |
mode | if 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 sideCitizen.CreateThread(function() local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt') local filedata = file:Read() local data = "Some Awesome stuff!" file:Save(data)end)
Instead of needing to open and save a file, you can update data directly to the file.
Parameter | Description |
---|---|
content | The data you with to save to the file |
mode | if 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 sideCitizen.CreateThread(function() local file = BccUtils.Files:Open(GetCurrentResourceName(), 'data.txt') file:Update("Some Awesome stuff!")end)
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.
Read the file that you have openned.
Parameter | Description |
---|---|
resourcename | Name of the resource |
filepath | path to the file you with to load |
mode | if 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 optimizedCitizen.CreateThread(function() local file = BccUtils.Files:Load(GetCurrentResourceName(), 'data.txt')end)
Save the file that you have openned.
Parameter | Description |
---|---|
resourcename | Name of the resource |
filepath | path to the file you with to load |
content | data to save to the file |
mode | if 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 optimizedCitizen.CreateThread(function() BccUtils.Files:Save(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")end)
Update the file that you have openned.
Parameter | Description |
---|---|
resourcename | Name of the resource |
filepath | path to the file you with to load |
content | data to update to the file |
mode | if 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 optimizedCitizen.CreateThread(function() BccUtils.Files:Update(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")end)
BCC Utils provides an enhanced print
functionality to the default Lua.
-- Server and Clientlocal 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 and backgrounds can be used usilizing the %{attribute}
format
Type | format | Description |
---|---|---|
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')
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.
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 ClientCitizen.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
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 nearby RawFire map Objects
Parameter | Description |
---|---|
x | in-game x coordinate |
y | in-game y coordinate |
z | in-game z coordinate |
radius | the radius from the coordinate |
objectname | destruction object name with RayFire attached |
BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
Example Usage:
-- ClientRegisterCommand('trigger', function() local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')end)
Check if the RayFire Destruction Object exists.
object:DoesExist()
Example Usage:
-- ClientRegisterCommand('trigger', function() local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff') if object:DoesExist() then --Exists! endend)
Reset the RayFire Destruction Objects state.
object:resetState()
Example Usage:
-- ClientRegisterCommand('trigger', function() local object = BccUtils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff') if object:DoesExist() then object:resetState() endend)
Reset the RayFire Destruction Objects state.
Parameter | Description |
---|---|
state | the state of the object. (6 will trigger most objects) |
object:resetState()
Example Usage:
-- ClientRegisterCommand('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) endend)
Render is an API to help with in-world and on screen drawing. (Text, Sprites, etc.)
Converts an in-world coordinate to a screen position
Parameter | Description |
---|---|
pos (vector3) | in-world position |
Returns vector 2 screen coords.
Returns Bool if its on screen
object:WorldToScreen(vector3(x, y, z))
Example Usage:
-- ClientRegisterCommand('trigger', function() local coords, onscreen = BccUtils.Render:WorldToScreen(GetEntityCoords(PlayerPedId())) print(coords.x, coords.y, onscreen)end)
Converts in-world coordinate to a hud position (bounded to screen)
Parameter | Description |
---|---|
pos (vector3) | in-world position |
Returns vector 2 screen coords
Returns Bool if its on screen
object:WorldToHud(vector3(x, y, z))
Example Usage:
-- ClientRegisterCommand('trigger', function() local coords, onscreen = BccUtils.Render:WorldToHud(GetEntityCoords(PlayerPedId())) print(coords.x, coords.y, onscreen)end)
Draw Sprites on screen
Parameter | Description |
---|---|
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 |
texturedict | Name of texture dictionary to load texture from (e.g. "CommonMenu", "MPWeaponsCommon", etc.) |
texturename | Name 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:
-- ClientCitizen.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 endend)
Draw a rectangle on screen
Parameter | Description |
---|---|
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:
-- ClientCitizen.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 endend)
Draw a Marker in-world
Parameter | Description |
---|---|
type | |
pos | table containing x y and z coords |
dir | table containing x y and z coords |
rot | rotation of the marker |
scale | table containing x y and z scale |
color | table of rgba values |
bobupanddown | does it bounce (true/false) |
facecamera | should it face the camera (true/false) |
rotate | does the marker rotate (true/false) |
drawonents | (true/false) |
BccUtils.Render:DrawMarker(type, pos, dir, rot, scale, color, bob, facevamera, rotate, drawonents)
Example Usage:
-- ClientCitizen.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) endend)
Draw a Text on screen
Parameter | Description |
---|---|
pos | table containing x and y coords of text position (0-1, 0-1) |
text | table containing x y and z coords |
color | table of rgba values |
scale | scale of the text |
shadow | if shadow is enabled (true/false) |
BccUtils.Render:DrawText(pos, text, color, scale, shadow)
Example Usage:
-- ClientCitizen.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 endend)
BCC Utils has a built-in network and entity event watcher that can be utilized by other scripts easily.
Register a callback that will be triggered whenever an in-game client event triggers.
Parameter | Description |
---|---|
eventname | name of the event to watch/listen to |
callback | fucntion to be triggered when an event is triggered |
BccUtils.Events:RegisterEventListener(eventname, callback)
Example Usage:
-- ClientCitizen.CreateThread(function() BccUtils.Events:RegisterEventListener('EVENT_PICKUP_CARRIABLE', function(args) print("EVENT TRIGGERED: EVENT_PICKUP_CARRIABLE", args[1], args[2]) end)end)
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.
Parameter | Description |
---|---|
listener | object returns from RegisterEventListener |
BccUtils.Events:RenoveEventListener(listener)
Example Usage:
-- ClientCitizen.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)
This provides the ability to print every in-game event for development purpose.
Parameter | Description |
---|---|
state | object 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:
-- ClientCitizen.CreateThread(function() BccUtils.Events:DevMode(true, 'entities') -- BccUtils.Events:DevMode(true, 'network')end)
function playsound() BccUtils.YtAudioPlayer.PlayAudio(embedlink , videoid, volume, looped)end--Filled out examplefunction playsound() BccUtils.YtAudioPlayer.PlayAudio("https://www.youtube.com/embed/TMeP3kI_2ng" , "TMeP3kI_2ng", 50, 0)end-- To Stop Audiofunction stopaudio() BccUtils.YtAudioPlayer.StopAudio()end
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)
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)
This API allows you to easily add Discord webhooks messages to your scripts.
-- (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')
-- (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!' },})
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' }, }})
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 loopBccUtils.Misc.DistanceCheckEntity(x, y, z, entity, dist, usez)
Set GPS Waypoin
--This will place a gps waypoint on the players map to the coords setBccUtils.Misc.SetGps(x, y, z)
Remove GPS Waypoint
BccUtils.Misc.RemoveGps()