From b304e3d3f409fa2994bab1264d968b7c9926edad Mon Sep 17 00:00:00 2001 From: Andrew <10902965+AndrewR3K@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:57:18 -0800 Subject: [PATCH] Added discord webhooks (#127) * Added discord webhooks * minor fixes * Update main.lua - housekeeping * Update comps.lua - removed translations that were previously moved to a separate file * Update main.lua - add default discord title * Update fxmanifest.lua - version check integrated with server file - version bump * Update en_lang.lua - housekeeping * Update main.lua - version check added to server file - housekeeping * Delete versioncheck.lua * Update package.json - version bump * Update version - version bump --------- Co-authored-by: Apollyon <37031311+JusCampin@users.noreply.github.com> --- client/main.lua | 70 ++++++++++---------- config/comps.lua | 16 ----- config/main.lua | 8 +++ fxmanifest.lua | 3 +- languages/en_lang.lua | 7 ++ languages/fr_lang.lua | 7 ++ languages/it_lang.lua | 7 ++ languages/pt_lang.lua | 7 ++ languages/ro_lang.lua | 9 ++- languages/th_lang.lua | 7 ++ server/main.lua | 139 ++++++++++++++++++++++++---------------- server/versioncheck.lua | 2 - ui/package.json | 2 +- version | 2 +- 14 files changed, 171 insertions(+), 115 deletions(-) delete mode 100644 server/versioncheck.lua diff --git a/client/main.lua b/client/main.lua index c3127e2..36331e6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,4 +1,4 @@ -local VORPcore = exports.vorp_core:GetCore() +local Core = exports.vorp_core:GetCore() local FeatherMenu = exports['feather-menu'].initiate() -- Prompts @@ -183,7 +183,7 @@ RegisterNUICallback('BuyHorse', function(data, cb) cb('ok') CheckPlayerJob(true, nil) if Stables[Site].trainerBuy and not IsTrainer then - VORPcore.NotifyRightTip(_U('trainerBuyHorse'), 4000) + Core.NotifyRightTip(_U('trainerBuyHorse'), 4000) StableMenu() return end @@ -193,7 +193,7 @@ RegisterNUICallback('BuyHorse', function(data, cb) data.isTrainer = false end data.origin = 'buyHorse' - local canBuy = VORPcore.Callback.TriggerAwait('bcc-stables:BuyHorse', data) + local canBuy = Core.Callback.TriggerAwait('bcc-stables:BuyHorse', data) if canBuy then SetHorseName(data) else @@ -222,7 +222,7 @@ function SetHorseName(data) if string.len(horseName) > 0 then data.name = horseName if data.origin == 'updateHorse' then - local nameSaved = VORPcore.Callback.TriggerAwait('bcc-stables:UpdateHorseName', data) + local nameSaved = Core.Callback.TriggerAwait('bcc-stables:UpdateHorseName', data) if nameSaved then StableMenu() end @@ -230,7 +230,7 @@ function SetHorseName(data) return elseif data.origin == 'buyHorse' then data.captured = 0 - local horseSaved = VORPcore.Callback.TriggerAwait('bcc-stables:SaveNewHorse', data) + local horseSaved = Core.Callback.TriggerAwait('bcc-stables:SaveNewHorse', data) if horseSaved then StableMenu() end @@ -243,7 +243,7 @@ function SetHorseName(data) while not Citizen.InvokeNative(0x01FEE67DB37F59B2, playerPed) do -- IsPedOnFoot Wait(10) end - local horseSaved = VORPcore.Callback.TriggerAwait('bcc-stables:SaveTamedHorse', data) + local horseSaved = Core.Callback.TriggerAwait('bcc-stables:SaveTamedHorse', data) if horseSaved then DeleteEntity(data.mount) HorseBreed = false @@ -328,7 +328,7 @@ RegisterNUICallback('selectHorse', function(data, cb) end) function GetSelectedHorse() - local data = VORPcore.Callback.TriggerAwait('bcc-stables:GetHorseData') + local data = Core.Callback.TriggerAwait('bcc-stables:GetHorseData') if data then SpawnHorse(data) else @@ -704,7 +704,7 @@ end) function HorseDrinking() if not IsEntityInWater(MyHorse) then - VORPcore.NotifyRightTip(HorseName .. _U('needWater'), 4000) + Core.NotifyRightTip(HorseName .. _U('needWater'), 4000) return end Drinking = true @@ -884,7 +884,7 @@ function WhistleSpawn() if Config.whistleSpawn then GetSelectedHorse() else - VORPcore.NotifyRightTip(_U('stableSpawn'), 4000) + Core.NotifyRightTip(_U('stableSpawn'), 4000) end end @@ -918,9 +918,9 @@ CreateThread(function() TamedModel = model if Config.displayHorseBreed and not HorseBreed then if horseCfg.breed == 'Other' then - VORPcore.NotifyBottomRight(modelCfg.color, 1000) + Core.NotifyBottomRight(modelCfg.color, 1000) else - VORPcore.NotifyBottomRight(horseCfg.breed, 1000) + Core.NotifyBottomRight(horseCfg.breed, 1000) end HorseBreed = true end @@ -981,16 +981,16 @@ CreateThread(function() PromptSetEnabled(KeepTame, allowKeep) if Citizen.InvokeNative(0xE0F65F0640EF0617, SellTame) then -- PromptHasHoldModeCompleted - local onCooldown = VORPcore.Callback.TriggerAwait('bcc-stables:CheckPlayerCooldown', 'sellTame') + local onCooldown = Core.Callback.TriggerAwait('bcc-stables:CheckPlayerCooldown', 'sellTame') if onCooldown then - VORPcore.NotifyRightTip(_U('sellCooldown'), 4000) + Core.NotifyRightTip(_U('sellCooldown'), 4000) HorseBreed = false goto END end if Config.trainerOnly then CheckPlayerJob(true, nil) if not IsTrainer then - VORPcore.NotifyRightTip(_U('trainerSellHorse'), 4000) + Core.NotifyRightTip(_U('trainerSellHorse'), 4000) HorseBreed = false goto END end @@ -1001,7 +1001,7 @@ CreateThread(function() while not Citizen.InvokeNative(0x01FEE67DB37F59B2, playerPed) do -- IsPedOnFoot Wait(10) end - VORPcore.NotifyRightTip(_U('tamedCooldown') .. Config.cooldown.sellTame .. _U('minutes'), 4000) + Core.NotifyRightTip(_U('tamedCooldown') .. Config.cooldown.sellTame .. _U('minutes'), 4000) DeleteEntity(mount) mount = 0 Wait(200) @@ -1012,7 +1012,7 @@ CreateThread(function() CheckPlayerJob(true, nil) if Config.trainerOnly then if not IsTrainer then - VORPcore.NotifyRightTip(_U('trainerRegHorse'), 4000) + Core.NotifyRightTip(_U('trainerRegHorse'), 4000) HorseBreed = false goto END end @@ -1032,7 +1032,7 @@ CreateThread(function() tameData.gender = 'female' end tameData.mount = mount - local canKeep = VORPcore.Callback.TriggerAwait('bcc-stables:RegisterHorse', tameData) + local canKeep = Core.Callback.TriggerAwait('bcc-stables:RegisterHorse', tameData) if canKeep then SetHorseName(tameData) else @@ -1068,15 +1068,15 @@ AddEventHandler('bcc-stables:CheckHorseHealth', function() SaveHorseStats(true) if Config.death.deselect then - deselected = VORPcore.Callback.TriggerAwait('bcc-stables:DeselectHorse', MyHorseId) + deselected = Core.Callback.TriggerAwait('bcc-stables:DeselectHorse', MyHorseId) end if Config.death.permanent then - permaDead = VORPcore.Callback.TriggerAwait('bcc-stables:SetHorseDead', MyHorseId) + permaDead = Core.Callback.TriggerAwait('bcc-stables:SetHorseDead', MyHorseId) end if deselected or permaDead then - VORPcore.NotifyRightTip(_U('horseDied'), 4000) + Core.NotifyRightTip(_U('horseDied'), 4000) end Wait(5000) @@ -1088,10 +1088,10 @@ AddEventHandler('bcc-stables:CheckHorseHealth', function() end) AddEventHandler('bcc-stables:ReviveHorse', function() - local hasItem = VORPcore.Callback.TriggerAwait('bcc-stables:HorseReviveItem') + local hasItem = Core.Callback.TriggerAwait('bcc-stables:HorseReviveItem') if not hasItem then - VORPcore.NotifyRightTip(_U('noReviver'), 4000) + Core.NotifyRightTip(_U('noReviver'), 4000) return end @@ -1105,7 +1105,7 @@ function OpenInventory(horsePedId, horseId, isLooting) local hasBags = Citizen.InvokeNative(0xFB4891BD7578CDC1, horsePedId, -2142954459) -- IsMetaPedUsingComponent if not isLooting and Config.useSaddlebags and not hasBags then - VORPcore.NotifyRightTip(_U('noSaddlebags'), 4000) + Core.NotifyRightTip(_U('noSaddlebags'), 4000) return end @@ -1132,7 +1132,7 @@ function ReturnHorse() local playerPed = PlayerPedId() if not MyHorse or MyHorse == 0 then - VORPcore.NotifyRightTip(_U('noHorse'), 4000) + Core.NotifyRightTip(_U('noHorse'), 4000) return end @@ -1149,7 +1149,7 @@ function ReturnHorse() DeleteEntity(MyHorse) MyHorse = 0 - VORPcore.NotifyRightTip(_U('horseReturned'), 4000) + Core.NotifyRightTip(_U('horseReturned'), 4000) end function GetControlOfHorse() @@ -1208,7 +1208,7 @@ function SaveXp(xpSource) Citizen.InvokeNative(0x75415EE0CB583760, MyHorse, 7, horseXp) -- AddAttributePoints if Config.showXpMessage then - VORPcore.NotifyRightTip('+ ' .. horseXp .. ' XP', 2000) + Core.NotifyRightTip('+ ' .. horseXp .. ' XP', 2000) end local maxXp = Citizen.InvokeNative(0x223BF310F854871C, MyHorse, 7) -- GetMaxAttributePoints @@ -1365,13 +1365,13 @@ end RegisterNetEvent('bcc-stables:BrushHorse', function() if not MyHorse or MyHorse == 0 then - return VORPcore.NotifyRightTip(_U('noHorse'), 4000) + return Core.NotifyRightTip(_U('noHorse'), 4000) end local playerPed = PlayerPedId() local dist = #(GetEntityCoords(playerPed) - GetEntityCoords(MyHorse)) if dist > 3.5 then - return VORPcore.NotifyRightTip(_U('tooFar'), 4000) + return Core.NotifyRightTip(_U('tooFar'), 4000) end ClearPedTasks(playerPed) @@ -1417,13 +1417,13 @@ end) RegisterNetEvent('bcc-stables:FeedHorse', function(item) if not MyHorse or MyHorse == 0 then - return VORPcore.NotifyRightTip(_U('noHorse'), 4000) + return Core.NotifyRightTip(_U('noHorse'), 4000) end local playerPed = PlayerPedId() local dist = #(GetEntityCoords(playerPed) - GetEntityCoords(MyHorse)) if dist > 3.5 then - VORPcore.NotifyRightTip(_U('tooFar'), 4000) + Core.NotifyRightTip(_U('tooFar'), 4000) return end @@ -1696,7 +1696,7 @@ RegisterNUICallback('sellHorse', function(data, cb) MyEntity = 0 Cam = false - local horseSold = VORPcore.Callback.TriggerAwait('bcc-stables:SellMyHorse', data) + local horseSold = Core.Callback.TriggerAwait('bcc-stables:SellMyHorse', data) if horseSold then StableMenu() end @@ -1800,14 +1800,14 @@ end, false) RegisterCommand(Config.commands.horseInfo, function(source, args, rawCommand) if not MyHorse or MyHorse == 0 then - VORPcore.NotifyRightTip(_U('noHorse'), 4000) + Core.NotifyRightTip(_U('noHorse'), 4000) return end if #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(MyHorse)) <= 3.0 then HorseInfoMenu() else - VORPcore.NotifyRightTip(_U('tooFar'), 4000) + Core.NotifyRightTip(_U('tooFar'), 4000) end end, false) @@ -1931,7 +1931,7 @@ function HorseTargetPrompts(menuGroup) end function CheckPlayerJob(trainer, site) - local result = VORPcore.Callback.TriggerAwait('bcc-stables:CheckJob', trainer, site) + local result = Core.Callback.TriggerAwait('bcc-stables:CheckJob', trainer, site) if trainer and result then IsTrainer = false if result[1] then @@ -1942,7 +1942,7 @@ function CheckPlayerJob(trainer, site) if result[1] then HasJob = true elseif Stables[site].shop.jobsEnabled then - VORPcore.NotifyRightTip(_U('needJob'), 4000) + Core.NotifyRightTip(_U('needJob'), 4000) end JobMatchedHorses = FindHorsesByJob(result[2]) end diff --git a/config/comps.lua b/config/comps.lua index 1881f51..97bb5a2 100644 --- a/config/comps.lua +++ b/config/comps.lua @@ -936,19 +936,3 @@ HorseComp = { { hash = '0x0865A270', cashPrice = 10, goldPrice = 1 }, }, } - -Translation = { -- English - Saddlecloths = "Saddlecloths", - SaddleHorns = "Saddle Horns", - SaddleBags = "Saddle Bags", - Tails = "Tails", - Manes = "Manes", - Saddles = "Saddles", - Stirrups = "Stirrups", - Bedrolls = "Bedrolls", - Masks = "Masks", - Mustaches = "Mustaches", - Holsters = "Holsters", - Bridles = "Bridles", - Horseshoes = "Horseshoes", -} diff --git a/config/main.lua b/config/main.lua index 2aab7df..a4b0d43 100644 --- a/config/main.lua +++ b/config/main.lua @@ -7,6 +7,14 @@ Config.defaultlang = 'en_lang' Config.devMode = false -- Default: false / Do Not Run on a Live Server ----------------------------------------------------- +Config.discord = { + active = false, + webhookURL = '', + title = 'BCC-Stables', + avatar = '' +} +----------------------------------------------------- + -- Set the currency type -- 0 = Cash Only -- 1 = Gold Only diff --git a/fxmanifest.lua b/fxmanifest.lua index 6c9bd54..d14c640 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -18,7 +18,6 @@ client_scripts { server_scripts { '@oxmysql/lib/MySQL.lua', - 'server/versioncheck.lua', 'server/main.lua' } @@ -34,5 +33,5 @@ files { "ui/img/*.*" } -version '1.5.2' +version '1.5.3' diff --git a/languages/en_lang.lua b/languages/en_lang.lua index 56d65e0..d5ba668 100644 --- a/languages/en_lang.lua +++ b/languages/en_lang.lua @@ -66,4 +66,11 @@ Locales["en_lang"] = { horseInfoTrickLvl_4a = "Trick: Dance | space", horseInfoTrickLvl_4b = "Side-Pass | space + A or D", horseDied = "Your horse has died, return to stable to select a horse.", + -- Discord Alerts + discordHorsePurchased = "Horse Purchased!", + discordTamedPurchased = "Tamed Horse Saved!", + discordHorseXPGain = "Horse XP Gained!", + discordHorseSold = "Horse Sold!", + discordTamedSold = "Tamed Horse Sold!", + discordTraded = "Horse Traded to " } diff --git a/languages/fr_lang.lua b/languages/fr_lang.lua index 3f164bc..d49f870 100644 --- a/languages/fr_lang.lua +++ b/languages/fr_lang.lua @@ -66,4 +66,11 @@ Locales["fr_lang"] = { horseInfoTrickLvl_4a = "Trick: Dance | space", horseInfoTrickLvl_4b = "Side-Pass | space + A or D", horseDied = "Your horse has died, return to stable to select a horse.", + -- Discord Alerts + discordHorsePurchased = "Cheval acheté !", + discordTamedPurchased = "Cheval apprivoisé sauvegardé !", + discordHorseXPGain = "XP de cheval gagnée !", + discordHorseSold = "Cheval vendu !", + discordTamedSold = "Cheval apprivoisé vendu !", + discordTraded = "Cheval échangé à " } diff --git a/languages/it_lang.lua b/languages/it_lang.lua index 0a01c30..3e06e75 100644 --- a/languages/it_lang.lua +++ b/languages/it_lang.lua @@ -66,4 +66,11 @@ Locales["it_lang"] = { horseInfoTrickLvl_4a = "Trick: Dance | space", horseInfoTrickLvl_4b = "Side-Pass | space + A or D", horseDied = "Your horse has died, return to stable to select a horse.", + -- Discord Alerts + discordHorsePurchased = "Cavallo acquistato!", + discordTamedPurchased = "Cavallo domato salvato!", + discordHorseXPGain = "XP cavallo guadagnata!", + discordHorseSold = "Cavallo venduto!", + discordTamedSold = "Cavallo domato venduto!", + discordTraded = "Cavallo scambiato con " } diff --git a/languages/pt_lang.lua b/languages/pt_lang.lua index 0fb33a8..6c39600 100644 --- a/languages/pt_lang.lua +++ b/languages/pt_lang.lua @@ -66,4 +66,11 @@ Locales["pt_lang"] = { horseInfoTrickLvl_4a = "Truque: Dance | space", horseInfoTrickLvl_4b = "Andar para o lado | space + A or D", horseDied = "O teu cavalo morreu, volta ao estábulo para selecionar um cavalo.", + -- Discord Alerts + discordHorsePurchased = "Cavalo comprado!", + discordTamedPurchased = "Cavalo domado salvo!", + discordHorseXPGain = "XP de cavalo adquirida!", + discordHorseSold = "Cavalo vendido!", + discordTamedSold = "Cavalo domado vendido!", + discordTraded = "Cavalo trocado com " } diff --git a/languages/ro_lang.lua b/languages/ro_lang.lua index 32531bd..6b80b3e 100644 --- a/languages/ro_lang.lua +++ b/languages/ro_lang.lua @@ -66,4 +66,11 @@ Locales["ro_lang"] = { horseInfoTrickLvl_4a = "Truc: Dans | space", horseInfoTrickLvl_4b = "Side-Pass | space + A sau D", horseDied = "Your horse has died, return to stable to select a horse.", -} \ No newline at end of file + -- Discord Alerts + discordHorsePurchased = "Cal cumpărat!", + discordTamedPurchased = "Cal îmblânzit salvat!", + discordHorseXPGain = "XP cal câștigat!", + discordHorseSold = "Cal vândut!", + discordTamedSold = "Cal îmblânzit vândut!", + discordTraded = "Cal schimbat cu " +} diff --git a/languages/th_lang.lua b/languages/th_lang.lua index 0f86b0e..9026598 100644 --- a/languages/th_lang.lua +++ b/languages/th_lang.lua @@ -66,4 +66,11 @@ Locales["th_lang"] = { horseInfoTrickLvl_4a = "ท่า: เต้น | space", horseInfoTrickLvl_4b = "เดินข้าง | space + A หรือ D", horseDied = "ม้าของคุณเสียชีวิตแล้ว กลับไปที่คอกม้าเพื่อเลือกม้าใหม่", + -- Discord Alerts + discordHorsePurchased = "ซื้อม้าแล้ว!", + discordTamedPurchased = "บันทึกม้าที่เชื่องแล้ว!", + discordHorseXPGain = "ได้รับ XP ม้า!", + discordHorseSold = "ขายม้าแล้ว!", + discordTamedSold = "ขายม้าที่เชื่องแล้ว!", + discordTraded = "แลกเปลี่ยนม้ากับ " } diff --git a/server/main.lua b/server/main.lua index 96880da..92b579e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,10 +1,21 @@ -local VORPcore = exports.vorp_core:GetCore() - +local Core = exports.vorp_core:GetCore() +local BccUtils = exports['bcc-utils'].initiate() local CooldownData = {} -VORPcore.Callback.Register('bcc-stables:BuyHorse', function(source, cb, data) +if Config.discord.active == true then + Discord = BccUtils.Discord.setup(Config.discord.webhookURL, Config.discord.title, Config.discord.avatar) +end + +function LogToDiscord(name, description, embeds) + if Config.discord.active == true then + Discord:sendMessage(name, description, embeds) + end +end + +---@param data table +Core.Callback.Register('bcc-stables:BuyHorse', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local Character = user.getUsedCharacter local charid = Character.charIdentifier @@ -16,7 +27,7 @@ VORPcore.Callback.Register('bcc-stables:BuyHorse', function(source, cb, data) local horses = MySQL.query.await('SELECT * FROM `player_horses` WHERE `charid` = ? AND `dead` = ?', { charid, 0 }) if #horses >= maxHorses then - VORPcore.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 4000) + Core.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 4000) cb(false) return end @@ -29,14 +40,14 @@ VORPcore.Callback.Register('bcc-stables:BuyHorse', function(source, cb, data) if Character.money >= colorCfg.cashPrice then cb(true) else - VORPcore.NotifyRightTip(src, _U('shortCash'), 4000) + Core.NotifyRightTip(src, _U('shortCash'), 4000) cb(false) end else if Character.gold >= colorCfg.goldPrice then cb(true) else - VORPcore.NotifyRightTip(src, _U('shortGold'), 4000) + Core.NotifyRightTip(src, _U('shortGold'), 4000) cb(false) end end @@ -45,9 +56,9 @@ VORPcore.Callback.Register('bcc-stables:BuyHorse', function(source, cb, data) end end) -VORPcore.Callback.Register('bcc-stables:RegisterHorse', function(source, cb, data) +Core.Callback.Register('bcc-stables:RegisterHorse', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local Character = user.getUsedCharacter local charid = Character.charIdentifier @@ -59,7 +70,7 @@ VORPcore.Callback.Register('bcc-stables:RegisterHorse', function(source, cb, dat local horses = MySQL.query.await('SELECT * FROM `player_horses` WHERE `charid` = ? AND `dead` = ?', { charid, 0 }) if #horses >= maxHorses then - VORPcore.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 4000) + Core.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 4000) cb(false) return end @@ -68,7 +79,7 @@ VORPcore.Callback.Register('bcc-stables:RegisterHorse', function(source, cb, dat if Character.money >= Config.regCost then cb(true) else - VORPcore.NotifyRightTip(src, _U('shortCash'), 4000) + Core.NotifyRightTip(src, _U('shortCash'), 4000) cb(false) end end @@ -76,7 +87,7 @@ end) RegisterNetEvent('bcc-stables:BuyTack', function(data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local Character = user.getUsedCharacter @@ -85,25 +96,25 @@ RegisterNetEvent('bcc-stables:BuyTack', function(data) if Character.money >= data.cashPrice then Character.removeCurrency(0, data.cashPrice) else - VORPcore.NotifyRightTip(src, _U('shortCash'), 4000) + Core.NotifyRightTip(src, _U('shortCash'), 4000) return end else if Character.gold >= data.goldPrice then Character.removeCurrency(1, data.goldPrice) else - VORPcore.NotifyRightTip(src, _U('shortGold'), 4000) + Core.NotifyRightTip(src, _U('shortGold'), 4000) return end end - VORPcore.NotifyRightTip(src, _U('purchaseSuccessful'), 4000) + Core.NotifyRightTip(src, _U('purchaseSuccessful'), 4000) end TriggerClientEvent('bcc-stables:SaveComps', src) end) -VORPcore.Callback.Register('bcc-stables:SaveNewHorse', function(source, cb, data) +Core.Callback.Register('bcc-stables:SaveNewHorse', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local identifier = character.identifier @@ -119,14 +130,16 @@ VORPcore.Callback.Register('bcc-stables:SaveNewHorse', function(source, cb, data character.removeCurrency(1, colorCfg.goldPrice) else if data.IsCash then - VORPcore.NotifyRightTip(src, _U('shortCash'), 4000) + Core.NotifyRightTip(src, _U('shortCash'), 4000) elseif not data.IsCash then - VORPcore.NotifyRightTip(src, _U('shortGold'), 4000) + Core.NotifyRightTip(src, _U('shortGold'), 4000) end return cb(true) end MySQL.query.await('INSERT INTO `player_horses` (identifier, charid, name, model, gender, captured) VALUES (?, ?, ?, ?, ?, ?)', { identifier, charid, tostring(data.name), data.ModelH, data.gender, data.captured }) + + LogToDiscord(charid, _U('discordHorsePurchased')) break end end @@ -134,9 +147,9 @@ VORPcore.Callback.Register('bcc-stables:SaveNewHorse', function(source, cb, data cb(true) end) -VORPcore.Callback.Register('bcc-stables:SaveTamedHorse', function(source, cb, data) +Core.Callback.Register('bcc-stables:SaveTamedHorse', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local identifier = character.identifier @@ -146,18 +159,20 @@ VORPcore.Callback.Register('bcc-stables:SaveTamedHorse', function(source, cb, da if character.money >= Config.regCost then character.removeCurrency(0, Config.regCost) else - VORPcore.NotifyRightTip(src, _U('shortCash'), 4000) + Core.NotifyRightTip(src, _U('shortCash'), 4000) return cb(false) end end MySQL.query.await('INSERT INTO `player_horses` (identifier, charid, name, model, gender, captured) VALUES (?, ?, ?, ?, ?, ?)', { identifier, charid, tostring(data.name), data.ModelH, data.gender, data.captured }) + + LogToDiscord(charid, _U('discordTamedPurchased')) cb(true) end) -VORPcore.Callback.Register('bcc-stables:UpdateHorseName', function(source, cb, data) +Core.Callback.Register('bcc-stables:UpdateHorseName', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local identifier = character.identifier @@ -170,7 +185,7 @@ end) RegisterServerEvent('bcc-stables:UpdateHorseXp', function(Xp, horseId) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -178,11 +193,13 @@ RegisterServerEvent('bcc-stables:UpdateHorseXp', function(Xp, horseId) MySQL.query.await('UPDATE `player_horses` SET `xp` = ? WHERE `id` = ? AND `identifier` = ? AND `charid` = ?', { Xp, horseId, identifier, charid }) + + LogToDiscord(charid, _U('discordHorseXPGain')) end) RegisterServerEvent('bcc-stables:SaveHorseStats', function(data, horseId) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -194,7 +211,7 @@ end) RegisterServerEvent('bcc-stables:SelectHorse', function(data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -214,9 +231,9 @@ RegisterServerEvent('bcc-stables:SelectHorse', function(data) end end) -VORPcore.Callback.Register('bcc-stables:DeselectHorse', function(source, cb, horseId) +Core.Callback.Register('bcc-stables:DeselectHorse', function(source, cb, horseId) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -227,9 +244,9 @@ VORPcore.Callback.Register('bcc-stables:DeselectHorse', function(source, cb, hor cb(true) end) -VORPcore.Callback.Register('bcc-stables:SetHorseDead', function(source, cb, horseId) +Core.Callback.Register('bcc-stables:SetHorseDead', function(source, cb, horseId) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -240,9 +257,9 @@ VORPcore.Callback.Register('bcc-stables:SetHorseDead', function(source, cb, hors cb(true) end) -VORPcore.Callback.Register('bcc-stables:GetHorseData', function(source, cb) +Core.Callback.Register('bcc-stables:GetHorseData', function(source, cb) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local identifier = character.identifier @@ -269,18 +286,18 @@ VORPcore.Callback.Register('bcc-stables:GetHorseData', function(source, cb) end end if data == nil then - VORPcore.NotifyRightTip(src, _U('noSelectedHorse'), 4000) + Core.NotifyRightTip(src, _U('noSelectedHorse'), 4000) cb(false) end else - VORPcore.NotifyRightTip(src, _U('noHorses'), 4000) + Core.NotifyRightTip(src, _U('noHorses'), 4000) cb(false) end end) RegisterNetEvent('bcc-stables:GetMyHorses', function() local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local Character = user.getUsedCharacter local identifier = Character.identifier @@ -293,7 +310,7 @@ end) RegisterNetEvent('bcc-stables:UpdateComponents', function(encodedComponents, horseId, MyHorse_entity) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local identifier = character.identifier @@ -304,9 +321,9 @@ RegisterNetEvent('bcc-stables:UpdateComponents', function(encodedComponents, hor TriggerClientEvent('bcc-stables:SetComponents', src, MyHorse_entity, encodedComponents) end) -VORPcore.Callback.Register('bcc-stables:SellMyHorse', function(source, cb, data) +Core.Callback.Register('bcc-stables:SellMyHorse', function(source, cb, data) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local identifier = character.identifier @@ -322,6 +339,7 @@ VORPcore.Callback.Register('bcc-stables:SellMyHorse', function(source, cb, data) model = horses[i].model MySQL.query.await('DELETE FROM `player_horses` WHERE `id` = ? AND `charid` = ? AND `identifier` = ?', { id, charid, identifier }) + LogToDiscord(charid, _U('discordHorseSold')) break end end @@ -333,7 +351,7 @@ VORPcore.Callback.Register('bcc-stables:SellMyHorse', function(source, cb, data) sellPrice = (Config.tamedSellPrice * colorCfg.cashPrice) end character.addCurrency(0, sellPrice) - VORPcore.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 4000) + Core.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 4000) cb(true) break end @@ -347,7 +365,7 @@ end RegisterServerEvent('bcc-stables:SellTamedHorse', function(hash) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local character = user.getUsedCharacter local charid = character.charIdentifier @@ -358,16 +376,18 @@ RegisterServerEvent('bcc-stables:SellTamedHorse', function(hash) if colorHash == hash then local sellPrice = (Config.tamedSellPrice * colorCfg.cashPrice) character.addCurrency(0, math.floor(sellPrice)) - VORPcore.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 4000) + Core.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 4000) SetPlayerCooldown('sellTame', charid) + + LogToDiscord(charid, _U('discordTamedSold')) end end end end) -VORPcore.Callback.Register('bcc-stables:CheckPlayerCooldown', function(source, cb, type) +Core.Callback.Register('bcc-stables:CheckPlayerCooldown', function(source, cb, type) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local character = user.getUsedCharacter local cooldown = Config.cooldown[type] @@ -394,14 +414,14 @@ end) RegisterServerEvent('bcc-stables:SaveHorseTrade', function(serverId, horseId) -- Current Owner local src = source - local curUser = VORPcore.getUser(src) + local curUser = Core.getUser(src) if not curUser then return end local curOwner = curUser.getUsedCharacter local curOwnerId = curOwner.identifier local curOwnerCharId = curOwner.charIdentifier local curOwnerName = curOwner.firstname .. " " .. curOwner.lastname -- New Owner - local newUser = VORPcore.getUser(serverId) + local newUser = Core.getUser(serverId) if not newUser then return end local newOwner = newUser.getUsedCharacter local newOwnerId = newOwner.identifier @@ -414,8 +434,11 @@ RegisterServerEvent('bcc-stables:SaveHorseTrade', function(serverId, horseId) if tonumber(horses[i].id) == horseId then MySQL.query.await('UPDATE `player_horses` SET `identifier` = ?, `charid` = ?, `selected` = ? WHERE `id` = ?', { newOwnerId, newOwnerCharId, 0, horseId }) - VORPcore.NotifyRightTip(src, _U('youGave') .. newOwnerName .. _U('aHorse'), 4000) - VORPcore.NotifyRightTip(serverId, curOwnerName .._U('gaveHorse'), 4000) + Core.NotifyRightTip(src, _U('youGave') .. newOwnerName .. _U('aHorse'), 4000) + Core.NotifyRightTip(serverId, curOwnerName .._U('gaveHorse'), 4000) + + + LogToDiscord(curOwnerName, _U('discordTraded') .. newOwnerName) break end end @@ -449,7 +472,7 @@ end) RegisterServerEvent('bcc-stables:OpenInventory', function(id) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end exports.vorp_inventory:openInventory(src, 'horse_' .. tostring(id)) end) @@ -465,14 +488,14 @@ end RegisterServerEvent('bcc-stables:RemoveItem', function(item) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end exports.vorp_inventory:subItem(src, item, 1) end) exports.vorp_inventory:registerUsableItem(Config.horsebrush, function(data) local src = data.source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local item = exports.vorp_inventory:getItem(src, Config.horsebrush) @@ -504,7 +527,7 @@ end) exports.vorp_inventory:registerUsableItem(Config.lantern, function(data) local src = data.source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end local item = exports.vorp_inventory:getItem(src, Config.lantern) @@ -534,9 +557,9 @@ exports.vorp_inventory:registerUsableItem(Config.lantern, function(data) end end) -VORPcore.Callback.Register('bcc-stables:HorseReviveItem', function(source, cb) +Core.Callback.Register('bcc-stables:HorseReviveItem', function(source, cb) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local reviveItem = Config.reviver @@ -549,9 +572,9 @@ VORPcore.Callback.Register('bcc-stables:HorseReviveItem', function(source, cb) cb(true) end) -VORPcore.Callback.Register('bcc-stables:CheckJob', function(source, cb, trainer, site) +Core.Callback.Register('bcc-stables:CheckJob', function(source, cb, trainer, site) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return cb(false) end local Character = user.getUsedCharacter local charJob = Character.job @@ -585,7 +608,7 @@ end RegisterNetEvent('vorp_core:instanceplayers', function(setRoom) local src = source - local user = VORPcore.getUser(src) + local user = Core.getUser(src) if not user then return end if setRoom == 0 then @@ -605,3 +628,5 @@ if not file_exists('./ui/index.html') then print( '^4 Please Download: ^2(bcc-stables.zip) ^4from ^3^0') end + +BccUtils.Versioner.checkFile(GetCurrentResourceName(), 'https://github.com/BryceCanyonCounty/bcc-stables') diff --git a/server/versioncheck.lua b/server/versioncheck.lua deleted file mode 100644 index 2dc258c..0000000 --- a/server/versioncheck.lua +++ /dev/null @@ -1,2 +0,0 @@ -BccUtils = exports['bcc-utils'].initiate() -BccUtils.Versioner.checkFile(GetCurrentResourceName(), 'https://github.com/BryceCanyonCounty/bcc-stables') \ No newline at end of file diff --git a/ui/package.json b/ui/package.json index 87bfff4..27f763d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,7 +1,7 @@ { "name": "bcc-stables", - "version": "1.5.2", + "version": "1.5.3", "private": true, "scripts": { diff --git a/version b/version index 88bac85..d648a1f 100644 --- a/version +++ b/version @@ -1,2 +1,2 @@ -<1.5.2> +<1.5.3> See GitHub for details!