Skip to content

Commit 66e1cc8

Browse files
committed
Update v2.6.6
1 parent 6a8dfa8 commit 66e1cc8

File tree

5 files changed

+155
-14
lines changed

5 files changed

+155
-14
lines changed

client/functions/points.lua

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
local Points = {}
2+
local RegisteredPoints = {}
3+
local closestPoint
4+
5+
local RemovePoint = function(self)
6+
if closestPoint.id and closestPoint.id == self.id then
7+
closestPoint = nil
8+
end
9+
10+
RegisteredPoints[self.id] = nil
11+
end
12+
13+
local ConvertCoords = function(coords)
14+
local coordsType = type(coords)
15+
16+
if coordsType ~= 'vector3' and coordsType ~= 'vec3' then
17+
if coordsType == 'table' then
18+
return vector3(coords[1] or coords.x, coords[2] or coords.y, coords[3] or coords.z)
19+
elseif coordsType == 'vector4' or coordsType == 'vec4' then
20+
return vector3(coords.x, coords.y, coords.z)
21+
end
22+
23+
error(("expected type 'vector3', received type '%s' (value: %s)"):format(coordsType, coords))
24+
end
25+
26+
return coords
27+
end
28+
29+
CreateThread(function()
30+
while true do
31+
local sleep = 250
32+
local coords = MSK.Player.coords
33+
34+
if closestPoint and #(coords - closestPoint.coords) > closestPoint.distance then
35+
closestPoint = nil
36+
end
37+
38+
for k, point in pairs(RegisteredPoints) do
39+
local distance = #(coords - point.coords)
40+
41+
if distance <= point.distance then
42+
point.currentDistance = distance
43+
44+
if closestPoint then
45+
if distance < closestPoint.currentDistance then
46+
closestPoint.isClosest = nil
47+
point.isClosest = true
48+
closestPoint = point
49+
end
50+
elseif distance < point.distance then
51+
point.isClosest = true
52+
closestPoint = point
53+
end
54+
55+
if not point.inside then
56+
point.inside = true
57+
58+
if point.onEnter then
59+
point.onEnter(point)
60+
end
61+
end
62+
elseif point.inside then
63+
point.inside = false
64+
point.currentDistance = nil
65+
66+
if point.onExit then
67+
point.onExit(point)
68+
end
69+
end
70+
end
71+
72+
Wait(sleep)
73+
end
74+
end)
75+
76+
Points.Add = function(properties)
77+
if type(properties) ~= "table" then
78+
return
79+
end
80+
81+
if not properties.coords or not properties.distance then
82+
error(("expected type 'table' for parameter 'properties', received type '%s'"):format(type(properties)))
83+
end
84+
85+
local id = #RegisteredPoints + 1
86+
local self = properties
87+
88+
self.id = id
89+
self.coords = ConvertCoords(self.coords)
90+
self.Remove = RemovePoint
91+
92+
RegisteredPoints[id] = self
93+
94+
return self
95+
end
96+
97+
Points.GetAllPoints = function()
98+
return RegisteredPoints
99+
end
100+
101+
Points.GetClosestPoint = function()
102+
return closestPoint
103+
end
104+
105+
MSK.Points = Points

config.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Config.Framework = 'AUTO'
99

1010
-- Supported Inventories: default, custom, ox_inventory, qs-inventory
1111
-- For ESX Default Inventory or Chezza Inventory, set to 'default'
12-
-- Set to 'custom' if you use another inventory
12+
-- Set to 'custom' if you use another inventory and add your own functions
1313
-- You can add your own inventory in: server/inventories/custom.lua
1414
Config.Inventory = 'default'
1515
----------------------------------------------------------------
@@ -57,7 +57,7 @@ Config.DisconnectLogger = {
5757
console = {
5858
enable = false,
5959
-- 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"
60-
-- 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"
60+
-- 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"
6161
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"
6262
},
6363

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

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

8585
commands = {
86-
enable = false,
86+
enable = true,
8787
groups = {'superadmin', 'admin', 'god'},
8888
ban = 'banPlayer',
8989
unban = 'unbanPlayer'

fxmanifest.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ games { 'gta5' }
44
author 'Musiker15 - MSK Scripts'
55
name 'msk_core'
66
description 'Functions for MSK Scripts'
7-
version '2.6.5'
7+
version '2.6.6'
88

99
lua54 'yes'
1010

server/functions/ace.lua

+41-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
MSK.IsAceAllowed = function(playerId, command)
2-
return IsPlayerAceAllowed(playerId, ('command.%s'):format(command))
2+
if not MSK.String.StartsWith(command, 'command.') then
3+
command = ('command.%s'):format(command)
4+
end
5+
6+
return IsPlayerAceAllowed(playerId, command)
37
end
48
exports('IsAceAllowed', MSK.IsAceAllowed)
59

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

2327
MSK.AddAce = function(principal, ace, allow)
24-
if type(principal) == 'string' then
25-
principal = 'group.' .. principal
26-
elseif type(principal) == 'number' then
27-
principal = 'player.' .. principal
28+
if not MSK.String.StartsWith(principal, 'group.') and not MSK.String.StartsWith(principal, 'player.') then
29+
if type(principal) == 'string' then
30+
principal = 'group.' .. principal
31+
elseif type(principal) == 'number' then
32+
principal = 'player.' .. principal
33+
end
2834
end
2935

36+
if not MSK.String.StartsWith(ace, 'command.') then
37+
ace = ('command.%s'):format(ace)
38+
end
39+
40+
logging('debug', 'MSK.AddAce', principal, ace, allowAce(allow))
41+
3042
ExecuteCommand(('add_ace %s %s %s'):format(principal, ace, allowAce(allow)))
3143
end
3244
exports('AddAce', MSK.AddAce)
3345

3446
MSK.RemoveAce = function(principal, ace, allow)
35-
if type(principal) == 'string' then
36-
principal = 'group.' .. principal
37-
elseif type(principal) == 'number' then
38-
principal = 'player.' .. principal
47+
if not MSK.String.StartsWith(principal, 'group.') and not MSK.String.StartsWith(principal, 'player.') then
48+
if type(principal) == 'string' then
49+
principal = 'group.' .. principal
50+
elseif type(principal) == 'number' then
51+
principal = 'player.' .. principal
52+
end
53+
end
54+
55+
if not MSK.String.StartsWith(ace, 'command.') then
56+
ace = ('command.%s'):format(ace)
3957
end
4058

59+
logging('debug', 'MSK.RemoveAce', principal, ace, allowAce(allow))
60+
4161
ExecuteCommand(('remove_ace %s %s %s'):format(principal, ace, allowAce(allow)))
4262
end
4363
exports('RemoveAce', MSK.RemoveAce)
@@ -47,6 +67,12 @@ MSK.AddPrincipal = function(child, parent)
4767
principal = 'player.' .. principal
4868
end
4969

70+
if not MSK.String.StartsWith(parent, 'group.') then
71+
parent = ('group.%s'):format(parent)
72+
end
73+
74+
logging('debug', 'MSK.AddPrincipal', child, parent)
75+
5076
ExecuteCommand(('add_principal %s %s'):format(child, parent))
5177
end
5278
exports('AddPrincipal', MSK.AddPrincipal)
@@ -56,6 +82,12 @@ MSK.RemovePrincipal = function(child, parent)
5682
principal = 'player.' .. principal
5783
end
5884

85+
if not MSK.String.StartsWith(parent, 'group.') then
86+
parent = ('group.%s'):format(parent)
87+
end
88+
89+
logging('debug', 'MSK.RemovePrincipal', child, parent)
90+
5991
ExecuteCommand(('remove_principal %s %s'):format(child, parent))
6092
end
6193
exports('RemovePrincipal', MSK.RemovePrincipal)

server/functions/bansystem.lua

+4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ exports('UnbanPlayer', MSK.UnbanPlayer)
230230
exports('unbanPlayer', MSK.UnbanPlayer) -- Support for old Scripts
231231

232232
if Config.BanSystem.enable and Config.BanSystem.commands.enable then
233+
while not MSK.RegisterCommand do
234+
Wait(10)
235+
end
236+
233237
MSK.RegisterCommand(Config.BanSystem.commands.ban, function(source, args, raw)
234238
local playerId = source
235239
local targetId, time, reason = args.playerId, args.time, args.reason

0 commit comments

Comments
 (0)