The RSG Framework includes a built-in reputation system that allows you to track player progress, achievements, and standing across various activities. The system is completely flexible - you can create any reputation types you need for your server, from hunting skills to lawman standing.Version: 2.3.6+
Reputation is stored in player metadata and persists across sessions. Create unlimited custom reputation types!
Get the current reputation points for a specific type.
Copy
Player.Functions.GetRep(rep)
Parameters:
rep (string) - Reputation type name
Returns:
number - Current reputation points (returns 0 if type doesn’t exist)
Example:
Copy
-- SERVER SIDElocal Player = RSGCore.Functions.GetPlayer(source)-- Get hunting reputationlocal huntingRep = Player.Functions.GetRep('hunting')print('Player has '.. huntingRep ..' hunting reputation')-- Check if player meets requirementlocal requiredRep = 100if Player.Functions.GetRep('fishing') >= requiredRep then print('Player is a master fisherman!')end-- Get non-existent reputation typelocal unknownRep = Player.Functions.GetRep('nonexistent')-- Returns: 0 (safe to use without checks)
-- SERVER SIDE-- Award reputation based on pelt qualityRegisterNetEvent('hunting:server:sellPelt', function(peltType, quality) local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local repGain = 0 local basePrice = 10 -- Quality affects reputation gain if quality == 'perfect' then repGain = 5 basePrice = basePrice * 1.5 elseif quality == 'good' then repGain = 3 basePrice = basePrice * 1.2 elseif quality == 'poor' then repGain = 1 basePrice = basePrice * 0.8 end -- Get current hunting reputation local huntingRep = Player.Functions.GetRep('hunting') -- Bonus payment based on reputation local repBonus = math.floor(huntingRep / 10) -- 1% per 10 rep local finalPrice = math.floor(basePrice * (1 + repBonus / 100)) -- Award money and reputation Player.Functions.AddMoney('cash', finalPrice, 'pelt-sale') Player.Functions.AddRep('hunting', repGain) -- Check for reputation milestones local newRep = Player.Functions.GetRep('hunting') if newRep >= 100 and huntingRep < 100 then TriggerClientEvent('ox_lib:notify', src, { title = 'Master Hunter', description = 'You have become a Master Hunter!', type = 'success', duration = 10000 }) end TriggerClientEvent('ox_lib:notify', src, { description = 'Sold '.. quality ..' pelt for $'.. finalPrice ..' (+' .. repGain ..' hunting rep)', type = 'success' })end)
-- SERVER SIDE-- Arrest increases lawman rep, decreases outlaw repRegisterNetEvent('police:server:arrestPlayer', function(targetId) local src = source local Officer = RSGCore.Functions.GetPlayer(src) local Criminal = RSGCore.Functions.GetPlayer(targetId) if not Officer or not Criminal then return end -- Check officer is law enforcement if Officer.PlayerData.job.type ~= 'leo' then return end -- Award lawman reputation to officer Officer.Functions.AddRep('lawman', 10) -- Reduce outlaw reputation for criminal Criminal.Functions.RemoveRep('outlaw', 25) -- Check officer's reputation tier local lawmanRep = Officer.Functions.GetRep('lawman') local tier = GetReputationTier(lawmanRep) TriggerClientEvent('ox_lib:notify', src, { description = 'Arrested criminal (+10 lawman rep) - '.. tier, type = 'success' })end)-- Crime increases outlaw rep, decreases lawman repRegisterNetEvent('crime:server:commitCrime', function(crimeType) local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local outlawGain = 0 if crimeType == 'robbery' then outlawGain = 15 elseif crimeType == 'murder' then outlawGain = 25 elseif crimeType == 'theft' then outlawGain = 5 end -- Increase outlaw reputation Player.Functions.AddRep('outlaw', outlawGain) -- Decrease lawman reputation Player.Functions.RemoveRep('lawman', outlawGain * 2) TriggerClientEvent('ox_lib:notify', src, { description = 'Crime committed (+' .. outlawGain ..' outlaw rep)', type = 'error' })end)-- Helper function for reputation tiersfunction GetReputationTier(rep) if rep >= 500 then return 'Legendary' end if rep >= 300 then return 'Master' end if rep >= 200 then return 'Expert' end if rep >= 100 then return 'Skilled' end if rep >= 50 then return 'Apprentice' end return 'Novice'end
-- SERVER SIDE-- Shop that requires reputation to accessRegisterNetEvent('shop:server:openSpecialShop', function() local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local requiredRep = 100 local huntingRep = Player.Functions.GetRep('hunting') if huntingRep < requiredRep then TriggerClientEvent('ox_lib:notify', src, { description = 'You need '.. requiredRep ..' hunting reputation (you have '.. huntingRep ..')', type = 'error' }) return end -- Open special shop with rare items local shopItems = { { name = 'legendary_bow', price = 500, amount = 1 }, { name = 'master_lure', price = 100, amount = 5 }, { name = 'tracking_scope', price = 250, amount = 1 } } exports['rsg-inventory']:OpenShop(src, 'master_hunter_shop', shopItems)end)-- Job promotion based on reputationRegisterNetEvent('job:server:requestPromotion', function() local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local job = Player.PlayerData.job.name local currentGrade = Player.PlayerData.job.grade.level -- Check job-specific reputation local jobRep = Player.Functions.GetRep(job) local requiredRep = (currentGrade + 1) * 50 -- 50, 100, 150, etc. if jobRep < requiredRep then TriggerClientEvent('ox_lib:notify', src, { description = 'Need '.. requiredRep ..' '.. job ..' reputation for promotion', type = 'error' }) return end -- Grant promotion local newGrade = currentGrade + 1 if Player.Functions.SetJob(job, tostring(newGrade)) then TriggerClientEvent('ox_lib:notify', src, { title = 'Promotion!', description = 'Promoted to grade '.. newGrade, type = 'success' }) endend)
-- SERVER SIDE-- Decrease reputation over time if inactiveCreateThread(function() while true do Wait(3600000) -- Every hour for _, playerId in pairs(RSGCore.Functions.GetPlayers()) do local Player = RSGCore.Functions.GetPlayer(playerId) if Player then -- Decay outlaw reputation slowly local outlawRep = Player.Functions.GetRep('outlaw') if outlawRep > 0 then Player.Functions.RemoveRep('outlaw', 1) -- Lose 1 per hour end -- Decay skill reputations very slowly for _, skill in ipairs({'hunting', 'fishing', 'mining'}) do local skillRep = Player.Functions.GetRep(skill) if skillRep > 100 then -- Only decay if above 100 Player.Functions.RemoveRep(skill, 1) end end end end endend)
-- SERVER SIDE-- Grant perks based on reputation thresholdsfunction ApplyReputationPerks(source) local Player = RSGCore.Functions.GetPlayer(source) if not Player then return end local huntingRep = Player.Functions.GetRep('hunting') -- Hunting perks if huntingRep >= 200 then -- Master hunter - better loot chance TriggerClientEvent('hunting:client:setLootBonus', source, 1.5) elseif huntingRep >= 100 then -- Expert hunter - moderate loot bonus TriggerClientEvent('hunting:client:setLootBonus', source, 1.25) end local tradingRep = Player.Functions.GetRep('trading') -- Trading perks if tradingRep >= 150 then -- Master trader - 20% better prices TriggerClientEvent('trading:client:setPriceBonus', source, 0.20) elseif tradingRep >= 75 then -- Skilled trader - 10% better prices TriggerClientEvent('trading:client:setPriceBonus', source, 0.10) endend-- Call when player loadsRegisterNetEvent('RSGCore:Server:PlayerLoaded', function(Player) ApplyReputationPerks(Player.PlayerData.source)end)
-- SERVER SIDE-- Get top players by reputation typeRegisterNetEvent('reputation:server:getLeaderboard', function(repType) local src = source MySQL.query('SELECT citizenid, charinfo, metadata FROM players ORDER BY JSON_EXTRACT(metadata, "$.rep.'.. repType ..'") DESC LIMIT 10', {}, function(result) if not result then return end local leaderboard = {} for i = 1, #result do local charinfo = json.decode(result[i].charinfo) local metadata = json.decode(result[i].metadata) local rep = metadata.rep and metadata.rep[repType] or 0 leaderboard[#leaderboard + 1] = { rank = i, name = charinfo.firstname ..' '.. charinfo.lastname, reputation = rep } end TriggerClientEvent('reputation:client:showLeaderboard', src, repType, leaderboard) end)end)-- CLIENT SIDERegisterNetEvent('reputation:client:showLeaderboard', function(repType, leaderboard) -- Display leaderboard in UI SendNUIMessage({ action = 'showLeaderboard', type = repType, data = leaderboard })end)
-- SERVER SIDE-- Quest that requires multiple reputation typesRegisterNetEvent('quest:server:startMasterQuest', function() local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local requirements = { hunting = 150, fishing = 100, crafting = 100, trading = 75 } -- Check all requirements local meetsRequirements = true local missingReps = {} for repType, required in pairs(requirements) do local current = Player.Functions.GetRep(repType) if current < required then meetsRequirements = false missingReps[#missingReps + 1] = { type = repType, required = required, current = current, needed = required - current } end end if not meetsRequirements then local message = 'Missing reputation requirements:\n' for _, missing in ipairs(missingReps) do message = message .. missing.type ..': '.. missing.current ..'/'.. missing.required ..' (need '.. missing.needed ..' more)\n' end TriggerClientEvent('ox_lib:notify', src, { title = 'Quest Locked', description = message, type = 'error', duration = 10000 }) return end -- Start the master quest TriggerEvent('quest:server:startQuest', src, 'master_quest') TriggerClientEvent('ox_lib:notify', src, { title = 'Master Quest', description = 'You have unlocked the Master Quest!', type = 'success' })end)
-- SERVER SIDE-- Define reputation tierslocal ReputationTiers = { hunting = { { min = 0, max = 49, label = 'Novice Hunter', color = '#808080' }, { min = 50, max = 99, label = 'Apprentice Hunter', color = '#00ff00' }, { min = 100, max = 199, label = 'Skilled Hunter', color = '#0080ff' }, { min = 200, max = 299, label = 'Expert Hunter', color = '#8000ff' }, { min = 300, max = 499, label = 'Master Hunter', color = '#ff8000' }, { min = 500, max = 9999, label = 'Legendary Hunter', color = '#ff0000' } }, lawman = { { min = 0, max = 49, label = 'Recruit', color = '#808080' }, { min = 50, max = 99, label = 'Deputy', color = '#00ff00' }, { min = 100, max = 199, label = 'Sheriff', color = '#0080ff' }, { min = 200, max = 299, label = 'US Marshal', color = '#8000ff' }, { min = 300, max = 9999, label = 'Legendary Lawman', color = '#ff0000' } }}-- Get tier for reputationfunction GetReputationTier(repType, repAmount) local tiers = ReputationTiers[repType] if not tiers then return nil end for _, tier in ipairs(tiers) do if repAmount >= tier.min and repAmount <= tier.max then return tier end end return nilend-- UsageRegisterNetEvent('reputation:server:checkTier', function(repType) local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local rep = Player.Functions.GetRep(repType) local tier = GetReputationTier(repType, rep) if tier then TriggerClientEvent('ox_lib:notify', src, { title = tier.label, description = 'You have '.. rep ..' '.. repType ..' reputation', type = 'info' }) endend)
Reputation functions are in rsg-core/server/player.lua:
Copy
-- Lines 236-242: AddRepfunction self.Functions.AddRep(rep, amount) if not rep or not amount then return end local addAmount = tonumber(amount) local currentRep = self.PlayerData.metadata['rep'][rep] or 0 self.PlayerData.metadata['rep'][rep] = currentRep + addAmount self.Functions.UpdatePlayerData()end-- Lines 244-254: RemoveRepfunction self.Functions.RemoveRep(rep, amount) if not rep or not amount then return end local removeAmount = tonumber(amount) local currentRep = self.PlayerData.metadata['rep'][rep] or 0 if currentRep - removeAmount < 0 then self.PlayerData.metadata['rep'][rep] = 0 else self.PlayerData.metadata['rep'][rep] = currentRep - removeAmount end self.Functions.UpdatePlayerData()end-- Lines 256-259: GetRepfunction self.Functions.GetRep(rep) if not rep then return end return self.PlayerData.metadata['rep'][rep] or 0end