From 93e704832f18c7a4a847dd80d5956aa1f043c428 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Wed, 30 Nov 2022 03:35:15 +0100 Subject: [PATCH] feat: admin commands --- server/commands.lua | 68 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/server/commands.lua b/server/commands.lua index 78cec7c..5b224e3 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -1,5 +1,69 @@ +NDCore.Functions.AddCommand("setmoney", "Admin command, manage player money.", function(source, args, rawCommand) + if not NDCore.Functions.IsPlayerAdmin(source) then return end + local target = tonumber(args[1]) + local action = args[2] + local moneyType = args[3]:lower() + local amount = tonumber(args[4]) + + if not target or GetPlayerPing(target) == 0 then return end + if action ~= "remove" and action ~= "add" and action ~= "set" then return end + if moneyType ~= "bank" and moneyType ~= "cash" then return end - + if action == "remove" then + if not amount or amount < 1 then return end + NDCore.Functions.DeductMoney(amount, target, moneyType) + elseif action == "add" then + if not amount or amount < 1 then return end + NDCore.Functions.AddMoney(amount, target, moneyType) + elseif action == "set" then + local character = NDCore.Functions.GetPlayer(target) + NDCore.Functions.SetPlayerData(character.id, moneyType, amount) end -end \ No newline at end of file +end, true, { + { name="player", help="Player server id" }, + { name="action", help="remove/add/set" }, + { name="type", help="bank/cash" }, + { name="amount" } +}) + +NDCore.Functions.AddCommand("setjob", "Admin command, set player job.", function(source, args, rawCommand) + if not NDCore.Functions.IsPlayerAdmin(source) then return end + + local target = tonumber(args[1]) + if not target or GetPlayerPing(target) == 0 then return end + + local character = NDCore.Functions.GetPlayer(target) + NDCore.Functions.SetPlayerJob(character.id, args[2], args[3]) +end, true, { + { name="player", help="Player server id" }, + { name="job name" }, + { name="rank", help="This should be a number, default value is 1." } +}) + +NDCore.Functions.AddCommand("setgroup", "Admin command, set player group.", function(source, args, rawCommand) + if not NDCore.Functions.IsPlayerAdmin(source) then return end + + local target = tonumber(args[1]) + if not target or GetPlayerPing(target) == 0 then return end + + local character = NDCore.Functions.GetPlayer(target) + if args[2] == "remove" then + NDCore.Functions.RemovePlayerFromGroup(character.id, args[3]) + elseif args[2] == "add" then + NDCore.Functions.SetPlayerToGroup(character.id, args[3], args[4]) + end +end, false, { + { name="player", help="Player server id" }, + { name="action", help="remove/add"}, + { name="group", help="Group name, make sure it's correct or it won't work."}, + { name="rank", help="This should be a number, default value is 1 (not required if removing)." } +}) + +NDCore.Functions.AddCommand("pay", "give cash to a nearby player", function(source, args, rawCommand) + local amount = args[1] + if not amount or amount == 0 then return end + NDCore.Functions.GiveCashToNearbyPlayer(source, amount) +end, true, { + { name="Amount" }, +}) \ No newline at end of file