mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
fix: non existing groups issues
This commit is contained in:
@@ -28,14 +28,36 @@ end, true, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
NDCore.Functions.AddCommand("setjob", "Admin command, set player job.", function(source, args, rawCommand)
|
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])
|
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)
|
local character = NDCore.Functions.GetPlayer(target)
|
||||||
NDCore.Functions.SetPlayerJob(character.id, args[2], args[3])
|
NDCore.Functions.SetPlayerJob(character.id, job, args[3])
|
||||||
end, true, {
|
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="player", help="Player server id" },
|
||||||
{ name="job name" },
|
{ name="job name" },
|
||||||
{ name="rank", help="This should be a number, default value is 1." }
|
{ name="rank", help="This should be a number, default value is 1." }
|
||||||
@@ -45,13 +67,35 @@ NDCore.Functions.AddCommand("setgroup", "Admin command, set player group.", func
|
|||||||
if not NDCore.Functions.IsPlayerAdmin(source) then return end
|
if not NDCore.Functions.IsPlayerAdmin(source) then return end
|
||||||
|
|
||||||
local target = tonumber(args[1])
|
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)
|
local character = NDCore.Functions.GetPlayer(target)
|
||||||
if args[2] == "remove" then
|
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
|
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
|
||||||
end, false, {
|
end, false, {
|
||||||
{ name="player", help="Player server id" },
|
{ 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]
|
local amount = args[1]
|
||||||
if not amount or amount == 0 then return end
|
if not amount or amount == 0 then return end
|
||||||
NDCore.Functions.GiveCashToNearbyPlayer(source, amount)
|
NDCore.Functions.GiveCashToNearbyPlayer(source, amount)
|
||||||
|
return {
|
||||||
|
color = {0, 255, 0},
|
||||||
|
args = {"Success", amount .. " paid."}
|
||||||
|
}
|
||||||
end, true, {
|
end, true, {
|
||||||
{ name="Amount" },
|
{ name="Amount" },
|
||||||
})
|
})
|
||||||
@@ -542,9 +542,13 @@ function NDCore.Functions.SetPlayerToGroup(characterId, group, rank)
|
|||||||
if not data.groups then
|
if not data.groups then
|
||||||
data.groups = {}
|
data.groups = {}
|
||||||
end
|
end
|
||||||
|
local rankName = tostring(groupRank)
|
||||||
|
if config.groups[group] and config.groups[group][groupRank] then
|
||||||
|
rankName = config.groups[group][groupRank]
|
||||||
|
end
|
||||||
data.groups[group] = {
|
data.groups[group] = {
|
||||||
rank = groupRank,
|
rank = groupRank,
|
||||||
rankName = config.groups[group][groupRank]
|
rankName = rankName
|
||||||
}
|
}
|
||||||
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
||||||
return true
|
return true
|
||||||
@@ -556,9 +560,13 @@ function NDCore.Functions.SetPlayerToGroup(characterId, group, rank)
|
|||||||
if not data.groups then
|
if not data.groups then
|
||||||
data.groups = {}
|
data.groups = {}
|
||||||
end
|
end
|
||||||
|
local rankName = tostring(groupRank)
|
||||||
|
if config.groups[group] and config.groups[group][groupRank] then
|
||||||
|
rankName = config.groups[group][groupRank]
|
||||||
|
end
|
||||||
data.groups[group] = {
|
data.groups[group] = {
|
||||||
rank = groupRank,
|
rank = groupRank,
|
||||||
rankName = config.groups[group][groupRank]
|
rankName = rankName
|
||||||
}
|
}
|
||||||
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
NDCore.Functions.SetPlayerData(characterId, "groups", data.groups)
|
||||||
return true
|
return true
|
||||||
@@ -615,10 +623,12 @@ function NDCore.Functions.AddCommand(name, help, callback, argsrequired, argumen
|
|||||||
return TriggerClientEvent("chat:addMessage", source, {
|
return TriggerClientEvent("chat:addMessage", source, {
|
||||||
color = {255, 0, 0},
|
color = {255, 0, 0},
|
||||||
multiline = true,
|
multiline = true,
|
||||||
args = {"System", "All arguments must be filled out!"}
|
args = {"Error", "all arguments required."}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
callback(source, args, rawCommand)
|
local message = callback(source, args, rawCommand)
|
||||||
|
if not message then return end
|
||||||
|
TriggerClientEvent("chat:addMessage", source, message)
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
NDCore.Commands[commandName] = {
|
NDCore.Commands[commandName] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user