Usage Examples
Usage Examples
Server-side Example
-- Example script to add reputation XP for mining
local playerId = 1
local category = 'mining'
local amount = 50
-- Add XP (single character)
exports['b2_reputation']:addReputationXPSingle(playerId, category, amount)
-- Add XP (multi-character)
exports['b2_reputation']:addReputationXPMulti(playerId, category, amount)
-- Get XP
local xpSingle = exports['b2_reputation']:getReputationXPSingle(playerId, category)
local xpMulti = exports['b2_reputation']:getReputationXPMulti(playerId, category)
-- Calculate reputation level
local levelSingle = exports['b2_reputation']:calculateReputationLevel(playerId, category)
local levelMulti = exports['b2_reputation']:calculateReputationLevel(playerId, category)
print("Single Character - XP: ", xpSingle, "Level: ", levelSingle)
print("Multi Character - XP: ", xpMulti, "Level: ", levelMulti)Client-side Example
Since the exports are server-side, you would typically call them from the server and handle client notifications or updates accordingly.
Initializing Player Data
To ensure player data is initialized correctly on first connection, make sure the following event handler is included. This is included in the b2_reputation system, so there should be no need for you to use it anywhere else:
Absolutely! Let's expand on how to integrate a new reputation category into the B2 Reputation System, including updating the SQL table and the config.lua file.
Integrating A New Reputation
Step 1: Add the Reputation to the SQL Table
Depending on your framework and whether you're using a single-character or multi-character setup, you will need to modify the appropriate SQL table. Hereβs how to do it:
Single Character
To add a new reputation category, let's say "hunting", to the SQL table:
Multi Character
Step 2: Add the Reputation to the Config.lua File
Next, you need to add the new reputation category to the config.lua file with the XP required for each level.
Here is an example of adding a new "hunting" reputation category:
Example Usage
Here's an example of how to use the new "hunting" reputation category in a script.
Server-side Example
By following these steps, you can seamlessly add new reputation categories to the B2 Reputation System. If you need further customization or assistance, feel free to ask!
Last updated