Skip to content

Commit

Permalink
Update v2.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Oct 20, 2024
1 parent 6a8dfa8 commit 66e1cc8
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 14 deletions.
105 changes: 105 additions & 0 deletions client/functions/points.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
local Points = {}
local RegisteredPoints = {}
local closestPoint

local RemovePoint = function(self)
if closestPoint.id and closestPoint.id == self.id then
closestPoint = nil
end

RegisteredPoints[self.id] = nil
end

local ConvertCoords = function(coords)
local coordsType = type(coords)

if coordsType ~= 'vector3' and coordsType ~= 'vec3' then
if coordsType == 'table' then
return vector3(coords[1] or coords.x, coords[2] or coords.y, coords[3] or coords.z)
elseif coordsType == 'vector4' or coordsType == 'vec4' then
return vector3(coords.x, coords.y, coords.z)
end

error(("expected type 'vector3', received type '%s' (value: %s)"):format(coordsType, coords))
end

return coords
end

CreateThread(function()
while true do
local sleep = 250
local coords = MSK.Player.coords

if closestPoint and #(coords - closestPoint.coords) > closestPoint.distance then
closestPoint = nil
end

for k, point in pairs(RegisteredPoints) do
local distance = #(coords - point.coords)

if distance <= point.distance then
point.currentDistance = distance

if closestPoint then
if distance < closestPoint.currentDistance then
closestPoint.isClosest = nil
point.isClosest = true
closestPoint = point
end
elseif distance < point.distance then
point.isClosest = true
closestPoint = point
end

if not point.inside then
point.inside = true

if point.onEnter then
point.onEnter(point)
end
end
elseif point.inside then
point.inside = false
point.currentDistance = nil

if point.onExit then
point.onExit(point)
end
end
end

Wait(sleep)
end
end)

Points.Add = function(properties)
if type(properties) ~= "table" then
return
end

if not properties.coords or not properties.distance then
error(("expected type 'table' for parameter 'properties', received type '%s'"):format(type(properties)))
end

local id = #RegisteredPoints + 1
local self = properties

self.id = id
self.coords = ConvertCoords(self.coords)
self.Remove = RemovePoint

RegisteredPoints[id] = self

return self
end

Points.GetAllPoints = function()
return RegisteredPoints
end

Points.GetClosestPoint = function()
return closestPoint
end

MSK.Points = Points
8 changes: 4 additions & 4 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Config.Framework = 'AUTO'

-- Supported Inventories: default, custom, ox_inventory, qs-inventory
-- For ESX Default Inventory or Chezza Inventory, set to 'default'
-- Set to 'custom' if you use another inventory
-- Set to 'custom' if you use another inventory and add your own functions
-- You can add your own inventory in: server/inventories/custom.lua
Config.Inventory = 'default'
----------------------------------------------------------------
Expand Down Expand Up @@ -57,7 +57,7 @@ Config.DisconnectLogger = {
console = {
enable = false,
-- German: "Der Spieler ^3%s^0 mit der ^3ID %s^0 hat den Server verlassen.\n^4Uhrzeit:^0 %s\n^4Grund:^0 %s\n^4Identifier:^0\n %s\n %s\n %s\n^4Koordinaten:^0 %s"
-- English: "The player ^3%s^0 with the ^3ID %s^0 has left the server.\n^4Time:^0 %s\n^4Reason:^0 %s\n^4Identifier:^0\n %s\n %s\n %s\n^4Coordinates:^0 %s"
-- English: "The player ^3%s^0 with the ^3ID %s^0 has left the server.\n^4Time:^0 %s\n^4Reason:^0 %s\n^4Identifier:^0\n %s\n %s\n %s\n^4Coordinates:^0 %s"
text = "Der Spieler ^3%s^0 mit der ^3ID %s^0 hat den Server verlassen.\n^4Uhrzeit:^0 %s\n^4Grund:^0 %s\n^4Identifier:^0\n %s\n %s\n %s\n^4Koordinaten:^0 %s"
},

Expand All @@ -73,7 +73,7 @@ Config.DisconnectLogger = {
}
}
----------------------------------------------------------------
-- For more Information go to: https://github.com/MSK-Scripts/msk_bansystem/blob/main/README.md
-- For more Information go to: https://docu.msk-scripts.de/msk-core/functions/server/ban-system
Config.BanSystem = {
enable = true, -- Set to true if you want to use this Feature

Expand All @@ -83,7 +83,7 @@ Config.BanSystem = {
botAvatar = "https://i.imgur.com/PizJGsh.png",

commands = {
enable = false,
enable = true,
groups = {'superadmin', 'admin', 'god'},
ban = 'banPlayer',
unban = 'unbanPlayer'
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_core'
description 'Functions for MSK Scripts'
version '2.6.5'
version '2.6.6'

lua54 'yes'

Expand Down
50 changes: 41 additions & 9 deletions server/functions/ace.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
MSK.IsAceAllowed = function(playerId, command)
return IsPlayerAceAllowed(playerId, ('command.%s'):format(command))
if not MSK.String.StartsWith(command, 'command.') then
command = ('command.%s'):format(command)
end

return IsPlayerAceAllowed(playerId, command)
end
exports('IsAceAllowed', MSK.IsAceAllowed)

Expand All @@ -21,23 +25,39 @@ local allowAce = function(allow)
end

MSK.AddAce = function(principal, ace, allow)
if type(principal) == 'string' then
principal = 'group.' .. principal
elseif type(principal) == 'number' then
principal = 'player.' .. principal
if not MSK.String.StartsWith(principal, 'group.') and not MSK.String.StartsWith(principal, 'player.') then
if type(principal) == 'string' then
principal = 'group.' .. principal
elseif type(principal) == 'number' then
principal = 'player.' .. principal
end
end

if not MSK.String.StartsWith(ace, 'command.') then
ace = ('command.%s'):format(ace)
end

logging('debug', 'MSK.AddAce', principal, ace, allowAce(allow))

ExecuteCommand(('add_ace %s %s %s'):format(principal, ace, allowAce(allow)))
end
exports('AddAce', MSK.AddAce)

MSK.RemoveAce = function(principal, ace, allow)
if type(principal) == 'string' then
principal = 'group.' .. principal
elseif type(principal) == 'number' then
principal = 'player.' .. principal
if not MSK.String.StartsWith(principal, 'group.') and not MSK.String.StartsWith(principal, 'player.') then
if type(principal) == 'string' then
principal = 'group.' .. principal
elseif type(principal) == 'number' then
principal = 'player.' .. principal
end
end

if not MSK.String.StartsWith(ace, 'command.') then
ace = ('command.%s'):format(ace)
end

logging('debug', 'MSK.RemoveAce', principal, ace, allowAce(allow))

ExecuteCommand(('remove_ace %s %s %s'):format(principal, ace, allowAce(allow)))
end
exports('RemoveAce', MSK.RemoveAce)
Expand All @@ -47,6 +67,12 @@ MSK.AddPrincipal = function(child, parent)
principal = 'player.' .. principal
end

if not MSK.String.StartsWith(parent, 'group.') then
parent = ('group.%s'):format(parent)
end

logging('debug', 'MSK.AddPrincipal', child, parent)

ExecuteCommand(('add_principal %s %s'):format(child, parent))
end
exports('AddPrincipal', MSK.AddPrincipal)
Expand All @@ -56,6 +82,12 @@ MSK.RemovePrincipal = function(child, parent)
principal = 'player.' .. principal
end

if not MSK.String.StartsWith(parent, 'group.') then
parent = ('group.%s'):format(parent)
end

logging('debug', 'MSK.RemovePrincipal', child, parent)

ExecuteCommand(('remove_principal %s %s'):format(child, parent))
end
exports('RemovePrincipal', MSK.RemovePrincipal)
4 changes: 4 additions & 0 deletions server/functions/bansystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ exports('UnbanPlayer', MSK.UnbanPlayer)
exports('unbanPlayer', MSK.UnbanPlayer) -- Support for old Scripts

if Config.BanSystem.enable and Config.BanSystem.commands.enable then
while not MSK.RegisterCommand do
Wait(10)
end

MSK.RegisterCommand(Config.BanSystem.commands.ban, function(source, args, raw)
local playerId = source
local targetId, time, reason = args.playerId, args.time, args.reason
Expand Down

0 comments on commit 66e1cc8

Please sign in to comment.