mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
feat: locales
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
local moneyTypes = {"bank", "cash"}
|
||||
local moneyActions = {
|
||||
remove = function(player, account, amount)
|
||||
player.deductMoney(account, amount, "Staff action")
|
||||
return ("Removed $%d (%s) to %s"):format(amount, account, player.name), ("removed $%d from %s"):format(amount, account)
|
||||
player.deductMoney(account, amount, locale("staff_action"))
|
||||
return locale("staff_money_removed", amount, account, player.name), locale("user_money_removed", amount, account)
|
||||
end,
|
||||
add = function(player, account, amount)
|
||||
player.addMoney(account, amount, "Staff action")
|
||||
return ("Added $%d (%s) to %s"):format(amount, account, player.name), ("added $%d to %s"):format(amount, account)
|
||||
player.addMoney(account, amount, locale("staff_action"))
|
||||
return locale("staff_money_added", amount, account, player.name), locale("user_money_added", amount, account)
|
||||
end,
|
||||
set = function(player, account, amount)
|
||||
player.setData(account, amount, "Staff action")
|
||||
return ("Set %s's (%s) to $%d"):format(player.name, account, amount), ("set %s to $%d"):format(account, amount)
|
||||
player.setData(account, amount, locale("staff_action"))
|
||||
return locale("staff_money_set", player.name, account, amount), locale("user_money_set", account, amount)
|
||||
end
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ lib.addCommand("setmoney", {
|
||||
local staffMessage, userMessage = action(player, moneyType, args.amount)
|
||||
|
||||
player.notify({
|
||||
title = "Staff action",
|
||||
title = locale("staff_action"),
|
||||
description = userMessage,
|
||||
type = "inform",
|
||||
duration = 10000
|
||||
@@ -58,7 +58,7 @@ lib.addCommand("setmoney", {
|
||||
TriggerClientEvent("chat:addMessage", source, {
|
||||
color = {50, 100, 235},
|
||||
multiline = true,
|
||||
args = {"Staff action", staffMessage}
|
||||
args = {locale("staff_action"), staffMessage}
|
||||
})
|
||||
end)
|
||||
|
||||
@@ -90,8 +90,8 @@ lib.addCommand("setjob", {
|
||||
local jobInfo = player.setJob(job, args.rank)
|
||||
if not player or not jobInfo then return end
|
||||
player.notify({
|
||||
title = "Staff action",
|
||||
description = ("Job updated to %s, rank %s"):format(jobInfo.label, jobInfo.rankName),
|
||||
title = locale("staff_action"),
|
||||
description = locale("job_updated_noti", jobInfo.label, jobInfo.rankName),
|
||||
type = "inform",
|
||||
duration = 10000
|
||||
})
|
||||
@@ -100,7 +100,7 @@ lib.addCommand("setjob", {
|
||||
TriggerClientEvent("chat:addMessage", source, {
|
||||
color = {50, 100, 235},
|
||||
multiline = true,
|
||||
args = {"Staff action", "success"}
|
||||
args = {locale("staff_action"), locale("success")}
|
||||
})
|
||||
end)
|
||||
|
||||
@@ -137,8 +137,8 @@ lib.addCommand("setgroup", {
|
||||
local groupInfo = player.addGroup(args.group, args.rank)
|
||||
if not groupInfo then return end
|
||||
player.notify({
|
||||
title = "Staff action",
|
||||
description = ("Added to group %s, rank %s."):format(groupInfo.label, groupInfo.rankName),
|
||||
title = locale("staff_action"),
|
||||
description = locale("group_added_noti", groupInfo.label, groupInfo.rankName),
|
||||
type = "inform",
|
||||
duration = 10000
|
||||
})
|
||||
@@ -146,8 +146,8 @@ lib.addCommand("setgroup", {
|
||||
local groupInfo = player.removeGroup(args.group)
|
||||
if not groupInfo then return end
|
||||
player.notify({
|
||||
title = "Staff action",
|
||||
description = ("Removed from group %s."):format(groupInfo.label),
|
||||
title = locale("staff_action"),
|
||||
description = locale("group_removed_noti", groupInfo.label),
|
||||
type = "inform",
|
||||
duration = 10000
|
||||
})
|
||||
@@ -159,7 +159,7 @@ lib.addCommand("setgroup", {
|
||||
TriggerClientEvent("chat:addMessage", source, {
|
||||
color = {50, 100, 235},
|
||||
multiline = true,
|
||||
args = {"Staff action", "success"}
|
||||
args = {locale("staff_action"), locale("success")}
|
||||
})
|
||||
end)
|
||||
|
||||
@@ -214,7 +214,7 @@ lib.addCommand("pay", {
|
||||
if not player or not targetPlayer then
|
||||
return player.notify({
|
||||
title = "Error",
|
||||
description = "No player found",
|
||||
description = locale("no_player_found"),
|
||||
type = "error"
|
||||
})
|
||||
end
|
||||
@@ -222,7 +222,7 @@ lib.addCommand("pay", {
|
||||
if player.cash < args.amount then
|
||||
return player.notify({
|
||||
title = "Error",
|
||||
description = "You don't have enough cash",
|
||||
description = locale("not_enough_cash"),
|
||||
type = "error"
|
||||
})
|
||||
end
|
||||
@@ -232,7 +232,7 @@ lib.addCommand("pay", {
|
||||
if #(playerCoords-targetCoords) > 2.0 then
|
||||
return player.notify({
|
||||
title = "Error",
|
||||
description = "Player is not nearby",
|
||||
description = locale("player_not_nearby"),
|
||||
type = "error"
|
||||
})
|
||||
end
|
||||
@@ -240,22 +240,22 @@ lib.addCommand("pay", {
|
||||
local success = player.deductMoney("cash", args.amount) and targetPlayer.addMoney("cash", args.amount)
|
||||
if not success then
|
||||
return player.notify({
|
||||
title = "Couldn't give money",
|
||||
title = locale("cant_give_money"),
|
||||
type = "error",
|
||||
duration = 5000
|
||||
})
|
||||
end
|
||||
|
||||
targetPlayer.notify({
|
||||
title = "Money received",
|
||||
description = ("Received $%d in cash"):format(args.amount),
|
||||
title = locale("money_received"),
|
||||
description = locale("money_received2", args.amount),
|
||||
type = "inform",
|
||||
duration = 5000
|
||||
})
|
||||
|
||||
player.notify({
|
||||
title = "Money given",
|
||||
description = ("You gave $%d in cash"):format(args.amount),
|
||||
title = locale("money_given"),
|
||||
description = locale("money_given2", args.amount),
|
||||
type = "inform",
|
||||
duration = 5000
|
||||
})
|
||||
@@ -323,12 +323,13 @@ lib.addCommand("dv", {
|
||||
count = 1
|
||||
end
|
||||
|
||||
local messageLabel = ("%s [dv]"):format(locale("staff_action"))
|
||||
if count == 0 then
|
||||
message = {"Staff action [dv]", "no vehicles found"}
|
||||
message = {messageLabel, "no vehicles found"}
|
||||
elseif count == 1 then
|
||||
message = {"Staff action [dv]", "deleted 1 vehicle"}
|
||||
message = {messageLabel, "deleted 1 vehicle"}
|
||||
else
|
||||
message = {"Staff action [dv]", ("deleted %d vehicles"):format(count)}
|
||||
message = {messageLabel, ("deleted %d vehicles"):format(count)}
|
||||
end
|
||||
|
||||
TriggerClientEvent("chat:addMessage", source, {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
lib.locale()
|
||||
NDCore = {}
|
||||
NDCore.players = {}
|
||||
PlayersInfo = {}
|
||||
@@ -117,12 +118,12 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
||||
if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" then
|
||||
discordInfo = checkDiscordIdentifier(identifiers)
|
||||
if not discordInfo and Config.discordMemeberRequired and not Config.sv_lan then
|
||||
deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite))
|
||||
deferrals.done(locale("not_in_discord", Config.discordInvite))
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
deferrals.update("Connecting...")
|
||||
deferrals.update(locale("connecting"))
|
||||
Wait(0)
|
||||
|
||||
if Config.sv_lan then
|
||||
@@ -143,7 +144,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
||||
}
|
||||
deferrals.done()
|
||||
else
|
||||
deferrals.done(("Your %s was not found."):format(Config.characterIdentifier))
|
||||
deferrals.done(locale("identifier_not_found", Config.characterIdentifier))
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
@@ -164,6 +165,7 @@ AddEventHandler("onResourceStop", function(name)
|
||||
end)
|
||||
|
||||
MySQL.ready(function()
|
||||
Wait(100)
|
||||
NDCore.loadSQL({
|
||||
"database/characters.sql",
|
||||
"database/vehicles.sql"
|
||||
|
||||
@@ -66,7 +66,7 @@ local function createCharacterTable(info)
|
||||
function self.depositMoney(amount)
|
||||
local amount = tonumber(amount)
|
||||
if not amount or self.cash < amount or amount <= 0 then return end
|
||||
return self.deductMoney("cash", amount, "Deposit") and self.addMoney("bank", amount, "Deposit")
|
||||
return self.deductMoney("cash", amount, locale("deposit")) and self.addMoney("bank", amount, locale("deposit"))
|
||||
end
|
||||
|
||||
---@param amount number
|
||||
@@ -74,7 +74,7 @@ local function createCharacterTable(info)
|
||||
function self.withdrawMoney(amount)
|
||||
local amount = tonumber(amount)
|
||||
if not amount or self.bank < amount or amount <= 0 then return end
|
||||
return self.deductMoney("bank", amount, "Withdraw") and self.addMoney("cash", amount, "Withdraw")
|
||||
return self.deductMoney("bank", amount, locale("withdraw")) and self.addMoney("cash", amount, locale("withdraw"))
|
||||
end
|
||||
|
||||
---@param data string
|
||||
|
||||
@@ -405,14 +405,14 @@ function NDCore.transferVehicleOwnership(vehicleId, fromSource, toSource)
|
||||
end
|
||||
|
||||
playerFrom.notify({
|
||||
title = "Ownership transfered",
|
||||
description = ("Vehicle ownership of %s has been transfered."):format(vehicle.plate),
|
||||
title = locale("vehicle_ownership_transfered"),
|
||||
description = locale("vehicle_ownership_transfered2", vehicle.plate),
|
||||
position = "bottom-right",
|
||||
type = "success"
|
||||
})
|
||||
playerTo.notify({
|
||||
title = "Ownership received",
|
||||
description = ("Received vehicle ownership of %s."):format(vehicle.plate),
|
||||
title = locale("vehicle_ownership_received"),
|
||||
description = locale("vehicle_ownership_received2", vehicle.plate),
|
||||
position = "bottom-right"
|
||||
})
|
||||
return true
|
||||
@@ -446,15 +446,15 @@ function NDCore.shareVehicleKeys(source, target, vehicle)
|
||||
local plate = GetVehicleNumberPlateText(vehicle)
|
||||
|
||||
player.notify({
|
||||
title = "Keys shared",
|
||||
description = ("You've shared vehicle keys to %s."):format(plate),
|
||||
title = locale("keys_shared"),
|
||||
description = locale("keys_shared2", plate),
|
||||
position = "bottom-right",
|
||||
type = "success",
|
||||
type = "success"
|
||||
})
|
||||
targetPlayer.notify({
|
||||
title = "Keys received",
|
||||
description = ("Received vehicle keys to %s."):format(plate),
|
||||
position = "bottom-right",
|
||||
title = locale("keys_received"),
|
||||
description = locale("keys_received2", plate),
|
||||
position = "bottom-right"
|
||||
})
|
||||
return true
|
||||
end
|
||||
@@ -504,16 +504,16 @@ local function toggleVehicleLock(source, entity, nearby, metadata)
|
||||
|
||||
if metadata and not metadata.keyEnabled then
|
||||
return player.notify({
|
||||
title = "No signal",
|
||||
description = "Vehicle key disabled.",
|
||||
title = locale("no_signal"),
|
||||
description = locale("veh_key_disabled"),
|
||||
type = "error",
|
||||
position = "bottom-right",
|
||||
duration = 3000
|
||||
})
|
||||
elseif not nearby then
|
||||
return player.notify({
|
||||
title = "No signal",
|
||||
description = "Vehicle to far away.",
|
||||
title = locale("no_signal"),
|
||||
description = locale("veh_far_away"),
|
||||
type = "error",
|
||||
position = "bottom-right",
|
||||
duration = 3000
|
||||
@@ -527,16 +527,16 @@ local function toggleVehicleLock(source, entity, nearby, metadata)
|
||||
player.triggerEvent("ND_Vehicles:keyFob", vehicle.netId)
|
||||
if locked then
|
||||
return player.notify({
|
||||
title = "LOCKED",
|
||||
description = "Your vehicle has now been locked.",
|
||||
title = locale("veh_locked"),
|
||||
description = locale("veh_locked2"),
|
||||
type = "success",
|
||||
position = "bottom-right",
|
||||
duration = 3000
|
||||
})
|
||||
end
|
||||
player.notify({
|
||||
title = "UNLOCKED",
|
||||
description = "Your vehicle has now been unlocked.",
|
||||
title = locale("veh_unlocked"),
|
||||
description = locale("veh_unlocked2"),
|
||||
type = "inform",
|
||||
position = "bottom-right",
|
||||
duration = 3000
|
||||
@@ -725,16 +725,16 @@ RegisterNetEvent("ND_Vehicles:storeVehicle", function(netId)
|
||||
local player = NDCore.getPlayer(src)
|
||||
if not vehicle.setStatus("stored", true) or not player or player.id ~= vehicle.owner then
|
||||
return player.notify({
|
||||
title = "Garage",
|
||||
description = "No owned vehicle found nearby.",
|
||||
title = locale("garage"),
|
||||
description = locale("no_owned_veh_nearby"),
|
||||
type = "error",
|
||||
position = "bottom",
|
||||
duration = 3000
|
||||
})
|
||||
end
|
||||
player.notify({
|
||||
title = "Garage",
|
||||
description = "Vehicle stored in garage.",
|
||||
title = locale("garage"),
|
||||
description = locale("veh_stored_in_garage"),
|
||||
type = "success",
|
||||
position = "bottom",
|
||||
duration = 3000
|
||||
@@ -767,17 +767,17 @@ RegisterNetEvent("ND_Vehicles:takeVehicle", function(vehId, locations)
|
||||
|
||||
if vehicle.impounded then
|
||||
local reclaimPrice = vehicle.metadata.impoundReclaimPrice or 200
|
||||
if not player.deductMoney("bank", reclaimPrice, "Vehicle impound reclaim") then
|
||||
if not player.deductMoney("bank", reclaimPrice, locale("impound_reclaim")) then
|
||||
return player.notify({
|
||||
title = "Impound",
|
||||
description = ("Price to reclaim is $%d, you don't have enough!"):format(reclaimPrice),
|
||||
title = locale("impound"),
|
||||
description = locale("impound_not_enough", reclaimPrice),
|
||||
type = "error",
|
||||
position = "bottom"
|
||||
})
|
||||
end
|
||||
player.notify({
|
||||
title = "Impound",
|
||||
description = ("Paid $%d to reclaim vehicle!"):format(reclaimPrice),
|
||||
title = locale("impound"),
|
||||
description = locale("impound_paid", reclaimPrice),
|
||||
type = "success",
|
||||
position = "bottom"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user