Skip to content

Commit c614156

Browse files
committed
Update v2.6.7
1 parent 66e1cc8 commit c614156

14 files changed

+280
-149
lines changed

client/functions/disconnectlogger.lua

+2-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ local display = function(data)
3535
CreateThread(function()
3636
while showDisplay do
3737
local sleep = 500
38-
39-
local playerPed = PlayerPedId()
40-
local playerCoords = GetEntityCoords(playerPed)
41-
local dist = #(data.coords - playerCoords)
42-
38+
39+
local dist = #(data.coords - MSK.Player.coords)
4340
local coordsUsed = vec3(data.coords.x, data.coords.y, data.coords.z + 0.2)
4441

4542
if dist <= 20.0 then

client/functions/entities.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GetEntities = function(isPlayerEntity)
55
for _, player in ipairs(GetActivePlayers()) do
66
local ped = GetPlayerPed(player)
77

8-
if DoesEntityExist(ped) and ped ~= PlayerPedId() then
8+
if DoesEntityExist(ped) and ped ~= MSK.Player.ped then
99
entities[player] = ped
1010
end
1111
end
@@ -23,7 +23,7 @@ GetClosestEntity = function(isPlayerEntity, coords)
2323
if coords then
2424
coords = vector3(coords.x, coords.y, coords.z)
2525
else
26-
coords = GetEntityCoords(PlayerPedId())
26+
coords = MSK.Player.coords
2727
end
2828

2929
for k, entity in pairs(entites) do
@@ -44,7 +44,7 @@ GetClosestEntities = function(isPlayerEntity, coords, distance)
4444
if coords then
4545
coords = vector3(coords.x, coords.y, coords.z)
4646
else
47-
coords = GetEntityCoords(PlayerPedId())
47+
coords = MSK.Player.coords
4848
end
4949

5050
for k, entity in pairs(entites) do
@@ -59,14 +59,14 @@ GetClosestEntities = function(isPlayerEntity, coords, distance)
5959
end
6060

6161
PlayerDied = function(deathCause, killer, killerServerId)
62-
local playerPed = PlayerPedId()
63-
local playerCoords = GetEntityCoords(playerPed)
62+
local playerPed = MSK.Player.ped
63+
local playerCoords = MSK.Player.coords
6464

6565
local data = {
6666
killedByPlayer = false,
6767
victim = playerPed,
6868
victimCoords = playerCoords,
69-
victimServerId = GetPlayerServerId(PlayerId())
69+
victimServerId = MSK.Player.serverId
7070
}
7171

7272
if killer and killerServerId then
@@ -93,7 +93,7 @@ AddEventHandler('gameEventTriggered', function(event, data)
9393
local playerPed = entity
9494
local playerDied = data[4]
9595

96-
if playerDied and NetworkGetPlayerIndexFromPed(playerPed) == PlayerId() and (IsPedDeadOrDying(playerPed, true) or IsPedFatallyInjured(playerPed)) then
96+
if playerDied and NetworkGetPlayerIndexFromPed(playerPed) == MSK.Player.clientId and (IsPedDeadOrDying(playerPed, true) or IsPedFatallyInjured(playerPed)) then
9797
local deathCause, killerEntity = GetPedCauseOfDeath(playerPed), GetPedSourceOfDeath(playerPed)
9898
local killer = NetworkGetPlayerIndexFromPed(killerEntity)
9999

client/functions/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ MSK.IsSpawnPointClear = function(coords, maxDistance)
166166
if coords then
167167
coords = vector3(coords.x, coords.y, coords.z)
168168
else
169-
coords = GetEntityCoords(PlayerPedId())
169+
coords = MSK.Player.coords
170170
end
171171

172172
for k, vehicle in pairs(GetGamePool('CVehicle')) do

client/functions/player.lua

+1-11
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ function Player:set(key, value)
1111
end
1212
end
1313

14-
function Player:remove(key)
15-
if self[key] then
16-
TriggerEvent('msk_core:onPlayerRemove', key, self[key])
17-
TriggerServerEvent('msk_core:onPlayerRemove', key, self[key])
18-
self[key] = nil
19-
20-
return true
21-
end
22-
end
23-
2414
Player:set('clientId', PlayerId())
2515
Player:set('serverId', GetPlayerServerId(Player.clientId))
2616
Player:set('playerId', Player.serverId)
@@ -47,7 +37,7 @@ local GetPlayerDeath = function()
4737
end
4838

4939
setmetatable(Player, {
50-
__index = function(self, key)
40+
__index = function(self, key, ...)
5141
if key == 'coords' then
5242
return GetEntityCoords(self.ped)
5343
elseif key == 'heading' then

client/functions/points.lua

+24-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ local RegisteredPoints = {}
33
local closestPoint
44

55
local RemovePoint = function(self)
6-
if closestPoint.id and closestPoint.id == self.id then
6+
if closestPoint and closestPoint.id and closestPoint.id == self.id then
77
closestPoint = nil
88
end
99

10+
if self.onRemove then
11+
self.onRemove(self)
12+
end
13+
1014
RegisteredPoints[self.id] = nil
1115
end
1216

@@ -93,13 +97,32 @@ Points.Add = function(properties)
9397

9498
return self
9599
end
100+
exports('AddPoint', Points.Add)
101+
102+
Points.Remove = function(pointId)
103+
if not RegisteredPoints[pointId] then return false end
104+
RegisteredPoints[pointId].Remove()
105+
return true
106+
end
107+
exports('RemovePoint', Points.Remove)
108+
109+
Points.RemoveAllPoints = function()
110+
for k, point in pairs(RegisteredPoints) do
111+
point.Remove()
112+
end
113+
114+
RegisteredPoints = {}
115+
end
116+
exports('RemoveAllPoints', Points.RemoveAllPoints)
96117

97118
Points.GetAllPoints = function()
98119
return RegisteredPoints
99120
end
121+
exports('GetAllPoints', Points.GetAllPoints)
100122

101123
Points.GetClosestPoint = function()
102124
return closestPoint
103125
end
126+
exports('GetClosestPoint', Points.GetClosestPoint)
104127

105128
MSK.Points = Points

client/functions/progressbar.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ local Controls = {
1919
}
2020

2121
local interrupted = function(data)
22-
if not data.useWhileDead and IsEntityDead(MSK.Player.playerPed) then return true end
23-
if not data.useWhileRagdoll and IsPedRagdoll(MSK.Player.playerPed) then return true end
24-
if not data.useWhileCuffed and IsPedCuffed(MSK.Player.playerPed) then return true end
25-
if not data.useWhileFalling and IsPedFalling(MSK.Player.playerPed) then return true end
26-
if not data.useWhileSwimming and IsPedSwimming(MSK.Player.playerPed) then return true end
22+
if not data.useWhileDead and IsEntityDead(MSK.Player.ped) then return true end
23+
if not data.useWhileRagdoll and IsPedRagdoll(MSK.Player.ped) then return true end
24+
if not data.useWhileCuffed and IsPedCuffed(MSK.Player.ped) then return true end
25+
if not data.useWhileFalling and IsPedFalling(MSK.Player.ped) then return true end
26+
if not data.useWhileSwimming and IsPedSwimming(MSK.Player.ped) then return true end
2727
end
2828

2929
local setProgressData = function(data)
@@ -33,10 +33,10 @@ local setProgressData = function(data)
3333
if anim then
3434
if anim.dict then
3535
MSK.Request.AnimDict(anim.dict)
36-
TaskPlayAnim(MSK.Player.playerPed, anim.dict, anim.anim, anim.blendIn or 3.0, anim.blendOut or 1.0, anim.duration or -1, anim.flag or 49, anim.playbackRate or 0, anim.lockX, anim.lockY, anim.lockZ)
36+
TaskPlayAnim(MSK.Player.ped, anim.dict, anim.anim, anim.blendIn or 3.0, anim.blendOut or 1.0, anim.duration or -1, anim.flag or 49, anim.playbackRate or 0, anim.lockX, anim.lockY, anim.lockZ)
3737
RemoveAnimDict(anim.dict)
3838
elseif anim.scenario then
39-
TaskStartScenarioInPlace(MSK.Player.playerPed, anim.scenario, 0, anim.playEnter ~= nil and anim.playEnter or true)
39+
TaskStartScenarioInPlace(MSK.Player.ped, anim.scenario, 0, anim.playEnter ~= nil and anim.playEnter or true)
4040
end
4141
end
4242

@@ -84,10 +84,10 @@ local setProgressData = function(data)
8484

8585
if anim then
8686
if anim.dict then
87-
StopAnimTask(MSK.Player.playerPed, anim.dict, anim.clip, 1.0)
88-
ClearPedTasks(MSK.Player.playerPed)
87+
StopAnimTask(MSK.Player.ped, anim.dict, anim.clip, 1.0)
88+
ClearPedTasks(MSK.Player.ped)
8989
else
90-
ClearPedTasks(MSK.Player.playerPed)
90+
ClearPedTasks(MSK.Player.ped)
9191
end
9292
end
9393
end

client/functions/request.lua

+34-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ MSK.Request.ScaleformMovie = function(scaleformName, timeout)
2323
end
2424
exports('RequestScaleformMovie', MSK.Request.ScaleformMovie)
2525

26-
setmetatable(MSK.Request, {
27-
__call = function(_, request, hasLoaded, assetType, asset, timeout, ...)
28-
return MSK.Request.Streaming(request, hasLoaded, assetType, asset, timeout, ...)
29-
end
30-
})
31-
3226
MSK.Request.AnimDict = function(animDict)
3327
assert(animDict and type(animDict) == 'string', ("Parameter 'animDict' has to be a 'string' (reveived %s)"):format(type(animDict)))
3428
assert(DoesAnimDictExist(animDict), ("attempted to load invalid animDict '%s'"):format(animDict))
@@ -78,4 +72,37 @@ MSK.Request.TextureDict = function(textureDict)
7872

7973
return MSK.Request(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict)
8074
end
81-
exports('RequestTextureDict', MSK.Request.TextureDict)
75+
exports('RequestTextureDict', MSK.Request.TextureDict)
76+
77+
MSK.Request.Raycast = function(distance, flag)
78+
local flags = {
79+
none = 0,
80+
all = -1,
81+
world = 1,
82+
vehicle = 2,
83+
ped = 4,
84+
object = 16,
85+
water = 32,
86+
glass = 64,
87+
river = 128,
88+
foliage = 256,
89+
}
90+
91+
if type(flag) ~= 'number' then
92+
flag = flags[flag] or -1
93+
end
94+
95+
local destination = GetOffsetFromEntityInWorldCoords(MSK.Player.ped, 0.0, distance or 5.0, 0.0)
96+
local handle = StartShapeTestCapsule(MSK.Player.coords, destination, distance or 5.0, flag or -1, MSK.Player.ped, 4)
97+
98+
local entity = MSK.Timeout.Await(1000, function()
99+
local retval, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(handle)
100+
101+
if retval ~= 1 and hit then
102+
return entityHit ~= 0 and entityHit
103+
end
104+
end, ("Function 'MSK.Request.Raycast' timed out after 1s - no result received from GetShapeTestResult (%s) on function MSK.Request.Raycast"):format(handle))
105+
106+
return entity
107+
end
108+
exports('RequestRaycast', MSK.Request.Raycast)

client/functions/showCoords.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ end
4848
startShowCoordsThread = function()
4949
while showCoords do
5050
local sleep = 1
51-
local playerPed = PlayerPedId()
52-
local playerX, playerY, playerZ = table.unpack(GetEntityCoords(playerPed))
53-
local playerH = GetEntityHeading(playerPed)
51+
52+
local playerX, playerY, playerZ = table.unpack(MSK.Player.coords)
53+
local playerH = MSK.Player.heading
5454

5555
DrawGenericText(("~g~X~w~ = ~r~%s ~g~Y~w~ = ~r~%s ~g~Z~w~ = ~r~%s ~g~H~w~ = ~r~%s~s~"):format(MSK.Math.Round(playerX, 2), MSK.Math.Round(playerY, 2), MSK.Math.Round(playerZ, 2), MSK.Math.Round(playerH, 2)))
5656

client/functions/vehicle.lua

+10-19
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,11 @@ end
2424
exports('GetVehicleWithPlate', MSK.GetVehicleWithPlate)
2525

2626
MSK.GetVehicleInDirection = function(distance)
27-
local playerPed = PlayerPedId()
28-
local playerCoords = GetEntityCoords(playerPed)
29-
local destination = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, distance or 5.0, 0.0)
30-
local handle = StartShapeTestCapsule(playerCoords, destination, distance or 5.0, 2, playerPed, 4)
31-
32-
local entity = MSK.Timeout.Await(1000, function()
33-
local retval, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(handle)
34-
35-
if retval ~= 1 and hit then
36-
return entityHit ~= 0 and entityHit
37-
end
38-
end, "No result received from GetShapeTestResult on function GetVehicleInFront")
27+
local entity = MSK.Request.Raycast(distance, 2)
3928

4029
if DoesEntityExist(entity) then
4130
local entityCoords = GetEntityCoords(entity)
42-
return entity, entityCoords, ('%.2f'):format(#(playerCoords - entityCoords))
31+
return entity, entityCoords, ('%.2f'):format(#(MSK.Player.coords - entityCoords))
4332
end
4433

4534
return entity
@@ -48,8 +37,10 @@ MSK.GetVehicleInFront = MSK.GetVehicleInDirection
4837
exports('GetVehicleInDirection', MSK.GetVehicleInDirection)
4938

5039
MSK.GetPedVehicleSeat = function(playerPed, vehicle)
51-
if not playerPed then playerPed = PlayerPedId() end
52-
if not vehicle then GetVehiclePedIsIn(playerPed, false) end
40+
if not playerPed then playerPed = MSK.Player.ped end
41+
if not vehicle then vehicle = MSK.Player.vehicle end
42+
43+
if not DoesEntityExist(vehicle) then return false end
5344

5445
for i = -1, 16 do
5546
if GetPedInVehicleSeat(vehicle, i) == playerPed then
@@ -85,7 +76,7 @@ MSK.GetVehicleLabel = function(vehicle, model)
8576
vehicleModel = GetEntityModel(vehicle)
8677
end
8778

88-
if model then
79+
if model and not vehicleModel then
8980
if not IsModelValid(model) then
9081
return 'Unknown', error(('The Model does not exist on function MSK.GetVehicleLabel (reveived %s)'):format(model))
9182
end
@@ -132,9 +123,9 @@ local isInVehicle, isEnteringVehicle = false, false
132123
CreateThread(function()
133124
while true do
134125
local sleep = 200
135-
local playerPed = PlayerPedId()
126+
local playerPed = MSK.Player.ped
136127

137-
if not isInVehicle and not IsPlayerDead(PlayerId()) then
128+
if not isInVehicle and not IsPlayerDead(MSK.Player.clientId) then
138129
if DoesEntityExist(GetVehiclePedIsTryingToEnter(playerPed)) and not isEnteringVehicle then
139130
local vehicle = GetVehiclePedIsTryingToEnter(playerPed)
140131
local plate = GetVehicleNumberPlateText(vehicle)
@@ -162,7 +153,7 @@ CreateThread(function()
162153
TriggerServerEvent('msk_core:enteredVehicle', currentVehicle.plate, currentVehicle.seat, currentVehicle.netId, currentVehicle.isEngineOn, currentVehicle.isDamaged)
163154
end
164155
elseif isInVehicle then
165-
if not IsPedInAnyVehicle(playerPed, false) or IsPlayerDead(PlayerId()) then
156+
if not IsPedInAnyVehicle(playerPed, false) or IsPlayerDead(MSK.Player.clientId) then
166157
isInVehicle = false
167158
TriggerEvent('msk_core:exitedVehicle', currentVehicle.vehicle, currentVehicle.plate, currentVehicle.seat, currentVehicle.netId, currentVehicle.isEngineOn, currentVehicle.isDamaged)
168159
TriggerServerEvent('msk_core:exitedVehicle', currentVehicle.plate, currentVehicle.seat, currentVehicle.netId, currentVehicle.isEngineOn, currentVehicle.isDamaged)

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.6'
7+
version '2.6.7'
88

99
lua54 'yes'
1010

import.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ local context = IsDuplicityVersion() and 'server' or 'client'
2626
MSK = exports.msk_core:GetLib()
2727

2828
----------------------------------------------------------------
29-
-- Support for old Scripts
29+
-- Quick function access
3030
----------------------------------------------------------------
3131
-- MSK.Input(header, placeholder, field, cb)
3232
setmetatable(MSK.Input, {
@@ -49,6 +49,15 @@ setmetatable(MSK.Progress, {
4949
end
5050
})
5151

52+
if context == 'server' then
53+
-- MSK.Check(repo)
54+
setmetatable(MSK.Check, {
55+
__call = function(self, ...)
56+
self.Version(...)
57+
end
58+
})
59+
end
60+
5261
----------------------------------------------------------------
5362
-- MSK.Player
5463
----------------------------------------------------------------
@@ -68,10 +77,6 @@ if context == 'client' then
6877
AddEventHandler('msk_core:onPlayer', function(key, value, oldValue)
6978
MSK.Player[key] = value
7079
end)
71-
72-
AddEventHandler('msk_core:onPlayerRemove', function(key, value)
73-
MSK.Player[key] = nil
74-
end)
7580
end
7681

7782
if context == 'server' then
@@ -105,11 +110,6 @@ if context == 'server' then
105110
MSK.Player[playerId][key] = value
106111
end)
107112

108-
AddEventHandler('msk_core:OnPlayerRemove', function(playerId, key, value)
109-
if not MSK.Player[playerId] then return end
110-
MSK.Player[playerId][key] = nil
111-
end)
112-
113113
for playerId, data in pairs(MSK.Player) do
114114
if not getmetatable(MSK.Player[playerId]) then
115115
setmetatable(MSK.Player[playerId], playerMeta)

0 commit comments

Comments
 (0)