Reward Configuration
This docs page relates to the following scripts:
These scripts use the same configuration but not sky_base functions. Some things mentioned here wont apply there.
It applies not to Coinsystem V1
Overviewβ
The reward system in the sky_base
library is a flexible and extensible system used to manage various types of rewards in our framework. This system is utilized by almost all of our scripts, allowing for consistent and easy reward management. Below, we explain the different types of rewards supported and provide examples of how they are used in practice.
Reward Propertiesβ
Each reward configuration consists of the following properties:
- label: The label for the reward, shown in the UI.
- sort: The type of the reward.
- name: The item name as in the database, model name if a vehicle, or model name if a weapon.
- amount: The amount of the reward. If
sort
is weapon, this is the amount of ammo. - img: The image file name for the reward without
.png
.
Reward Typesβ
The reward system supports several types of rewards, each identified by a sort
value:
Itemβ
-
Description: Grants an item to the player.
-
Usage: The item name should be the same as used in the database.
-
Example:
{
label = "Bulletproof Vest",
sort = "item",
name = "bulletproof",
amount = 1,
img = "box"
} -
Source Code: Sky.FW.AddItem in sky_base/config/framework/*.lua
Weaponβ
- Description: Grants a weapon to the player. Only applicable if the framework is
esx
. If you are using qbcore or another system that sees weapons as an item, use theitem
type instead. - Usage: Amount is the amount of ammo in this case.
- Example:
{
label = "Combat Pistol",
sort = "weapon",
name = "weapon_combatpistol",
amount = 100, -- amount of ammo in this case
img = "pistol"
}
Bankβ
-
Description: Adds money to the player's bank account.
-
Example:
{
label = "15.000$",
sort = "bank",
name = "",
amount = 15000,
img = "cash"
} -
Source Code: Sky.FW.AddAccountMoney in sky_base/config/framework/*.lua
Cashβ
-
Description: Adds cash to the player's hand (wallet).
-
Example:
{
label = "5.000$",
sort = "cash",
name = "",
amount = 5000,
img = "cash"
} -
Source Code: Sky.FW.AddAccountMoney in sky_base/config/framework/*.lua
Accountβ
-
Description: Adds money to a specific account type.
-
Example:
{
label = "Black Money",
sort = "account",
name = "black_money",
amount = 2000,
img = "black_money_image"
} -
Source Code: Sky.FW.AddAccountMoney in sky_base/config/framework/*.lua
Vehicleβ
-
Description: Grants a vehicle to the player.
-
Usage: The reward should specify the vehicle model name and the image name.
-
Example:
{
label = "Mercedes-AMG GT 2021",
sort = "vehicle",
name = "t20",
amount = 1,
img = "car"
} -
Source Code: Functions.GiveVehicle in sky_base/config/sv_functions.lua
Coinsβ
- Description: Grants coins to the player using the
sky_coinsystem
. - Usage: The reward should specify the amount of coins to be given and the image name.
- Example:
{
label = "10 Coins",
sort = "coins",
name = "",
amount = 10,
img = "coins"
} - Note: The
sky_coinsystem
must be started for this reward type to work. If it is not started, an error will be printed.
Customβ
-
Description: Allows for the creation of custom reward types by using the
Functions.GiveCustomReward
function. -
Usage: Custom rewards can be created in the
sky_base/config/sv_functions.lua
file. -
Example:
{
label = "Husky",
sort = "pet",
name = "husky_pet",
amount = 1,
img = "cute_husky"
} -
Code example
-- default reward table keys = label, sort, name, amount, img
function Functions.GiveCustomReward(source, reward)
-- Example code
if reward.sort == "pet" then
exports["some_petscript"]:GivePet(source, reward.name, reward.amount)
end
end -
Source Code: Functions.GiveCustomReward in sky_base/config/sv_functions.lua