fix: non existing groups issues

This commit is contained in:
Andyyy7666
2022-12-02 22:40:21 +01:00
parent 12b30c30d6
commit 59574278a4
2 changed files with 70 additions and 12 deletions

View File

@@ -28,14 +28,36 @@ end, true, {
})
NDCore.Functions.AddCommand("setjob", "Admin command, set player job.", function(source, args, rawCommand)
if not NDCore.Functions.IsPlayerAdmin(source) then return end
if not NDCore.Functions.IsPlayerAdmin(source) then
return {
color = {255, 0, 0},
args = {"Error", "you don't have access to this command."}
}
end
local target = tonumber(args[1])
if not target or GetPlayerPing(target) == 0 then return end
if not target or GetPlayerPing(target) == 0 then
return {
color = {255, 0, 0},
args = {"Error", "target player not found."}
}
end
local job = args[2]
if not job then
return {
color = {255, 0, 0},
args = {"Error", "job required."}
}
end
local character = NDCore.Functions.GetPlayer(target)
NDCore.Functions.SetPlayerJob(character.id, args[2], args[3])
end, true, {
NDCore.Functions.SetPlayerJob(character.id, job, args[3])
return {
color = {0, 255, 0},
args = {"Success", GetPlayerName(target) .. " job set to " .. job .. (args[3] and " rank " .. args[3] or " rank 1.")}
}
end, false, {
{ name="player", help="Player server id" },
{ name="job name" },
{ name="rank", help="This should be a number, default value is 1." }
@@ -43,15 +65,37 @@ end, true, {
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
if not target or GetPlayerPing(target) == 0 then
return {
color = {255, 0, 0},
args = {"Error", "target player not found."}
}
end
local group = args[3]
if not group then
return {
color = {255, 0, 0},
args = {"Error", "group required."}
}
end
local character = NDCore.Functions.GetPlayer(target)
if args[2] == "remove" then
NDCore.Functions.RemovePlayerFromGroup(character.id, args[3])
NDCore.Functions.RemovePlayerFromGroup(character.id, group)
return {
color = {0, 255, 0},
args = {"Success", GetPlayerName(target) .. " removed from " .. group}
}
elseif args[2] == "add" then
NDCore.Functions.SetPlayerToGroup(character.id, args[3], args[4])
local rank = args[4]
NDCore.Functions.SetPlayerToGroup(character.id, group, rank)
return {
color = {0, 255, 0},
args = {"Success", GetPlayerName(target) .. " added to " .. group .. (rank and " rank " .. rank or " rank 1.")}
}
end
end, false, {
{ name="player", help="Player server id" },
@@ -64,6 +108,10 @@ NDCore.Functions.AddCommand("pay", "give cash to a nearby player", function(sour
local amount = args[1]
if not amount or amount == 0 then return end
NDCore.Functions.GiveCashToNearbyPlayer(source, amount)
return {
color = {0, 255, 0},
args = {"Success", amount .. " paid."}
}
end, true, {
{ name="Amount" },
})