0.0.1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Example spawn points for FiveM with a "hipster" model.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
|
||||
|
||||
map 'map.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'gta5'
|
||||
@@ -0,0 +1,63 @@
|
||||
vehicle_generator "airtug" { -54.26639938354492, -1679.548828125, 28.4414, heading = 228.2736053466797 }
|
||||
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -802.311, y = 175.056, z = 72.8446 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -9.96562, y = -1438.54, z = 31.1015 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 0.916756, y = 528.485, z = 174.628 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -181.615, y = 852.8, z = 232.701 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 657.723, y = 457.342, z = 144.641 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 134.387, y = 1150.31, z = 231.594 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 726.14, y = 1196.91, z = 326.262 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 740.792, y = 1283.62, z = 360.297 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -437.009, y = 1059.59, z = 327.331 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -428.771, y = 1596.8, z = 356.338 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1348.78, y = 723.87, z = 186.45 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1543.24, y = 830.069, z = 182.132 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2150.48, y = 222.019, z = 184.602 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -3032.13, y = 22.2157, z = 10.1184 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 3063.97, y = 5608.88, z = 209.245 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -2614.35, y = 1872.49, z = 167.32 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1873.94, y = 2088.73, z = 140.994 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -597.177, y = 2092.16, z = 131.413 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 967.126, y = 2226.99, z = 54.0588 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -338.043, y = 2829, z = 56.0871 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 1082.25, y = -696.921, z = 58.0099 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 1658.31, y = -13.9234, z = 169.992 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2522.98, y = -384.436, z = 92.9928 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2826.27, y = -656.489, z = 1.87841 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2851.12, y = 1467.5, z = 24.5554 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2336.33, y = 2535.39, z = 46.5177 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2410.46, y = 3077.88, z = 48.1529 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2451.15, y = 3768.37, z = 41.3477 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 3337.78, y = 5174.8, z = 18.2108 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1119.33, y = 4978.52, z = 186.26 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2877.3, y = 5911.57, z = 369.618 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2942.1, y = 5306.73, z = 101.52 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2211.29, y = 5577.94, z = 53.872 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 1602.39, y = 6623.02, z = 15.8417 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 66.0113, y = 7203.58, z = 3.16 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -219.201, y = 6562.82, z = 10.9706 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -45.1562, y = 6301.64, z = 31.6114 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1004.77, y = 4854.32, z = 274.606 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1580.01, y = 5173.3, z = 19.5813 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1467.95, y = 5416.2, z = 23.5959 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2359.31, y = 3243.83, z = 92.9037 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -2612.96, y = 3555.03, z = 4.85649 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2083.27, y = 2616.94, z = 3.08396 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -524.471, y = 4195, z = 193.731 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -840.713, y = 4183.18, z = 215.29 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1576.24, y = 2103.87, z = 67.576 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1634.37, y = 209.816, z = 60.6413 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1495.07, y = 142.697, z = 55.6527 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1715.41, y = -197.722, z = 57.698 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1181.07, y = -505.544, z = 35.5661 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1712.37, y = -1082.91, z = 13.0801 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1352.43, y = -1542.75, z = 4.42268 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1756.89, y = 427.531, z = 127.685 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 3060.2, y = 2113.2, z = 1.6613 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 501.646, y = 5604.53, z = 797.91 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 714.109, y = 4151.15, z = 35.7792 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -103.651, y = -967.93, z = 296.52 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -265.333, y = -2419.35, z = 122.366 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
|
||||
|
||||
--
|
||||
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Example spawn points for FiveM with a "skater" model.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
|
||||
|
||||
map 'map.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'gta5'
|
||||
@@ -0,0 +1,62 @@
|
||||
spawnpoint 'a_m_y_skater_01' { x = -802.311, y = 175.056, z = 72.8446 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -9.96562, y = -1438.54, z = 31.1015 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 0.916756, y = 528.485, z = 174.628 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1975.86, y = 3821.03, z = 33.4501 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -181.615, y = 852.8, z = 232.701 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 657.723, y = 457.342, z = 144.641 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 134.387, y = 1150.31, z = 231.594 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 726.14, y = 1196.91, z = 326.262 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 740.792, y = 1283.62, z = 360.297 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -437.009, y = 1059.59, z = 327.331 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -428.771, y = 1596.8, z = 356.338 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1348.78, y = 723.87, z = 186.45 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1543.24, y = 830.069, z = 182.132 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2150.48, y = 222.019, z = 184.602 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -3032.13, y = 22.2157, z = 10.1184 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 3063.97, y = 5608.88, z = 209.245 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -2614.35, y = 1872.49, z = 167.32 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1873.94, y = 2088.73, z = 140.994 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -597.177, y = 2092.16, z = 131.413 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 967.126, y = 2226.99, z = 54.0588 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -338.043, y = 2829, z = 56.0871 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1082.25, y = -696.921, z = 58.0099 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 1658.31, y = -13.9234, z = 169.992 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2522.98, y = -384.436, z = 92.9928 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2826.27, y = -656.489, z = 1.87841 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2851.12, y = 1467.5, z = 24.5554 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2336.33, y = 2535.39, z = 46.5177 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2410.46, y = 3077.88, z = 48.1529 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2451.15, y = 3768.37, z = 41.3477 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 3337.78, y = 5174.8, z = 18.2108 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1119.33, y = 4978.52, z = 186.26 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2877.3, y = 5911.57, z = 369.618 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2942.1, y = 5306.73, z = 101.52 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2211.29, y = 5577.94, z = 53.872 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 1602.39, y = 6623.02, z = 15.8417 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 66.0113, y = 7203.58, z = 3.16 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -219.201, y = 6562.82, z = 10.9706 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -45.1562, y = 6301.64, z = 31.6114 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1004.77, y = 4854.32, z = 274.606 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1580.01, y = 5173.3, z = 19.5813 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1467.95, y = 5416.2, z = 23.5959 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2359.31, y = 3243.83, z = 92.9037 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -2612.96, y = 3555.03, z = 4.85649 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2083.27, y = 2616.94, z = 3.08396 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -524.471, y = 4195, z = 193.731 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -840.713, y = 4183.18, z = 215.29 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1576.24, y = 2103.87, z = 67.576 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1634.37, y = 209.816, z = 60.6413 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1495.07, y = 142.697, z = 55.6527 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1715.41, y = -197.722, z = 57.698 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1181.07, y = -505.544, z = 35.5661 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1712.37, y = -1082.91, z = 13.0801 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1352.43, y = -1542.75, z = 4.42268 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1756.89, y = 427.531, z = 127.685 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 3060.2, y = 2113.2, z = 1.6613 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 501.646, y = 5604.53, z = 797.91 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 714.109, y = 4151.15, z = 35.7792 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -103.651, y = -967.93, z = 296.52 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -265.333, y = -2419.35, z = 122.366 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
|
||||
|
||||
--
|
||||
@@ -0,0 +1,16 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Example spawn points for RedM.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
|
||||
|
||||
map 'map.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'rdr3'
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
@@ -0,0 +1,2 @@
|
||||
spawnpoint 'player_three' { x = -262.849, y = 793.404, z = 118.087 }
|
||||
spawnpoint 'player_zero' { x = -262.849, y = 793.404, z = 118.087 }
|
||||
@@ -0,0 +1,4 @@
|
||||
AddEventHandler('onClientMapStart', function()
|
||||
exports.spawnmanager:setAutoSpawn(true)
|
||||
exports.spawnmanager:forceRespawn()
|
||||
end)
|
||||
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'A basic freeroam gametype that uses the default spawn logic from spawnmanager.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
resource_type 'gametype' { name = 'Freeroam' }
|
||||
|
||||
client_script 'basic_client.lua'
|
||||
|
||||
game 'common'
|
||||
fx_version 'adamant'
|
||||
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
description 'An example money system fountain spawn point.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
|
||||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
map 'map.lua'
|
||||
|
||||
dependency 'money-fountain'
|
||||
@@ -0,0 +1,4 @@
|
||||
money_fountain 'test_fountain' {
|
||||
vector3(97.334, -973.621, 29.36),
|
||||
amount = 75
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
-- add text entries for all the help types we have
|
||||
AddTextEntry('FOUNTAIN_HELP', 'This fountain currently contains $~1~.~n~Press ~INPUT_PICKUP~ to obtain $~1~.~n~Press ~INPUT_DETONATE~ to place $~1~.')
|
||||
AddTextEntry('FOUNTAIN_HELP_DRAINED', 'This fountain currently contains $~1~.~n~Press ~INPUT_DETONATE~ to place $~1~.')
|
||||
AddTextEntry('FOUNTAIN_HELP_BROKE', 'This fountain currently contains $~1~.~n~Press ~INPUT_PICKUP~ to obtain $~1~.')
|
||||
AddTextEntry('FOUNTAIN_HELP_BROKE_N_DRAINED', 'This fountain currently contains $~1~.')
|
||||
AddTextEntry('FOUNTAIN_HELP_INUSE', 'This fountain currently contains $~1~.~n~You can use it again in ~a~.')
|
||||
|
||||
-- upvalue aliases so that we will be fast if far away
|
||||
local Wait = Wait
|
||||
local GetEntityCoords = GetEntityCoords
|
||||
local PlayerPedId = PlayerPedId
|
||||
|
||||
-- timer, don't tick as frequently if we're far from any money fountain
|
||||
local relevanceTimer = 500
|
||||
|
||||
CreateThread(function()
|
||||
local pressing = false
|
||||
|
||||
while true do
|
||||
Wait(relevanceTimer)
|
||||
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
for _, data in pairs(moneyFountains) do
|
||||
-- if we're near this fountain
|
||||
local dist = #(coords - data.coords)
|
||||
|
||||
-- near enough to draw
|
||||
if dist < 40 then
|
||||
-- ensure per-frame tick
|
||||
relevanceTimer = 0
|
||||
|
||||
DrawMarker(29, data.coords.x, data.coords.y, data.coords.z, 0, 0, 0, 0.0, 0, 0, 1.0, 1.0, 1.0, 0, 150, 0, 120, false, true, 2, false, nil, nil, false)
|
||||
else
|
||||
-- put the relevance timer back to the way it was
|
||||
relevanceTimer = 500
|
||||
end
|
||||
|
||||
-- near enough to use
|
||||
if dist < 1 then
|
||||
-- are we able to use it? if not, display appropriate help
|
||||
local player = LocalPlayer
|
||||
local nextUse = player.state['fountain_nextUse']
|
||||
|
||||
-- GetNetworkTime is synced for everyone
|
||||
if nextUse and nextUse >= GetNetworkTime() then
|
||||
BeginTextCommandDisplayHelp('FOUNTAIN_HELP_INUSE')
|
||||
AddTextComponentInteger(GlobalState['fountain_' .. data.id])
|
||||
AddTextComponentSubstringTime(math.tointeger(nextUse - GetNetworkTime()), 2 | 4) -- seconds (2), minutes (4)
|
||||
EndTextCommandDisplayHelp(0, false, false, 1000)
|
||||
else
|
||||
-- handle inputs for pickup/place
|
||||
if not pressing then
|
||||
if IsControlPressed(0, 38 --[[ INPUT_PICKUP ]]) then
|
||||
TriggerServerEvent('money_fountain:tryPickup', data.id)
|
||||
pressing = true
|
||||
elseif IsControlPressed(0, 47 --[[ INPUT_DETONATE ]]) then
|
||||
TriggerServerEvent('money_fountain:tryPlace', data.id)
|
||||
pressing = true
|
||||
end
|
||||
else
|
||||
if not IsControlPressed(0, 38 --[[ INPUT_PICKUP ]]) and
|
||||
not IsControlPressed(0, 47 --[[ INPUT_DETONATE ]]) then
|
||||
pressing = false
|
||||
end
|
||||
end
|
||||
|
||||
-- decide the appropriate help message
|
||||
local youCanSpend = (player.state['money_cash'] or 0) >= data.amount
|
||||
local fountainCanSpend = GlobalState['fountain_' .. data.id] >= data.amount
|
||||
|
||||
local helpName
|
||||
|
||||
if youCanSpend and fountainCanSpend then
|
||||
helpName = 'FOUNTAIN_HELP'
|
||||
elseif youCanSpend and not fountainCanSpend then
|
||||
helpName = 'FOUNTAIN_HELP_DRAINED'
|
||||
elseif not youCanSpend and fountainCanSpend then
|
||||
helpName = 'FOUNTAIN_HELP_BROKE'
|
||||
else
|
||||
helpName = 'FOUNTAIN_HELP_BROKE_N_DRAINED'
|
||||
end
|
||||
|
||||
-- and print it
|
||||
BeginTextCommandDisplayHelp(helpName)
|
||||
AddTextComponentInteger(GlobalState['fountain_' .. data.id])
|
||||
|
||||
if fountainCanSpend then
|
||||
AddTextComponentInteger(data.amount)
|
||||
end
|
||||
|
||||
if youCanSpend then
|
||||
AddTextComponentInteger(data.amount)
|
||||
end
|
||||
|
||||
EndTextCommandDisplayHelp(0, false, false, 1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,22 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
description 'An example money system client containing a money fountain.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
|
||||
fx_version 'bodacious'
|
||||
game 'gta5'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
shared_script 'mapdata.lua'
|
||||
|
||||
dependencies {
|
||||
'mapmanager',
|
||||
'money'
|
||||
}
|
||||
|
||||
lua54 'yes'
|
||||
@@ -0,0 +1,28 @@
|
||||
-- define the money fountain list (SHARED SCRIPT)
|
||||
moneyFountains = {}
|
||||
|
||||
-- index to know what to remove
|
||||
local fountainIdx = 1
|
||||
|
||||
AddEventHandler('getMapDirectives', function(add)
|
||||
-- add a 'money_fountain' map directive
|
||||
add('money_fountain', function(state, name)
|
||||
return function(data)
|
||||
local coords = data[1]
|
||||
local amount = data.amount or 100
|
||||
|
||||
local idx = fountainIdx
|
||||
fountainIdx += 1
|
||||
|
||||
moneyFountains[idx] = {
|
||||
id = name,
|
||||
coords = coords,
|
||||
amount = amount
|
||||
}
|
||||
|
||||
state.add('idx', idx)
|
||||
end
|
||||
end, function(state)
|
||||
moneyFountains[state.idx] = nil
|
||||
end)
|
||||
end)
|
||||
@@ -0,0 +1,107 @@
|
||||
-- track down what we've added to global state
|
||||
local sentState = {}
|
||||
|
||||
-- money system
|
||||
local ms = exports['money']
|
||||
|
||||
-- get the fountain content from storage
|
||||
local function getMoneyForId(fountainId)
|
||||
return GetResourceKvpInt(('money:%s'):format(fountainId)) / 100.0
|
||||
end
|
||||
|
||||
-- set the fountain content in storage + state
|
||||
local function setMoneyForId(fountainId, money)
|
||||
GlobalState['fountain_' .. fountainId] = math.tointeger(money)
|
||||
|
||||
return SetResourceKvpInt(('money:%s'):format(fountainId), math.tointeger(money * 100.0))
|
||||
end
|
||||
|
||||
-- get the nearest fountain to the player + ID
|
||||
local function getMoneyFountain(id, source)
|
||||
local coords = GetEntityCoords(GetPlayerPed(source))
|
||||
|
||||
for _, v in pairs(moneyFountains) do
|
||||
if v.id == id then
|
||||
if #(v.coords - coords) < 2.5 then
|
||||
return v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- generic function for events
|
||||
local function handleFountainStuff(source, id, pickup)
|
||||
-- if near the fountain we specify
|
||||
local fountain = getMoneyFountain(id, source)
|
||||
|
||||
if fountain then
|
||||
-- and we can actually use the fountain already
|
||||
local player = Player(source)
|
||||
|
||||
local nextUse = player.state['fountain_nextUse']
|
||||
if not nextUse then
|
||||
nextUse = 0
|
||||
end
|
||||
|
||||
-- GetGameTimer ~ GetNetworkTime on client
|
||||
if nextUse <= GetGameTimer() then
|
||||
-- not rate limited
|
||||
local success = false
|
||||
local money = getMoneyForId(fountain.id)
|
||||
|
||||
-- decide the op
|
||||
if pickup then
|
||||
-- if the fountain is rich enough to get the per-use amount
|
||||
if money >= fountain.amount then
|
||||
-- give the player money
|
||||
if ms:addMoney(source, 'cash', fountain.amount) then
|
||||
money -= fountain.amount
|
||||
success = true
|
||||
end
|
||||
end
|
||||
else
|
||||
-- if the player is rich enough
|
||||
if ms:removeMoney(source, 'cash', fountain.amount) then
|
||||
-- add to the fountain
|
||||
money += fountain.amount
|
||||
success = true
|
||||
end
|
||||
end
|
||||
|
||||
-- save it and set the player's cooldown
|
||||
if success then
|
||||
setMoneyForId(fountain.id, money)
|
||||
player.state['fountain_nextUse'] = GetGameTimer() + GetConvarInt('moneyFountain_cooldown', 5000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- event for picking up fountain->player
|
||||
RegisterNetEvent('money_fountain:tryPickup')
|
||||
AddEventHandler('money_fountain:tryPickup', function(id)
|
||||
handleFountainStuff(source, id, true)
|
||||
end)
|
||||
|
||||
-- event for donating player->fountain
|
||||
RegisterNetEvent('money_fountain:tryPlace')
|
||||
AddEventHandler('money_fountain:tryPlace', function(id)
|
||||
handleFountainStuff(source, id, false)
|
||||
end)
|
||||
|
||||
-- listener: if a new fountain is added, set its current money in state
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(500)
|
||||
|
||||
for _, fountain in pairs(moneyFountains) do
|
||||
if not sentState[fountain.id] then
|
||||
GlobalState['fountain_' .. fountain.id] = math.tointeger(getMoneyForId(fountain.id))
|
||||
|
||||
sentState[fountain.id] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,30 @@
|
||||
local moneyTypes = {
|
||||
cash = `MP0_WALLET_BALANCE`,
|
||||
bank = `BANK_BALANCE`,
|
||||
}
|
||||
|
||||
RegisterNetEvent('money:displayUpdate')
|
||||
|
||||
AddEventHandler('money:displayUpdate', function(type, money)
|
||||
local stat = moneyTypes[type]
|
||||
if not stat then return end
|
||||
StatSetInt(stat, math.floor(money))
|
||||
end)
|
||||
|
||||
TriggerServerEvent('money:requestDisplay')
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
if IsControlJustPressed(0, 20) then
|
||||
SetMultiplayerBankCash()
|
||||
SetMultiplayerWalletCash()
|
||||
|
||||
Wait(4350)
|
||||
|
||||
RemoveMultiplayerBankCash()
|
||||
RemoveMultiplayerWalletCash()
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,16 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
description 'An example money system using KVS.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
|
||||
fx_version 'bodacious'
|
||||
game 'gta5'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
--dependency 'cfx.re/playerData.v1alpha1'
|
||||
lua54 'yes'
|
||||
119
resources/[cfx-default]/[gameplay]/[examples]/money/server.lua
Normal file
119
resources/[cfx-default]/[gameplay]/[examples]/money/server.lua
Normal file
@@ -0,0 +1,119 @@
|
||||
local playerData = exports['cfx.re/playerData.v1alpha1']
|
||||
|
||||
local validMoneyTypes = {
|
||||
bank = true,
|
||||
cash = true,
|
||||
}
|
||||
|
||||
local function getMoneyForId(playerId, moneyType)
|
||||
return GetResourceKvpInt(('money:%s:%s'):format(playerId, moneyType)) / 100.0
|
||||
end
|
||||
|
||||
local function setMoneyForId(playerId, moneyType, money)
|
||||
local s = playerData:getPlayerById(playerId)
|
||||
|
||||
TriggerEvent('money:updated', {
|
||||
dbId = playerId,
|
||||
source = s,
|
||||
moneyType = moneyType,
|
||||
money = money
|
||||
})
|
||||
|
||||
return SetResourceKvpInt(('money:%s:%s'):format(playerId, moneyType), math.tointeger(money * 100.0))
|
||||
end
|
||||
|
||||
local function addMoneyForId(playerId, moneyType, amount)
|
||||
local curMoney = getMoneyForId(playerId, moneyType)
|
||||
curMoney += amount
|
||||
|
||||
if curMoney >= 0 then
|
||||
setMoneyForId(playerId, moneyType, curMoney)
|
||||
return true, curMoney
|
||||
end
|
||||
|
||||
return false, 0
|
||||
end
|
||||
|
||||
exports('addMoney', function(playerIdx, moneyType, amount)
|
||||
amount = tonumber(amount)
|
||||
|
||||
if amount <= 0 or amount > (1 << 30) then
|
||||
return false
|
||||
end
|
||||
|
||||
if not validMoneyTypes[moneyType] then
|
||||
return false
|
||||
end
|
||||
|
||||
local playerId = playerData:getPlayerId(playerIdx)
|
||||
local success, money = addMoneyForId(playerId, moneyType, amount)
|
||||
|
||||
if success then
|
||||
Player(playerIdx).state['money_' .. moneyType] = money
|
||||
end
|
||||
|
||||
return true
|
||||
end)
|
||||
|
||||
exports('removeMoney', function(playerIdx, moneyType, amount)
|
||||
amount = tonumber(amount)
|
||||
|
||||
if amount <= 0 or amount > (1 << 30) then
|
||||
return false
|
||||
end
|
||||
|
||||
if not validMoneyTypes[moneyType] then
|
||||
return false
|
||||
end
|
||||
|
||||
local playerId = playerData:getPlayerId(playerIdx)
|
||||
local success, money = addMoneyForId(playerId, moneyType, -amount)
|
||||
|
||||
if success then
|
||||
Player(playerIdx).state['money_' .. moneyType] = money
|
||||
end
|
||||
|
||||
return success
|
||||
end)
|
||||
|
||||
exports('getMoney', function(playerIdx, moneyType)
|
||||
local playerId = playerData:getPlayerId(playerIdx)
|
||||
return getMoneyForId(playerId, moneyType)
|
||||
end)
|
||||
|
||||
-- player display bits
|
||||
AddEventHandler('money:updated', function(data)
|
||||
if data.source then
|
||||
TriggerClientEvent('money:displayUpdate', data.source, data.moneyType, data.money)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('money:requestDisplay')
|
||||
|
||||
AddEventHandler('money:requestDisplay', function()
|
||||
local source = source
|
||||
local playerId = playerData:getPlayerId(source)
|
||||
|
||||
for type, _ in pairs(validMoneyTypes) do
|
||||
local amount = getMoneyForId(playerId, type)
|
||||
TriggerClientEvent('money:displayUpdate', source, type, amount)
|
||||
|
||||
Player(source).state['money_' .. type] = amount
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand('earn', function(source, args)
|
||||
local type = args[1]
|
||||
local amount = tonumber(args[2])
|
||||
|
||||
exports['money']:addMoney(source, type, amount)
|
||||
end, true)
|
||||
|
||||
RegisterCommand('spend', function(source, args)
|
||||
local type = args[1]
|
||||
local amount = tonumber(args[2])
|
||||
|
||||
if not exports['money']:removeMoney(source, type, amount) then
|
||||
print('you are broke??')
|
||||
end
|
||||
end, true)
|
||||
@@ -0,0 +1,41 @@
|
||||
AddEventHandler('gameEventTriggered', function(eventName, args)
|
||||
if eventName == 'CEventNetworkEntityDamage' then
|
||||
local victim = args[1]
|
||||
local culprit = args[2]
|
||||
local isDead = args[4] == 1
|
||||
|
||||
if isDead then
|
||||
local origCoords = GetEntityCoords(victim)
|
||||
local pickup = CreatePickupRotate(`PICKUP_MONEY_VARIABLE`, origCoords.x, origCoords.y, origCoords.z - 0.7, 0.0, 0.0, 0.0, 512, 0, false, 0)
|
||||
local netId = PedToNet(victim)
|
||||
|
||||
local undoStuff = { false }
|
||||
|
||||
CreateThread(function()
|
||||
local self = PlayerPedId()
|
||||
|
||||
while not undoStuff[1] do
|
||||
Wait(50)
|
||||
|
||||
if #(GetEntityCoords(self) - origCoords) < 2.5 and HasPickupBeenCollected(pickup) then
|
||||
TriggerServerEvent('money:tryPickup', netId)
|
||||
|
||||
RemovePickup(pickup)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
undoStuff[1] = true
|
||||
end)
|
||||
|
||||
SetTimeout(15000, function()
|
||||
if not undoStuff[1] then
|
||||
RemovePickup(pickup)
|
||||
undoStuff[1] = true
|
||||
end
|
||||
end)
|
||||
|
||||
TriggerServerEvent('money:allowPickupNear', netId)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,15 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
description 'An example money system client.'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
fx_version 'bodacious'
|
||||
game 'gta5'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
lua54 'yes'
|
||||
@@ -0,0 +1,42 @@
|
||||
local safePositions = {}
|
||||
|
||||
RegisterNetEvent('money:allowPickupNear')
|
||||
|
||||
AddEventHandler('money:allowPickupNear', function(pedId)
|
||||
local entity = NetworkGetEntityFromNetworkId(pedId)
|
||||
|
||||
Wait(250)
|
||||
|
||||
if not DoesEntityExist(entity) then
|
||||
return
|
||||
end
|
||||
|
||||
if GetEntityHealth(entity) > 100 then
|
||||
return
|
||||
end
|
||||
|
||||
local coords = GetEntityCoords(entity)
|
||||
safePositions[pedId] = coords
|
||||
end)
|
||||
|
||||
RegisterNetEvent('money:tryPickup')
|
||||
|
||||
AddEventHandler('money:tryPickup', function(entity)
|
||||
if not safePositions[entity] then
|
||||
return
|
||||
end
|
||||
|
||||
local source = source
|
||||
local playerPed = GetPlayerPed(source)
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
if #(safePositions[entity] - coords) < 2.5 then
|
||||
exports['money']:addMoney(source, 'cash', 40)
|
||||
end
|
||||
|
||||
safePositions[entity] = nil
|
||||
end)
|
||||
|
||||
AddEventHandler('entityRemoved', function(entity)
|
||||
safePositions[entity] = nil
|
||||
end)
|
||||
@@ -0,0 +1,21 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'A GTA Online-styled theme for the chat resource.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
file 'style.css'
|
||||
file 'shadow.js'
|
||||
|
||||
chat_theme 'gtao' {
|
||||
styleSheet = 'style.css',
|
||||
script = 'shadow.js',
|
||||
msgTemplates = {
|
||||
default = '<b>{0}</b><span>{1}</span>'
|
||||
}
|
||||
}
|
||||
|
||||
game 'common'
|
||||
fx_version 'adamant'
|
||||
74
resources/[cfx-default]/[gameplay]/chat-theme-gtao/shadow.js
Normal file
74
resources/[cfx-default]/[gameplay]/chat-theme-gtao/shadow.js
Normal file
@@ -0,0 +1,74 @@
|
||||
(function() {
|
||||
var Filters = {}
|
||||
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
svg.setAttribute("style", "display:block;width:0px;height:0px");
|
||||
var defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
||||
|
||||
var blurFilter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
|
||||
blurFilter.setAttribute("id", "svgBlurFilter");
|
||||
var feGaussianFilter = document.createElementNS("http://www.w3.org/2000/svg", "feGaussianBlur");
|
||||
feGaussianFilter.setAttribute("stdDeviation", "0 0");
|
||||
blurFilter.appendChild(feGaussianFilter);
|
||||
defs.appendChild(blurFilter);
|
||||
Filters._svgBlurFilter = feGaussianFilter;
|
||||
|
||||
// Drop Shadow Filter
|
||||
var dropShadowFilter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
|
||||
dropShadowFilter.setAttribute("id", "svgDropShadowFilter");
|
||||
var feGaussianFilter = document.createElementNS("http://www.w3.org/2000/svg", "feGaussianBlur");
|
||||
feGaussianFilter.setAttribute("in", "SourceAlpha");
|
||||
feGaussianFilter.setAttribute("stdDeviation", "3");
|
||||
dropShadowFilter.appendChild(feGaussianFilter);
|
||||
Filters._svgDropshadowFilterBlur = feGaussianFilter;
|
||||
|
||||
var feOffset = document.createElementNS("http://www.w3.org/2000/svg", "feOffset");
|
||||
feOffset.setAttribute("dx", "0");
|
||||
feOffset.setAttribute("dy", "0");
|
||||
feOffset.setAttribute("result", "offsetblur");
|
||||
dropShadowFilter.appendChild(feOffset);
|
||||
Filters._svgDropshadowFilterOffset = feOffset;
|
||||
|
||||
var feFlood = document.createElementNS("http://www.w3.org/2000/svg", "feFlood");
|
||||
feFlood.setAttribute("flood-color", "rgba(0,0,0,1)");
|
||||
dropShadowFilter.appendChild(feFlood);
|
||||
Filters._svgDropshadowFilterFlood = feFlood;
|
||||
|
||||
var feComposite = document.createElementNS("http://www.w3.org/2000/svg", "feComposite");
|
||||
feComposite.setAttribute("in2", "offsetblur");
|
||||
feComposite.setAttribute("operator", "in");
|
||||
dropShadowFilter.appendChild(feComposite);
|
||||
var feComposite = document.createElementNS("http://www.w3.org/2000/svg", "feComposite");
|
||||
feComposite.setAttribute("in2", "SourceAlpha");
|
||||
feComposite.setAttribute("operator", "out");
|
||||
feComposite.setAttribute("result", "outer");
|
||||
dropShadowFilter.appendChild(feComposite);
|
||||
|
||||
var feMerge = document.createElementNS("http://www.w3.org/2000/svg", "feMerge");
|
||||
var feMergeNode = document.createElementNS("http://www.w3.org/2000/svg", "feMergeNode");
|
||||
feMerge.appendChild(feMergeNode);
|
||||
var feMergeNode = document.createElementNS("http://www.w3.org/2000/svg", "feMergeNode");
|
||||
feMerge.appendChild(feMergeNode);
|
||||
Filters._svgDropshadowMergeNode = feMergeNode;
|
||||
dropShadowFilter.appendChild(feMerge);
|
||||
defs.appendChild(dropShadowFilter);
|
||||
svg.appendChild(defs);
|
||||
document.documentElement.appendChild(svg);
|
||||
|
||||
const blurScale = 1;
|
||||
const scale = (document.body.clientWidth / 1280);
|
||||
|
||||
Filters._svgDropshadowFilterBlur.setAttribute("stdDeviation",
|
||||
1 * blurScale + " " +
|
||||
1 * blurScale
|
||||
);
|
||||
Filters._svgDropshadowFilterOffset.setAttribute("dx",
|
||||
String(Math.cos(45 * Math.PI / 180) * 1 * scale));
|
||||
Filters._svgDropshadowFilterOffset.setAttribute("dy",
|
||||
String(Math.sin(45 * Math.PI / 180) * 1 * scale));
|
||||
Filters._svgDropshadowFilterFlood.setAttribute("flood-color",
|
||||
'rgba(0, 0, 0, 1)');
|
||||
Filters._svgDropshadowMergeNode.setAttribute("in",
|
||||
"SourceGraphic");
|
||||
|
||||
})();
|
||||
141
resources/[cfx-default]/[gameplay]/chat-theme-gtao/style.css
Normal file
141
resources/[cfx-default]/[gameplay]/chat-theme-gtao/style.css
Normal file
@@ -0,0 +1,141 @@
|
||||
* {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.chat-window {
|
||||
--size: calc(((2.7vh * 1.2)) * 6);
|
||||
|
||||
position: absolute;
|
||||
right: calc(2.77vh);
|
||||
top: calc(50% - (var(--size) / 2));
|
||||
height: var(--size) !important;
|
||||
|
||||
background: inherit !important;
|
||||
|
||||
text-align: right;
|
||||
|
||||
left: auto;
|
||||
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font2';
|
||||
src: url(https://runtime.fivem.net/temp/ChaletLondonNineteenSixty.otf?a);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font2_cond';
|
||||
src: url(https://runtime.fivem.net/temp/chaletcomprime-colognesixty-webfont.ttf?a);
|
||||
}
|
||||
|
||||
.msg {
|
||||
font-family: Font2, sans-serif;
|
||||
color: #fff;
|
||||
|
||||
font-size: calc(1.8vh); /* 13px in 720p, calc'd by width */
|
||||
filter: url(#svgDropShadowFilter);
|
||||
|
||||
line-height: calc(2.7vh * 1.2);
|
||||
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.msg > span > span > b {
|
||||
font-family: Font2_cond, sans-serif;
|
||||
font-weight: normal;
|
||||
|
||||
vertical-align: baseline;
|
||||
padding-right: 11px;
|
||||
|
||||
line-height: 1;
|
||||
|
||||
font-size: calc(2.7vh);
|
||||
}
|
||||
|
||||
.msg > span > span > span {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.msg i:first-of-type {
|
||||
font-style: normal;
|
||||
color: #c0c0c0;
|
||||
}
|
||||
|
||||
.chat-input {
|
||||
position: absolute;
|
||||
right: calc(2.77vh);
|
||||
bottom: calc(2.77vh);
|
||||
|
||||
background: inherit !important;
|
||||
|
||||
text-align: right;
|
||||
|
||||
top: auto;
|
||||
left: auto;
|
||||
|
||||
height: auto;
|
||||
|
||||
font-family: Font2, sans-serif;
|
||||
}
|
||||
|
||||
.chat-input > div {
|
||||
background-color: rgba(0, 0, 0, .6) !important;
|
||||
border: calc(0.28vh / 2) solid rgba(180, 180, 180, .6);
|
||||
outline: calc(0.28vh / 2) solid rgba(0, 0, 0, .8); /* to replace margin-background */
|
||||
padding: calc(0.28vh / 2);
|
||||
}
|
||||
|
||||
.chat-input .prefix {
|
||||
margin: 0;
|
||||
margin-left: 0.7%;
|
||||
margin-top: -0.1%;
|
||||
line-height: 2.8vh;
|
||||
}
|
||||
|
||||
.chat-input .prefix.any {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.chat-input .prefix.any:before {
|
||||
content: '[';
|
||||
}
|
||||
|
||||
.chat-input .prefix.any:after {
|
||||
content: ']';
|
||||
}
|
||||
|
||||
.chat-input > div + div {
|
||||
position: absolute;
|
||||
bottom: calc(1.65vh + 0.28vh + 0.28vh + 0.28vh + (0.28vh / 2));
|
||||
width: 99.6%;
|
||||
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.suggestions {
|
||||
border: calc(0.28vh / 2) solid rgba(180, 180, 180, .6);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
textarea {
|
||||
background: transparent;
|
||||
padding: 0.5vh;
|
||||
}
|
||||
|
||||
@media screen and (min-aspect-ratio: 21/9) {
|
||||
.chat-window, .chat-input {
|
||||
right: calc(12.8vw);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-aspect-ratio: 32/9) {
|
||||
.chat-window, .chat-input {
|
||||
right: calc(25vw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
description 'A basic resource for storing player identifiers.'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
fx_version 'bodacious'
|
||||
game 'common'
|
||||
|
||||
server_script 'server.lua'
|
||||
|
||||
provides {
|
||||
'cfx.re/playerData.v1alpha1'
|
||||
}
|
||||
222
resources/[cfx-default]/[gameplay]/player-data/server.lua
Normal file
222
resources/[cfx-default]/[gameplay]/player-data/server.lua
Normal file
@@ -0,0 +1,222 @@
|
||||
--- player-data is a basic resource to showcase player identifier storage
|
||||
--
|
||||
-- it works in a fairly simple way: a set of identifiers is assigned to an account ID, and said
|
||||
-- account ID is then returned/added as state bag
|
||||
--
|
||||
-- it also implements the `cfx.re/playerData.v1alpha1` spec, which is exposed through the following:
|
||||
-- - getPlayerId(source: string)
|
||||
-- - getPlayerById(dbId: string)
|
||||
-- - getPlayerIdFromIdentifier(identifier: string)
|
||||
-- - setting `cfx.re/playerData@id` state bag field on the player
|
||||
|
||||
-- identifiers that we'll ignore (e.g. IP) as they're low-trust/high-variance
|
||||
local identifierBlocklist = {
|
||||
ip = true
|
||||
}
|
||||
|
||||
-- function to check if the identifier is blocked
|
||||
local function isIdentifierBlocked(identifier)
|
||||
-- Lua pattern to correctly split
|
||||
local idType = identifier:match('([^:]+):')
|
||||
|
||||
-- ensure it's a boolean
|
||||
return identifierBlocklist[idType] or false
|
||||
end
|
||||
|
||||
-- our database schema, in hierarchical KVS syntax:
|
||||
-- player:
|
||||
-- <id>:
|
||||
-- identifier:
|
||||
-- <identifier>: 'true'
|
||||
-- identifier:
|
||||
-- <identifier>: <playerId>
|
||||
|
||||
-- list of player indices to data
|
||||
local players = {}
|
||||
|
||||
-- list of player DBIDs to player indices
|
||||
local playersById = {}
|
||||
|
||||
-- a sequence field using KVS
|
||||
local function incrementId()
|
||||
local nextId = GetResourceKvpInt('nextId')
|
||||
nextId = nextId + 1
|
||||
SetResourceKvpInt('nextId', nextId)
|
||||
|
||||
return nextId
|
||||
end
|
||||
|
||||
-- gets the ID tied to an identifier in the schema, or nil
|
||||
local function getPlayerIdFromIdentifier(identifier)
|
||||
local str = GetResourceKvpString(('identifier:%s'):format(identifier))
|
||||
|
||||
if not str then
|
||||
return nil
|
||||
end
|
||||
|
||||
return msgpack.unpack(str).id
|
||||
end
|
||||
|
||||
-- stores the identifier + adds to a logging list
|
||||
local function setPlayerIdFromIdentifier(identifier, id)
|
||||
local str = ('identifier:%s'):format(identifier)
|
||||
SetResourceKvp(str, msgpack.pack({ id = id }))
|
||||
SetResourceKvp(('player:%s:identifier:%s'):format(id, identifier), 'true')
|
||||
end
|
||||
|
||||
-- stores any new identifiers for this player ID
|
||||
local function storeIdentifiers(playerIdx, newId)
|
||||
for _, identifier in ipairs(GetPlayerIdentifiers(playerIdx)) do
|
||||
if not isIdentifierBlocked(identifier) then
|
||||
-- TODO: check if the player already has an identifier of this type
|
||||
setPlayerIdFromIdentifier(identifier, newId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- registers a new player (increments sequence, stores data, returns ID)
|
||||
local function registerPlayer(playerIdx)
|
||||
local newId = incrementId()
|
||||
storeIdentifiers(playerIdx, newId)
|
||||
|
||||
return newId
|
||||
end
|
||||
|
||||
-- initializes a player's data set
|
||||
local function setupPlayer(playerIdx)
|
||||
-- try getting the oldest-known identity from all the player's identifiers
|
||||
local defaultId = 0xFFFFFFFFFF
|
||||
local lowestId = defaultId
|
||||
|
||||
for _, identifier in ipairs(GetPlayerIdentifiers(playerIdx)) do
|
||||
if not isIdentifierBlocked(identifier) then
|
||||
local dbId = getPlayerIdFromIdentifier(identifier)
|
||||
|
||||
if dbId then
|
||||
if dbId < lowestId then
|
||||
lowestId = dbId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if this is the default ID, register. if not, update
|
||||
local playerId
|
||||
|
||||
if lowestId == defaultId then
|
||||
playerId = registerPlayer(playerIdx)
|
||||
else
|
||||
storeIdentifiers(playerIdx, lowestId)
|
||||
playerId = lowestId
|
||||
end
|
||||
|
||||
-- add state bag field
|
||||
if Player then
|
||||
Player(playerIdx).state['cfx.re/playerData@id'] = playerId
|
||||
end
|
||||
|
||||
-- and add to our caching tables
|
||||
players[playerIdx] = {
|
||||
dbId = playerId
|
||||
}
|
||||
|
||||
playersById[tostring(playerId)] = playerIdx
|
||||
end
|
||||
|
||||
-- we want to add a player pretty early
|
||||
AddEventHandler('playerConnecting', function()
|
||||
local playerIdx = tostring(source)
|
||||
setupPlayer(playerIdx)
|
||||
end)
|
||||
|
||||
-- and migrate them to a 'joining' ID where possible
|
||||
RegisterNetEvent('playerJoining')
|
||||
|
||||
AddEventHandler('playerJoining', function(oldIdx)
|
||||
-- resource restart race condition
|
||||
local oldPlayer = players[tostring(oldIdx)]
|
||||
|
||||
if oldPlayer then
|
||||
players[tostring(source)] = oldPlayer
|
||||
players[tostring(oldIdx)] = nil
|
||||
else
|
||||
setupPlayer(tostring(source))
|
||||
end
|
||||
end)
|
||||
|
||||
-- remove them if they're dropped
|
||||
AddEventHandler('playerDropped', function()
|
||||
local player = players[tostring(source)]
|
||||
|
||||
if player then
|
||||
playersById[tostring(player.dbId)] = nil
|
||||
end
|
||||
|
||||
players[tostring(source)] = nil
|
||||
end)
|
||||
|
||||
-- and when the resource is restarted, set up all players that are on right now
|
||||
for _, player in ipairs(GetPlayers()) do
|
||||
setupPlayer(player)
|
||||
end
|
||||
|
||||
-- also a quick command to get the current state
|
||||
RegisterCommand('playerData', function(source, args)
|
||||
if not args[1] then
|
||||
print('Usage:')
|
||||
print('\tplayerData getId <dbId>: gets identifiers for ID')
|
||||
print('\tplayerData getIdentifier <identifier>: gets ID for identifier')
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if args[1] == 'getId' then
|
||||
local prefix = ('player:%s:identifier:'):format(args[2])
|
||||
local handle = StartFindKvp(prefix)
|
||||
local key
|
||||
|
||||
repeat
|
||||
key = FindKvp(handle)
|
||||
|
||||
if key then
|
||||
print('result:', key:sub(#prefix + 1))
|
||||
end
|
||||
until not key
|
||||
|
||||
EndFindKvp(handle)
|
||||
elseif args[1] == 'getIdentifier' then
|
||||
print('result:', getPlayerIdFromIdentifier(args[2]))
|
||||
end
|
||||
end, true)
|
||||
|
||||
-- COMPATIBILITY for server versions that don't export provide
|
||||
local function getExportEventName(resource, name)
|
||||
return string.format('__cfx_export_%s_%s', resource, name)
|
||||
end
|
||||
|
||||
function AddExport(name, fn)
|
||||
if not Citizen.Traits or not Citizen.Traits.ProvidesExports then
|
||||
AddEventHandler(getExportEventName('cfx.re/playerData.v1alpha1', name), function(setCB)
|
||||
setCB(fn)
|
||||
end)
|
||||
end
|
||||
|
||||
exports(name, fn)
|
||||
end
|
||||
|
||||
-- exports
|
||||
AddExport('getPlayerIdFromIdentifier', getPlayerIdFromIdentifier)
|
||||
|
||||
AddExport('getPlayerId', function(playerIdx)
|
||||
local player = players[tostring(playerIdx)]
|
||||
|
||||
if not player then
|
||||
return nil
|
||||
end
|
||||
|
||||
return player.dbId
|
||||
end)
|
||||
|
||||
AddExport('getPlayerById', function(playerId)
|
||||
return playersById[tostring(playerId)]
|
||||
end)
|
||||
@@ -0,0 +1,36 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'A basic resource for displaying player names.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
-- add scripts
|
||||
client_script 'playernames_api.lua'
|
||||
server_script 'playernames_api.lua'
|
||||
|
||||
client_script 'playernames_cl.lua'
|
||||
server_script 'playernames_sv.lua'
|
||||
|
||||
-- make exports
|
||||
local exportList = {
|
||||
'setComponentColor',
|
||||
'setComponentAlpha',
|
||||
'setComponentVisibility',
|
||||
'setWantedLevel',
|
||||
'setHealthBarColor',
|
||||
'setNameTemplate'
|
||||
}
|
||||
|
||||
exports(exportList)
|
||||
server_exports(exportList)
|
||||
|
||||
-- add files
|
||||
files {
|
||||
'template/template.lua'
|
||||
}
|
||||
|
||||
-- support the latest resource manifest
|
||||
fx_version 'adamant'
|
||||
game 'gta5'
|
||||
@@ -0,0 +1,80 @@
|
||||
local ids = {}
|
||||
|
||||
local function getTriggerFunction(key)
|
||||
return function(id, ...)
|
||||
-- if on the client, it's easy
|
||||
if not IsDuplicityVersion() then
|
||||
TriggerEvent('playernames:configure', GetPlayerServerId(id), key, ...)
|
||||
else
|
||||
-- if on the server, save configuration
|
||||
if not ids[id] then
|
||||
ids[id] = {}
|
||||
end
|
||||
|
||||
-- save the setting
|
||||
ids[id][key] = table.pack(...)
|
||||
|
||||
-- broadcast to clients
|
||||
TriggerClientEvent('playernames:configure', -1, id, key, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if IsDuplicityVersion() then
|
||||
function reconfigure(source)
|
||||
for id, data in pairs(ids) do
|
||||
for key, args in pairs(data) do
|
||||
TriggerClientEvent('playernames:configure', source, id, key, table.unpack(args))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
ids[source] = nil
|
||||
end)
|
||||
end
|
||||
|
||||
setComponentColor = getTriggerFunction('setc')
|
||||
setComponentAlpha = getTriggerFunction('seta')
|
||||
setComponentVisibility = getTriggerFunction('tglc')
|
||||
setWantedLevel = getTriggerFunction('setw')
|
||||
setHealthBarColor = getTriggerFunction('sehc')
|
||||
setNameTemplate = getTriggerFunction('tpl')
|
||||
setName = getTriggerFunction('name')
|
||||
|
||||
if not io then
|
||||
io = { write = nil, open = nil }
|
||||
end
|
||||
|
||||
local template = load(LoadResourceFile(GetCurrentResourceName(), 'template/template.lua'))()
|
||||
|
||||
function formatPlayerNameTag(i, templateStr)
|
||||
--return ('%s <%d>'):format(GetPlayerName(i), GetPlayerServerId(i))
|
||||
local str = ''
|
||||
|
||||
template.print = function(txt)
|
||||
str = str .. txt
|
||||
end
|
||||
|
||||
local context = {
|
||||
name = GetPlayerName(i),
|
||||
i = i,
|
||||
global = _G
|
||||
}
|
||||
|
||||
if IsDuplicityVersion() then
|
||||
context.id = i
|
||||
else
|
||||
context.id = GetPlayerServerId(i)
|
||||
end
|
||||
|
||||
TriggerEvent('playernames:extendContext', i, function(k, v)
|
||||
context[k] = v
|
||||
end)
|
||||
|
||||
template.render(templateStr, context, nil, true)
|
||||
|
||||
template.print = print
|
||||
|
||||
return str
|
||||
end
|
||||
@@ -0,0 +1,191 @@
|
||||
local mpGamerTags = {}
|
||||
local mpGamerTagSettings = {}
|
||||
|
||||
local gtComponent = {
|
||||
GAMER_NAME = 0,
|
||||
CREW_TAG = 1,
|
||||
healthArmour = 2,
|
||||
BIG_TEXT = 3,
|
||||
AUDIO_ICON = 4,
|
||||
MP_USING_MENU = 5,
|
||||
MP_PASSIVE_MODE = 6,
|
||||
WANTED_STARS = 7,
|
||||
MP_DRIVER = 8,
|
||||
MP_CO_DRIVER = 9,
|
||||
MP_TAGGED = 10,
|
||||
GAMER_NAME_NEARBY = 11,
|
||||
ARROW = 12,
|
||||
MP_PACKAGES = 13,
|
||||
INV_IF_PED_FOLLOWING = 14,
|
||||
RANK_TEXT = 15,
|
||||
MP_TYPING = 16
|
||||
}
|
||||
|
||||
local function makeSettings()
|
||||
return {
|
||||
alphas = {},
|
||||
colors = {},
|
||||
healthColor = false,
|
||||
toggles = {},
|
||||
wantedLevel = false
|
||||
}
|
||||
end
|
||||
|
||||
local templateStr
|
||||
|
||||
function updatePlayerNames()
|
||||
-- re-run this function the next frame
|
||||
SetTimeout(0, updatePlayerNames)
|
||||
|
||||
-- return if no template string is set
|
||||
if not templateStr then
|
||||
return
|
||||
end
|
||||
|
||||
-- get local coordinates to compare to
|
||||
local localCoords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
-- for each valid player index
|
||||
for _, i in ipairs(GetActivePlayers()) do
|
||||
-- if the player exists
|
||||
if i ~= PlayerId() then
|
||||
-- get their ped
|
||||
local ped = GetPlayerPed(i)
|
||||
local pedCoords = GetEntityCoords(ped)
|
||||
|
||||
-- make a new settings list if needed
|
||||
if not mpGamerTagSettings[i] then
|
||||
mpGamerTagSettings[i] = makeSettings()
|
||||
end
|
||||
|
||||
-- check the ped, because changing player models may recreate the ped
|
||||
-- also check gamer tag activity in case the game deleted the gamer tag
|
||||
if not mpGamerTags[i] or mpGamerTags[i].ped ~= ped or not IsMpGamerTagActive(mpGamerTags[i].tag) then
|
||||
local nameTag = formatPlayerNameTag(i, templateStr)
|
||||
|
||||
-- remove any existing tag
|
||||
if mpGamerTags[i] then
|
||||
RemoveMpGamerTag(mpGamerTags[i].tag)
|
||||
end
|
||||
|
||||
-- store the new tag
|
||||
mpGamerTags[i] = {
|
||||
tag = CreateMpGamerTag(GetPlayerPed(i), nameTag, false, false, '', 0),
|
||||
ped = ped
|
||||
}
|
||||
end
|
||||
|
||||
-- store the tag in a local
|
||||
local tag = mpGamerTags[i].tag
|
||||
|
||||
-- should the player be renamed? this is set by events
|
||||
if mpGamerTagSettings[i].rename then
|
||||
SetMpGamerTagName(tag, formatPlayerNameTag(i, templateStr))
|
||||
mpGamerTagSettings[i].rename = nil
|
||||
end
|
||||
|
||||
-- check distance
|
||||
local distance = #(pedCoords - localCoords)
|
||||
|
||||
-- show/hide based on nearbyness/line-of-sight
|
||||
-- nearby checks are primarily to prevent a lot of LOS checks
|
||||
if distance < 250 and HasEntityClearLosToEntity(PlayerPedId(), ped, 17) then
|
||||
SetMpGamerTagVisibility(tag, gtComponent.GAMER_NAME, true)
|
||||
SetMpGamerTagVisibility(tag, gtComponent.healthArmour, IsPlayerTargettingEntity(PlayerId(), ped))
|
||||
SetMpGamerTagVisibility(tag, gtComponent.AUDIO_ICON, NetworkIsPlayerTalking(i))
|
||||
|
||||
SetMpGamerTagAlpha(tag, gtComponent.AUDIO_ICON, 255)
|
||||
SetMpGamerTagAlpha(tag, gtComponent.healthArmour, 255)
|
||||
|
||||
-- override settings
|
||||
local settings = mpGamerTagSettings[i]
|
||||
|
||||
for k, v in pairs(settings.toggles) do
|
||||
SetMpGamerTagVisibility(tag, gtComponent[k], v)
|
||||
end
|
||||
|
||||
for k, v in pairs(settings.alphas) do
|
||||
SetMpGamerTagAlpha(tag, gtComponent[k], v)
|
||||
end
|
||||
|
||||
for k, v in pairs(settings.colors) do
|
||||
SetMpGamerTagColour(tag, gtComponent[k], v)
|
||||
end
|
||||
|
||||
if settings.wantedLevel then
|
||||
SetMpGamerTagWantedLevel(tag, settings.wantedLevel)
|
||||
end
|
||||
|
||||
if settings.healthColor then
|
||||
SetMpGamerTagHealthBarColour(tag, settings.healthColor)
|
||||
end
|
||||
else
|
||||
SetMpGamerTagVisibility(tag, gtComponent.GAMER_NAME, false)
|
||||
SetMpGamerTagVisibility(tag, gtComponent.healthArmour, false)
|
||||
SetMpGamerTagVisibility(tag, gtComponent.AUDIO_ICON, false)
|
||||
end
|
||||
elseif mpGamerTags[i] then
|
||||
RemoveMpGamerTag(mpGamerTags[i].tag)
|
||||
|
||||
mpGamerTags[i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function getSettings(id)
|
||||
local i = GetPlayerFromServerId(tonumber(id))
|
||||
|
||||
if not mpGamerTagSettings[i] then
|
||||
mpGamerTagSettings[i] = makeSettings()
|
||||
end
|
||||
|
||||
return mpGamerTagSettings[i]
|
||||
end
|
||||
|
||||
RegisterNetEvent('playernames:configure')
|
||||
|
||||
AddEventHandler('playernames:configure', function(id, key, ...)
|
||||
local args = table.pack(...)
|
||||
|
||||
if key == 'tglc' then
|
||||
getSettings(id).toggles[args[1]] = args[2]
|
||||
elseif key == 'seta' then
|
||||
getSettings(id).alphas[args[1]] = args[2]
|
||||
elseif key == 'setc' then
|
||||
getSettings(id).colors[args[1]] = args[2]
|
||||
elseif key == 'setw' then
|
||||
getSettings(id).wantedLevel = args[1]
|
||||
elseif key == 'sehc' then
|
||||
getSettings(id).healthColor = args[1]
|
||||
elseif key == 'rnme' then
|
||||
getSettings(id).rename = true
|
||||
elseif key == 'name' then
|
||||
getSettings(id).serverName = args[1]
|
||||
getSettings(id).rename = true
|
||||
elseif key == 'tpl' then
|
||||
for _, v in pairs(mpGamerTagSettings) do
|
||||
v.rename = true
|
||||
end
|
||||
|
||||
templateStr = args[1]
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playernames:extendContext', function(i, cb)
|
||||
cb('serverName', getSettings(GetPlayerServerId(i)).serverName)
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(name)
|
||||
if name == GetCurrentResourceName() then
|
||||
for _, v in pairs(mpGamerTags) do
|
||||
RemoveMpGamerTag(v.tag)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
SetTimeout(0, function()
|
||||
TriggerServerEvent('playernames:init')
|
||||
end)
|
||||
|
||||
-- run this function every frame
|
||||
SetTimeout(0, updatePlayerNames)
|
||||
@@ -0,0 +1,46 @@
|
||||
local curTemplate
|
||||
local curTags = {}
|
||||
|
||||
local activePlayers = {}
|
||||
|
||||
local function detectUpdates()
|
||||
SetTimeout(500, detectUpdates)
|
||||
|
||||
local template = GetConvar('playerNames_template', '[{{id}}] {{name}}')
|
||||
|
||||
if curTemplate ~= template then
|
||||
setNameTemplate(-1, template)
|
||||
|
||||
curTemplate = template
|
||||
end
|
||||
|
||||
template = GetConvar('playerNames_svTemplate', '[{{id}}] {{name}}')
|
||||
|
||||
for v, _ in pairs(activePlayers) do
|
||||
local newTag = formatPlayerNameTag(v, template)
|
||||
if newTag ~= curTags[v] then
|
||||
setName(v, newTag)
|
||||
|
||||
curTags[v] = newTag
|
||||
end
|
||||
end
|
||||
|
||||
for i, tag in pairs(curTags) do
|
||||
if not activePlayers[i] then
|
||||
curTags[i] = nil -- in case curTags doesnt get cleared when the player left, clear it now.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
curTags[source] = nil
|
||||
activePlayers[source] = nil
|
||||
end)
|
||||
|
||||
RegisterNetEvent('playernames:init')
|
||||
AddEventHandler('playernames:init', function()
|
||||
reconfigure(source)
|
||||
activePlayers[source] = true
|
||||
end)
|
||||
|
||||
detectUpdates()
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2014 - 2017 Aapo Talvensaari
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the {organization} nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,478 @@
|
||||
local setmetatable = setmetatable
|
||||
local loadstring = loadstring
|
||||
local loadchunk
|
||||
local tostring = tostring
|
||||
local setfenv = setfenv
|
||||
local require = require
|
||||
local capture
|
||||
local concat = table.concat
|
||||
local assert = assert
|
||||
local prefix
|
||||
local write = io.write
|
||||
local pcall = pcall
|
||||
local phase
|
||||
local open = io.open
|
||||
local load = load
|
||||
local type = type
|
||||
local dump = string.dump
|
||||
local find = string.find
|
||||
local gsub = string.gsub
|
||||
local byte = string.byte
|
||||
local null
|
||||
local sub = string.sub
|
||||
local ngx = ngx
|
||||
local jit = jit
|
||||
local var
|
||||
|
||||
local _VERSION = _VERSION
|
||||
local _ENV = _ENV
|
||||
local _G = _G
|
||||
|
||||
local HTML_ENTITIES = {
|
||||
["&"] = "&",
|
||||
["<"] = "<",
|
||||
[">"] = ">",
|
||||
['"'] = """,
|
||||
["'"] = "'",
|
||||
["/"] = "/"
|
||||
}
|
||||
|
||||
local CODE_ENTITIES = {
|
||||
["{"] = "{",
|
||||
["}"] = "}",
|
||||
["&"] = "&",
|
||||
["<"] = "<",
|
||||
[">"] = ">",
|
||||
['"'] = """,
|
||||
["'"] = "'",
|
||||
["/"] = "/"
|
||||
}
|
||||
|
||||
local VAR_PHASES
|
||||
|
||||
local ok, newtab = pcall(require, "table.new")
|
||||
if not ok then newtab = function() return {} end end
|
||||
|
||||
local caching = true
|
||||
local template = newtab(0, 12)
|
||||
|
||||
template._VERSION = "1.9"
|
||||
template.cache = {}
|
||||
|
||||
local function enabled(val)
|
||||
if val == nil then return true end
|
||||
return val == true or (val == "1" or val == "true" or val == "on")
|
||||
end
|
||||
|
||||
local function trim(s)
|
||||
return gsub(gsub(s, "^%s+", ""), "%s+$", "")
|
||||
end
|
||||
|
||||
local function rpos(view, s)
|
||||
while s > 0 do
|
||||
local c = sub(view, s, s)
|
||||
if c == " " or c == "\t" or c == "\0" or c == "\x0B" then
|
||||
s = s - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
local function escaped(view, s)
|
||||
if s > 1 and sub(view, s - 1, s - 1) == "\\" then
|
||||
if s > 2 and sub(view, s - 2, s - 2) == "\\" then
|
||||
return false, 1
|
||||
else
|
||||
return true, 1
|
||||
end
|
||||
end
|
||||
return false, 0
|
||||
end
|
||||
|
||||
local function readfile(path)
|
||||
local file = open(path, "rb")
|
||||
if not file then return nil end
|
||||
local content = file:read "*a"
|
||||
file:close()
|
||||
return content
|
||||
end
|
||||
|
||||
local function loadlua(path)
|
||||
return readfile(path) or path
|
||||
end
|
||||
|
||||
local function loadngx(path)
|
||||
local vars = VAR_PHASES[phase()]
|
||||
local file, location = path, vars and var.template_location
|
||||
if sub(file, 1) == "/" then file = sub(file, 2) end
|
||||
if location and location ~= "" then
|
||||
if sub(location, -1) == "/" then location = sub(location, 1, -2) end
|
||||
local res = capture(concat{ location, '/', file})
|
||||
if res.status == 200 then return res.body end
|
||||
end
|
||||
local root = vars and (var.template_root or var.document_root) or prefix
|
||||
if sub(root, -1) == "/" then root = sub(root, 1, -2) end
|
||||
return readfile(concat{ root, "/", file }) or path
|
||||
end
|
||||
|
||||
do
|
||||
if ngx then
|
||||
VAR_PHASES = {
|
||||
set = true,
|
||||
rewrite = true,
|
||||
access = true,
|
||||
content = true,
|
||||
header_filter = true,
|
||||
body_filter = true,
|
||||
log = true
|
||||
}
|
||||
template.print = ngx.print or write
|
||||
template.load = loadngx
|
||||
prefix, var, capture, null, phase = ngx.config.prefix(), ngx.var, ngx.location.capture, ngx.null, ngx.get_phase
|
||||
if VAR_PHASES[phase()] then
|
||||
caching = enabled(var.template_cache)
|
||||
end
|
||||
else
|
||||
template.print = write
|
||||
template.load = loadlua
|
||||
end
|
||||
if _VERSION == "Lua 5.1" then
|
||||
local context = { __index = function(t, k)
|
||||
return t.context[k] or t.template[k] or _G[k]
|
||||
end }
|
||||
if jit then
|
||||
loadchunk = function(view)
|
||||
return assert(load(view, nil, nil, setmetatable({ template = template }, context)))
|
||||
end
|
||||
else
|
||||
loadchunk = function(view)
|
||||
local func = assert(loadstring(view))
|
||||
setfenv(func, setmetatable({ template = template }, context))
|
||||
return func
|
||||
end
|
||||
end
|
||||
else
|
||||
local context = { __index = function(t, k)
|
||||
return t.context[k] or t.template[k] or _ENV[k]
|
||||
end }
|
||||
loadchunk = function(view)
|
||||
return assert(load(view, nil, nil, setmetatable({ template = template }, context)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function template.caching(enable)
|
||||
if enable ~= nil then caching = enable == true end
|
||||
return caching
|
||||
end
|
||||
|
||||
function template.output(s)
|
||||
if s == nil or s == null then return "" end
|
||||
if type(s) == "function" then return template.output(s()) end
|
||||
return tostring(s)
|
||||
end
|
||||
|
||||
function template.escape(s, c)
|
||||
if type(s) == "string" then
|
||||
if c then return gsub(s, "[}{\">/<'&]", CODE_ENTITIES) end
|
||||
return gsub(s, "[\">/<'&]", HTML_ENTITIES)
|
||||
end
|
||||
return template.output(s)
|
||||
end
|
||||
|
||||
function template.new(view, layout)
|
||||
assert(view, "view was not provided for template.new(view, layout).")
|
||||
local render, compile = template.render, template.compile
|
||||
if layout then
|
||||
if type(layout) == "table" then
|
||||
return setmetatable({ render = function(self, context)
|
||||
local context = context or self
|
||||
context.blocks = context.blocks or {}
|
||||
context.view = compile(view)(context)
|
||||
layout.blocks = context.blocks or {}
|
||||
layout.view = context.view or ""
|
||||
return layout:render()
|
||||
end }, { __tostring = function(self)
|
||||
local context = self
|
||||
context.blocks = context.blocks or {}
|
||||
context.view = compile(view)(context)
|
||||
layout.blocks = context.blocks or {}
|
||||
layout.view = context.view
|
||||
return tostring(layout)
|
||||
end })
|
||||
else
|
||||
return setmetatable({ render = function(self, context)
|
||||
local context = context or self
|
||||
context.blocks = context.blocks or {}
|
||||
context.view = compile(view)(context)
|
||||
return render(layout, context)
|
||||
end }, { __tostring = function(self)
|
||||
local context = self
|
||||
context.blocks = context.blocks or {}
|
||||
context.view = compile(view)(context)
|
||||
return compile(layout)(context)
|
||||
end })
|
||||
end
|
||||
end
|
||||
return setmetatable({ render = function(self, context)
|
||||
return render(view, context or self)
|
||||
end }, { __tostring = function(self)
|
||||
return compile(view)(self)
|
||||
end })
|
||||
end
|
||||
|
||||
function template.precompile(view, path, strip)
|
||||
local chunk = dump(template.compile(view), strip ~= false)
|
||||
if path then
|
||||
local file = open(path, "wb")
|
||||
file:write(chunk)
|
||||
file:close()
|
||||
end
|
||||
return chunk
|
||||
end
|
||||
|
||||
function template.compile(view, key, plain)
|
||||
assert(view, "view was not provided for template.compile(view, key, plain).")
|
||||
if key == "no-cache" then
|
||||
return loadchunk(template.parse(view, plain)), false
|
||||
end
|
||||
key = key or view
|
||||
local cache = template.cache
|
||||
if cache[key] then return cache[key], true end
|
||||
local func = loadchunk(template.parse(view, plain))
|
||||
if caching then cache[key] = func end
|
||||
return func, false
|
||||
end
|
||||
|
||||
function template.parse(view, plain)
|
||||
assert(view, "view was not provided for template.parse(view, plain).")
|
||||
if not plain then
|
||||
view = template.load(view)
|
||||
if byte(view, 1, 1) == 27 then return view end
|
||||
end
|
||||
local j = 2
|
||||
local c = {[[
|
||||
context=... or {}
|
||||
local function include(v, c) return template.compile(v)(c or context) end
|
||||
local ___,blocks,layout={},blocks or {}
|
||||
]] }
|
||||
local i, s = 1, find(view, "{", 1, true)
|
||||
while s do
|
||||
local t, p = sub(view, s + 1, s + 1), s + 2
|
||||
if t == "{" then
|
||||
local e = find(view, "}}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
if z then
|
||||
i = s
|
||||
else
|
||||
c[j] = "___[#___+1]=template.escape("
|
||||
c[j+1] = trim(sub(view, p, e - 1))
|
||||
c[j+2] = ")\n"
|
||||
j=j+3
|
||||
s, i = e + 1, e + 2
|
||||
end
|
||||
end
|
||||
elseif t == "*" then
|
||||
local e = find(view, "*}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
if z then
|
||||
i = s
|
||||
else
|
||||
c[j] = "___[#___+1]=template.output("
|
||||
c[j+1] = trim(sub(view, p, e - 1))
|
||||
c[j+2] = ")\n"
|
||||
j=j+3
|
||||
s, i = e + 1, e + 2
|
||||
end
|
||||
end
|
||||
elseif t == "%" then
|
||||
local e = find(view, "%}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if z then
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
i = s
|
||||
else
|
||||
local n = e + 2
|
||||
if sub(view, n, n) == "\n" then
|
||||
n = n + 1
|
||||
end
|
||||
local r = rpos(view, s - 1)
|
||||
if i <= r then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, r)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
c[j] = trim(sub(view, p, e - 1))
|
||||
c[j+1] = "\n"
|
||||
j=j+2
|
||||
s, i = n - 1, n
|
||||
end
|
||||
end
|
||||
elseif t == "(" then
|
||||
local e = find(view, ")}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
if z then
|
||||
i = s
|
||||
else
|
||||
local f = sub(view, p, e - 1)
|
||||
local x = find(f, ",", 2, true)
|
||||
if x then
|
||||
c[j] = "___[#___+1]=include([=["
|
||||
c[j+1] = trim(sub(f, 1, x - 1))
|
||||
c[j+2] = "]=],"
|
||||
c[j+3] = trim(sub(f, x + 1))
|
||||
c[j+4] = ")\n"
|
||||
j=j+5
|
||||
else
|
||||
c[j] = "___[#___+1]=include([=["
|
||||
c[j+1] = trim(f)
|
||||
c[j+2] = "]=])\n"
|
||||
j=j+3
|
||||
end
|
||||
s, i = e + 1, e + 2
|
||||
end
|
||||
end
|
||||
elseif t == "[" then
|
||||
local e = find(view, "]}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
if z then
|
||||
i = s
|
||||
else
|
||||
c[j] = "___[#___+1]=include("
|
||||
c[j+1] = trim(sub(view, p, e - 1))
|
||||
c[j+2] = ")\n"
|
||||
j=j+3
|
||||
s, i = e + 1, e + 2
|
||||
end
|
||||
end
|
||||
elseif t == "-" then
|
||||
local e = find(view, "-}", p, true)
|
||||
if e then
|
||||
local x, y = find(view, sub(view, s, e + 1), e + 2, true)
|
||||
if x then
|
||||
local z, w = escaped(view, s)
|
||||
if z then
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
i = s
|
||||
else
|
||||
y = y + 1
|
||||
x = x - 1
|
||||
if sub(view, y, y) == "\n" then
|
||||
y = y + 1
|
||||
end
|
||||
local b = trim(sub(view, p, e - 1))
|
||||
if b == "verbatim" or b == "raw" then
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
c[j] = "___[#___+1]=[=["
|
||||
c[j+1] = sub(view, e + 2, x)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
else
|
||||
if sub(view, x, x) == "\n" then
|
||||
x = x - 1
|
||||
end
|
||||
local r = rpos(view, s - 1)
|
||||
if i <= r then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, r)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
c[j] = 'blocks["'
|
||||
c[j+1] = b
|
||||
c[j+2] = '"]=include[=['
|
||||
c[j+3] = sub(view, e + 2, x)
|
||||
c[j+4] = "]=]\n"
|
||||
j=j+5
|
||||
end
|
||||
s, i = y - 1, y
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif t == "#" then
|
||||
local e = find(view, "#}", p, true)
|
||||
if e then
|
||||
local z, w = escaped(view, s)
|
||||
if i < s - w then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = sub(view, i, s - 1 - w)
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
if z then
|
||||
i = s
|
||||
else
|
||||
e = e + 2
|
||||
if sub(view, e, e) == "\n" then
|
||||
e = e + 1
|
||||
end
|
||||
s, i = e - 1, e
|
||||
end
|
||||
end
|
||||
end
|
||||
s = find(view, "{", s + 1, true)
|
||||
end
|
||||
s = sub(view, i)
|
||||
if s and s ~= "" then
|
||||
c[j] = "___[#___+1]=[=[\n"
|
||||
c[j+1] = s
|
||||
c[j+2] = "]=]\n"
|
||||
j=j+3
|
||||
end
|
||||
c[j] = "return layout and include(layout,setmetatable({view=table.concat(___),blocks=blocks},{__index=context})) or table.concat(___)"
|
||||
return concat(c)
|
||||
end
|
||||
|
||||
function template.render(view, context, key, plain)
|
||||
assert(view, "view was not provided for template.render(view, context, key, plain).")
|
||||
return template.print(template.compile(view, key, plain)(context))
|
||||
end
|
||||
|
||||
return template
|
||||
0
resources/[cfx-default]/[local]/.gitkeep
Normal file
0
resources/[cfx-default]/[local]/.gitkeep
Normal file
30
resources/[cfx-default]/[managers]/mapmanager/fxmanifest.lua
Normal file
30
resources/[cfx-default]/[managers]/mapmanager/fxmanifest.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'A flexible handler for game type/map association.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_scripts {
|
||||
"mapmanager_shared.lua",
|
||||
"mapmanager_client.lua"
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
"mapmanager_shared.lua",
|
||||
"mapmanager_server.lua"
|
||||
}
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'gta5', 'rdr3' }
|
||||
|
||||
server_export "getCurrentGameType"
|
||||
server_export "getCurrentMap"
|
||||
server_export "changeGameType"
|
||||
server_export "changeMap"
|
||||
server_export "doesMapSupportGameType"
|
||||
server_export "getMaps"
|
||||
server_export "roundEnded"
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
@@ -0,0 +1,108 @@
|
||||
local maps = {}
|
||||
local gametypes = {}
|
||||
|
||||
AddEventHandler('onClientResourceStart', function(res)
|
||||
-- parse metadata for this resource
|
||||
|
||||
-- map files
|
||||
local num = GetNumResourceMetadata(res, 'map')
|
||||
|
||||
if num > 0 then
|
||||
for i = 0, num-1 do
|
||||
local file = GetResourceMetadata(res, 'map', i)
|
||||
|
||||
if file then
|
||||
addMap(file, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- resource type data
|
||||
local type = GetResourceMetadata(res, 'resource_type', 0)
|
||||
|
||||
if type then
|
||||
local extraData = GetResourceMetadata(res, 'resource_type_extra', 0)
|
||||
|
||||
if extraData then
|
||||
extraData = json.decode(extraData)
|
||||
else
|
||||
extraData = {}
|
||||
end
|
||||
|
||||
if type == 'map' then
|
||||
maps[res] = extraData
|
||||
elseif type == 'gametype' then
|
||||
gametypes[res] = extraData
|
||||
end
|
||||
end
|
||||
|
||||
-- handle starting
|
||||
loadMap(res)
|
||||
|
||||
-- defer this to the next game tick to work around a lack of dependencies
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(15)
|
||||
|
||||
if maps[res] then
|
||||
TriggerEvent('onClientMapStart', res)
|
||||
elseif gametypes[res] then
|
||||
TriggerEvent('onClientGameTypeStart', res)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(res)
|
||||
if maps[res] then
|
||||
TriggerEvent('onClientMapStop', res)
|
||||
elseif gametypes[res] then
|
||||
TriggerEvent('onClientGameTypeStop', res)
|
||||
end
|
||||
|
||||
unloadMap(res)
|
||||
end)
|
||||
|
||||
AddEventHandler('getMapDirectives', function(add)
|
||||
if not CreateScriptVehicleGenerator then
|
||||
return
|
||||
end
|
||||
|
||||
add('vehicle_generator', function(state, name)
|
||||
return function(opts)
|
||||
local x, y, z, heading
|
||||
local color1, color2
|
||||
|
||||
if opts.x then
|
||||
x = opts.x
|
||||
y = opts.y
|
||||
z = opts.z
|
||||
else
|
||||
x = opts[1]
|
||||
y = opts[2]
|
||||
z = opts[3]
|
||||
end
|
||||
|
||||
heading = opts.heading or 1.0
|
||||
color1 = opts.color1 or -1
|
||||
color2 = opts.color2 or -1
|
||||
|
||||
CreateThread(function()
|
||||
local hash = GetHashKey(name)
|
||||
RequestModel(hash)
|
||||
|
||||
while not HasModelLoaded(hash) do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
local carGen = CreateScriptVehicleGenerator(x, y, z, heading, 5.0, 3.0, hash, color1, color2, -1, -1, true, false, false, true, true, -1)
|
||||
SetScriptVehicleGenerator(carGen, true)
|
||||
SetAllVehicleGeneratorsActive(true)
|
||||
|
||||
state.add('cargen', carGen)
|
||||
end)
|
||||
end
|
||||
end, function(state, arg)
|
||||
Citizen.Trace("deleting car gen " .. tostring(state.cargen) .. "\n")
|
||||
|
||||
DeleteScriptVehicleGenerator(state.cargen)
|
||||
end)
|
||||
end)
|
||||
@@ -0,0 +1,331 @@
|
||||
-- loosely based on MTA's https://code.google.com/p/mtasa-resources/source/browse/trunk/%5Bmanagers%5D/mapmanager/mapmanager_main.lua
|
||||
|
||||
local maps = {}
|
||||
local gametypes = {}
|
||||
|
||||
local function refreshResources()
|
||||
local numResources = GetNumResources()
|
||||
|
||||
for i = 0, numResources - 1 do
|
||||
local resource = GetResourceByFindIndex(i)
|
||||
|
||||
if GetNumResourceMetadata(resource, 'resource_type') > 0 then
|
||||
local type = GetResourceMetadata(resource, 'resource_type', 0)
|
||||
local params = json.decode(GetResourceMetadata(resource, 'resource_type_extra', 0))
|
||||
|
||||
local valid = false
|
||||
|
||||
local games = GetNumResourceMetadata(resource, 'game')
|
||||
if games > 0 then
|
||||
for j = 0, games - 1 do
|
||||
local game = GetResourceMetadata(resource, 'game', j)
|
||||
|
||||
if game == GetConvar('gamename', 'gta5') or game == 'common' then
|
||||
valid = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if valid then
|
||||
if type == 'map' then
|
||||
maps[resource] = params
|
||||
elseif type == 'gametype' then
|
||||
gametypes[resource] = params
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceListRefresh', function()
|
||||
refreshResources()
|
||||
end)
|
||||
|
||||
refreshResources()
|
||||
|
||||
AddEventHandler('onResourceStarting', function(resource)
|
||||
local num = GetNumResourceMetadata(resource, 'map')
|
||||
|
||||
if num then
|
||||
for i = 0, num-1 do
|
||||
local file = GetResourceMetadata(resource, 'map', i)
|
||||
|
||||
if file then
|
||||
addMap(file, resource)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if maps[resource] then
|
||||
if getCurrentMap() and getCurrentMap() ~= resource then
|
||||
if doesMapSupportGameType(getCurrentGameType(), resource) then
|
||||
print("Changing map from " .. getCurrentMap() .. " to " .. resource)
|
||||
|
||||
changeMap(resource)
|
||||
else
|
||||
-- check if there's only one possible game type for the map
|
||||
local map = maps[resource]
|
||||
local count = 0
|
||||
local gt
|
||||
|
||||
for type, flag in pairs(map.gameTypes) do
|
||||
if flag then
|
||||
count = count + 1
|
||||
gt = type
|
||||
end
|
||||
end
|
||||
|
||||
if count == 1 then
|
||||
print("Changing map from " .. getCurrentMap() .. " to " .. resource .. " (gt " .. gt .. ")")
|
||||
|
||||
changeGameType(gt)
|
||||
changeMap(resource)
|
||||
end
|
||||
end
|
||||
|
||||
CancelEvent()
|
||||
end
|
||||
elseif gametypes[resource] then
|
||||
if getCurrentGameType() and getCurrentGameType() ~= resource then
|
||||
print("Changing gametype from " .. getCurrentGameType() .. " to " .. resource)
|
||||
|
||||
changeGameType(resource)
|
||||
|
||||
CancelEvent()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
math.randomseed(GetInstanceId())
|
||||
|
||||
local currentGameType = nil
|
||||
local currentMap = nil
|
||||
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if maps[resource] then
|
||||
if not getCurrentGameType() then
|
||||
for gt, _ in pairs(maps[resource].gameTypes) do
|
||||
changeGameType(gt)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if getCurrentGameType() and not getCurrentMap() then
|
||||
if doesMapSupportGameType(currentGameType, resource) then
|
||||
if TriggerEvent('onMapStart', resource, maps[resource]) then
|
||||
if maps[resource].name then
|
||||
print('Started map ' .. maps[resource].name)
|
||||
SetMapName(maps[resource].name)
|
||||
else
|
||||
print('Started map ' .. resource)
|
||||
SetMapName(resource)
|
||||
end
|
||||
|
||||
currentMap = resource
|
||||
else
|
||||
currentMap = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif gametypes[resource] then
|
||||
if not getCurrentGameType() then
|
||||
if TriggerEvent('onGameTypeStart', resource, gametypes[resource]) then
|
||||
currentGameType = resource
|
||||
|
||||
local gtName = gametypes[resource].name or resource
|
||||
|
||||
SetGameType(gtName)
|
||||
|
||||
print('Started gametype ' .. gtName)
|
||||
|
||||
SetTimeout(50, function()
|
||||
if not currentMap then
|
||||
local possibleMaps = {}
|
||||
|
||||
for map, data in pairs(maps) do
|
||||
if data.gameTypes[currentGameType] then
|
||||
table.insert(possibleMaps, map)
|
||||
end
|
||||
end
|
||||
|
||||
if #possibleMaps > 0 then
|
||||
local rnd = math.random(#possibleMaps)
|
||||
changeMap(possibleMaps[rnd])
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
currentGameType = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- handle starting
|
||||
loadMap(resource)
|
||||
end)
|
||||
|
||||
local function handleRoundEnd()
|
||||
local possibleMaps = {}
|
||||
|
||||
for map, data in pairs(maps) do
|
||||
if data.gameTypes[currentGameType] then
|
||||
table.insert(possibleMaps, map)
|
||||
end
|
||||
end
|
||||
|
||||
if #possibleMaps > 1 then
|
||||
local mapname = currentMap
|
||||
|
||||
while mapname == currentMap do
|
||||
local rnd = math.random(#possibleMaps)
|
||||
mapname = possibleMaps[rnd]
|
||||
end
|
||||
|
||||
changeMap(mapname)
|
||||
elseif #possibleMaps > 0 then
|
||||
local rnd = math.random(#possibleMaps)
|
||||
changeMap(possibleMaps[rnd])
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('mapmanager:roundEnded', function()
|
||||
-- set a timeout as we don't want to return to a dead environment
|
||||
SetTimeout(50, handleRoundEnd) -- not a closure as to work around some issue in neolua?
|
||||
end)
|
||||
|
||||
function roundEnded()
|
||||
SetTimeout(50, handleRoundEnd)
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
if resource == currentGameType then
|
||||
TriggerEvent('onGameTypeStop', resource)
|
||||
|
||||
currentGameType = nil
|
||||
|
||||
if currentMap then
|
||||
StopResource(currentMap)
|
||||
end
|
||||
elseif resource == currentMap then
|
||||
TriggerEvent('onMapStop', resource)
|
||||
|
||||
currentMap = nil
|
||||
end
|
||||
|
||||
-- unload the map
|
||||
unloadMap(resource)
|
||||
end)
|
||||
|
||||
AddEventHandler('rconCommand', function(commandName, args)
|
||||
if commandName == 'map' then
|
||||
if #args ~= 1 then
|
||||
RconPrint("usage: map [mapname]\n")
|
||||
end
|
||||
|
||||
if not maps[args[1]] then
|
||||
RconPrint('no such map ' .. args[1] .. "\n")
|
||||
CancelEvent()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if currentGameType == nil or not doesMapSupportGameType(currentGameType, args[1]) then
|
||||
local map = maps[args[1]]
|
||||
local count = 0
|
||||
local gt
|
||||
|
||||
for type, flag in pairs(map.gameTypes) do
|
||||
if flag then
|
||||
count = count + 1
|
||||
gt = type
|
||||
end
|
||||
end
|
||||
|
||||
if count == 1 then
|
||||
print("Changing map from " .. getCurrentMap() .. " to " .. args[1] .. " (gt " .. gt .. ")")
|
||||
|
||||
changeGameType(gt)
|
||||
changeMap(args[1])
|
||||
|
||||
RconPrint('map ' .. args[1] .. "\n")
|
||||
else
|
||||
RconPrint('map ' .. args[1] .. ' does not support ' .. currentGameType .. "\n")
|
||||
end
|
||||
|
||||
CancelEvent()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
changeMap(args[1])
|
||||
|
||||
RconPrint('map ' .. args[1] .. "\n")
|
||||
|
||||
CancelEvent()
|
||||
elseif commandName == 'gametype' then
|
||||
if #args ~= 1 then
|
||||
RconPrint("usage: gametype [name]\n")
|
||||
end
|
||||
|
||||
if not gametypes[args[1]] then
|
||||
RconPrint('no such gametype ' .. args[1] .. "\n")
|
||||
CancelEvent()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
changeGameType(args[1])
|
||||
|
||||
RconPrint('gametype ' .. args[1] .. "\n")
|
||||
|
||||
CancelEvent()
|
||||
end
|
||||
end)
|
||||
|
||||
function getCurrentGameType()
|
||||
return currentGameType
|
||||
end
|
||||
|
||||
function getCurrentMap()
|
||||
return currentMap
|
||||
end
|
||||
|
||||
function getMaps()
|
||||
return maps
|
||||
end
|
||||
|
||||
function changeGameType(gameType)
|
||||
if currentMap and not doesMapSupportGameType(gameType, currentMap) then
|
||||
StopResource(currentMap)
|
||||
end
|
||||
|
||||
if currentGameType then
|
||||
StopResource(currentGameType)
|
||||
end
|
||||
|
||||
StartResource(gameType)
|
||||
end
|
||||
|
||||
function changeMap(map)
|
||||
if currentMap then
|
||||
StopResource(currentMap)
|
||||
end
|
||||
|
||||
StartResource(map)
|
||||
end
|
||||
|
||||
function doesMapSupportGameType(gameType, map)
|
||||
if not gametypes[gameType] then
|
||||
return false
|
||||
end
|
||||
|
||||
if not maps[map] then
|
||||
return false
|
||||
end
|
||||
|
||||
if not maps[map].gameTypes then
|
||||
return true
|
||||
end
|
||||
|
||||
return maps[map].gameTypes[gameType]
|
||||
end
|
||||
@@ -0,0 +1,87 @@
|
||||
-- shared logic file for map manager - don't call any subsystem-specific functions here
|
||||
mapFiles = {}
|
||||
|
||||
function addMap(file, owningResource)
|
||||
if not mapFiles[owningResource] then
|
||||
mapFiles[owningResource] = {}
|
||||
end
|
||||
|
||||
table.insert(mapFiles[owningResource], file)
|
||||
end
|
||||
|
||||
undoCallbacks = {}
|
||||
|
||||
function loadMap(res)
|
||||
if mapFiles[res] then
|
||||
for _, file in ipairs(mapFiles[res]) do
|
||||
parseMap(file, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function unloadMap(res)
|
||||
if undoCallbacks[res] then
|
||||
for _, cb in ipairs(undoCallbacks[res]) do
|
||||
cb()
|
||||
end
|
||||
|
||||
undoCallbacks[res] = nil
|
||||
mapFiles[res] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function parseMap(file, owningResource)
|
||||
if not undoCallbacks[owningResource] then
|
||||
undoCallbacks[owningResource] = {}
|
||||
end
|
||||
|
||||
local env = {
|
||||
math = math, pairs = pairs, ipairs = ipairs, next = next, tonumber = tonumber, tostring = tostring,
|
||||
type = type, table = table, string = string, _G = env,
|
||||
vector3 = vector3, quat = quat, vec = vec, vector2 = vector2
|
||||
}
|
||||
|
||||
TriggerEvent('getMapDirectives', function(key, cb, undocb)
|
||||
env[key] = function(...)
|
||||
local state = {}
|
||||
|
||||
state.add = function(k, v)
|
||||
state[k] = v
|
||||
end
|
||||
|
||||
local result = cb(state, ...)
|
||||
local args = table.pack(...)
|
||||
|
||||
table.insert(undoCallbacks[owningResource], function()
|
||||
undocb(state)
|
||||
end)
|
||||
|
||||
return result
|
||||
end
|
||||
end)
|
||||
|
||||
local mt = {
|
||||
__index = function(t, k)
|
||||
if rawget(t, k) ~= nil then return rawget(t, k) end
|
||||
|
||||
-- as we're not going to return nothing here (to allow unknown directives to be ignored)
|
||||
local f = function()
|
||||
return f
|
||||
end
|
||||
|
||||
return function() return f end
|
||||
end
|
||||
}
|
||||
|
||||
setmetatable(env, mt)
|
||||
|
||||
local fileData = LoadResourceFile(owningResource, file)
|
||||
local mapFunction, err = load(fileData, file, 't', env)
|
||||
|
||||
if not mapFunction then
|
||||
Citizen.Trace("Couldn't load map " .. file .. ": " .. err .. " (type of fileData: " .. type(fileData) .. ")\n")
|
||||
return
|
||||
end
|
||||
|
||||
mapFunction()
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Handles spawning a player in a unified fashion to prevent resources from having to implement custom spawn logic.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'spawnmanager.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'rdr3', 'gta5' }
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
386
resources/[cfx-default]/[managers]/spawnmanager/spawnmanager.lua
Normal file
386
resources/[cfx-default]/[managers]/spawnmanager/spawnmanager.lua
Normal file
@@ -0,0 +1,386 @@
|
||||
-- in-memory spawnpoint array for this script execution instance
|
||||
local spawnPoints = {}
|
||||
|
||||
-- auto-spawn enabled flag
|
||||
local autoSpawnEnabled = false
|
||||
local autoSpawnCallback
|
||||
|
||||
-- support for mapmanager maps
|
||||
AddEventHandler('getMapDirectives', function(add)
|
||||
-- call the remote callback
|
||||
add('spawnpoint', function(state, model)
|
||||
-- return another callback to pass coordinates and so on (as such syntax would be [spawnpoint 'model' { options/coords }])
|
||||
return function(opts)
|
||||
local x, y, z, heading
|
||||
|
||||
local s, e = pcall(function()
|
||||
-- is this a map or an array?
|
||||
if opts.x then
|
||||
x = opts.x
|
||||
y = opts.y
|
||||
z = opts.z
|
||||
else
|
||||
x = opts[1]
|
||||
y = opts[2]
|
||||
z = opts[3]
|
||||
end
|
||||
|
||||
x = x + 0.0001
|
||||
y = y + 0.0001
|
||||
z = z + 0.0001
|
||||
|
||||
-- get a heading and force it to a float, or just default to null
|
||||
heading = opts.heading and (opts.heading + 0.01) or 0
|
||||
|
||||
-- add the spawnpoint
|
||||
addSpawnPoint({
|
||||
x = x, y = y, z = z,
|
||||
heading = heading,
|
||||
model = model
|
||||
})
|
||||
|
||||
-- recalculate the model for storage
|
||||
if not tonumber(model) then
|
||||
model = GetHashKey(model, _r)
|
||||
end
|
||||
|
||||
-- store the spawn data in the state so we can erase it later on
|
||||
state.add('xyz', { x, y, z })
|
||||
state.add('model', model)
|
||||
end)
|
||||
|
||||
if not s then
|
||||
Citizen.Trace(e .. "\n")
|
||||
end
|
||||
end
|
||||
-- delete callback follows on the next line
|
||||
end, function(state, arg)
|
||||
-- loop through all spawn points to find one with our state
|
||||
for i, sp in ipairs(spawnPoints) do
|
||||
-- if it matches...
|
||||
if sp.x == state.xyz[1] and sp.y == state.xyz[2] and sp.z == state.xyz[3] and sp.model == state.model then
|
||||
-- remove it.
|
||||
table.remove(spawnPoints, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
-- loads a set of spawn points from a JSON string
|
||||
function loadSpawns(spawnString)
|
||||
-- decode the JSON string
|
||||
local data = json.decode(spawnString)
|
||||
|
||||
-- do we have a 'spawns' field?
|
||||
if not data.spawns then
|
||||
error("no 'spawns' in JSON data")
|
||||
end
|
||||
|
||||
-- loop through the spawns
|
||||
for i, spawn in ipairs(data.spawns) do
|
||||
-- and add it to the list (validating as we go)
|
||||
addSpawnPoint(spawn)
|
||||
end
|
||||
end
|
||||
|
||||
local spawnNum = 1
|
||||
|
||||
function addSpawnPoint(spawn)
|
||||
-- validate the spawn (position)
|
||||
if not tonumber(spawn.x) or not tonumber(spawn.y) or not tonumber(spawn.z) then
|
||||
error("invalid spawn position")
|
||||
end
|
||||
|
||||
-- heading
|
||||
if not tonumber(spawn.heading) then
|
||||
error("invalid spawn heading")
|
||||
end
|
||||
|
||||
-- model (try integer first, if not, hash it)
|
||||
local model = spawn.model
|
||||
|
||||
if not tonumber(spawn.model) then
|
||||
model = GetHashKey(spawn.model)
|
||||
end
|
||||
|
||||
-- is the model actually a model?
|
||||
if not IsModelInCdimage(model) then
|
||||
error("invalid spawn model")
|
||||
end
|
||||
|
||||
-- is is even a ped?
|
||||
-- not in V?
|
||||
--[[if not IsThisModelAPed(model) then
|
||||
error("this model ain't a ped!")
|
||||
end]]
|
||||
|
||||
-- overwrite the model in case we hashed it
|
||||
spawn.model = model
|
||||
|
||||
-- add an index
|
||||
spawn.idx = spawnNum
|
||||
spawnNum = spawnNum + 1
|
||||
|
||||
-- all OK, add the spawn entry to the list
|
||||
table.insert(spawnPoints, spawn)
|
||||
|
||||
return spawn.idx
|
||||
end
|
||||
|
||||
-- removes a spawn point
|
||||
function removeSpawnPoint(spawn)
|
||||
for i = 1, #spawnPoints do
|
||||
if spawnPoints[i].idx == spawn then
|
||||
table.remove(spawnPoints, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- changes the auto-spawn flag
|
||||
function setAutoSpawn(enabled)
|
||||
autoSpawnEnabled = enabled
|
||||
end
|
||||
|
||||
-- sets a callback to execute instead of 'native' spawning when trying to auto-spawn
|
||||
function setAutoSpawnCallback(cb)
|
||||
autoSpawnCallback = cb
|
||||
autoSpawnEnabled = true
|
||||
end
|
||||
|
||||
-- function as existing in original R* scripts
|
||||
local function freezePlayer(id, freeze)
|
||||
local player = id
|
||||
SetPlayerControl(player, not freeze, false)
|
||||
|
||||
local ped = GetPlayerPed(player)
|
||||
|
||||
if not freeze then
|
||||
if not IsEntityVisible(ped) then
|
||||
SetEntityVisible(ped, true)
|
||||
end
|
||||
|
||||
if not IsPedInAnyVehicle(ped) then
|
||||
SetEntityCollision(ped, true)
|
||||
end
|
||||
|
||||
FreezeEntityPosition(ped, false)
|
||||
--SetCharNeverTargetted(ped, false)
|
||||
SetPlayerInvincible(player, false)
|
||||
else
|
||||
if IsEntityVisible(ped) then
|
||||
SetEntityVisible(ped, false)
|
||||
end
|
||||
|
||||
SetEntityCollision(ped, false)
|
||||
FreezeEntityPosition(ped, true)
|
||||
--SetCharNeverTargetted(ped, true)
|
||||
SetPlayerInvincible(player, true)
|
||||
--RemovePtfxFromPed(ped)
|
||||
|
||||
if not IsPedFatallyInjured(ped) then
|
||||
ClearPedTasksImmediately(ped)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function loadScene(x, y, z)
|
||||
if not NewLoadSceneStart then
|
||||
return
|
||||
end
|
||||
|
||||
NewLoadSceneStart(x, y, z, 0.0, 0.0, 0.0, 20.0, 0)
|
||||
|
||||
while IsNewLoadSceneActive() do
|
||||
networkTimer = GetNetworkTimer()
|
||||
|
||||
NetworkUpdateLoadScene()
|
||||
end
|
||||
end
|
||||
|
||||
-- to prevent trying to spawn multiple times
|
||||
local spawnLock = false
|
||||
|
||||
-- spawns the current player at a certain spawn point index (or a random one, for that matter)
|
||||
function spawnPlayer(spawnIdx, cb)
|
||||
if spawnLock then
|
||||
return
|
||||
end
|
||||
|
||||
spawnLock = true
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
-- if the spawn isn't set, select a random one
|
||||
if not spawnIdx then
|
||||
spawnIdx = GetRandomIntInRange(1, #spawnPoints + 1)
|
||||
end
|
||||
|
||||
-- get the spawn from the array
|
||||
local spawn
|
||||
|
||||
if type(spawnIdx) == 'table' then
|
||||
spawn = spawnIdx
|
||||
|
||||
-- prevent errors when passing spawn table
|
||||
spawn.x = spawn.x + 0.00
|
||||
spawn.y = spawn.y + 0.00
|
||||
spawn.z = spawn.z + 0.00
|
||||
|
||||
spawn.heading = spawn.heading and (spawn.heading + 0.00) or 0
|
||||
else
|
||||
spawn = spawnPoints[spawnIdx]
|
||||
end
|
||||
|
||||
if not spawn.skipFade then
|
||||
DoScreenFadeOut(500)
|
||||
|
||||
while not IsScreenFadedOut() do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- validate the index
|
||||
if not spawn then
|
||||
Citizen.Trace("tried to spawn at an invalid spawn index\n")
|
||||
|
||||
spawnLock = false
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- freeze the local player
|
||||
freezePlayer(PlayerId(), true)
|
||||
|
||||
-- if the spawn has a model set
|
||||
if spawn.model then
|
||||
RequestModel(spawn.model)
|
||||
|
||||
-- load the model for this spawn
|
||||
while not HasModelLoaded(spawn.model) do
|
||||
RequestModel(spawn.model)
|
||||
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
-- change the player model
|
||||
SetPlayerModel(PlayerId(), spawn.model)
|
||||
|
||||
-- release the player model
|
||||
SetModelAsNoLongerNeeded(spawn.model)
|
||||
|
||||
-- RDR3 player model bits
|
||||
if N_0x283978a15512b2fe then
|
||||
N_0x283978a15512b2fe(PlayerPedId(), true)
|
||||
end
|
||||
end
|
||||
|
||||
-- preload collisions for the spawnpoint
|
||||
RequestCollisionAtCoord(spawn.x, spawn.y, spawn.z)
|
||||
|
||||
-- spawn the player
|
||||
local ped = PlayerPedId()
|
||||
|
||||
-- V requires setting coords as well
|
||||
SetEntityCoordsNoOffset(ped, spawn.x, spawn.y, spawn.z, false, false, false, true)
|
||||
|
||||
NetworkResurrectLocalPlayer(spawn.x, spawn.y, spawn.z, spawn.heading, true, true, false)
|
||||
|
||||
-- gamelogic-style cleanup stuff
|
||||
ClearPedTasksImmediately(ped)
|
||||
--SetEntityHealth(ped, 300) -- TODO: allow configuration of this?
|
||||
RemoveAllPedWeapons(ped) -- TODO: make configurable (V behavior?)
|
||||
ClearPlayerWantedLevel(PlayerId())
|
||||
|
||||
-- why is this even a flag?
|
||||
--SetCharWillFlyThroughWindscreen(ped, false)
|
||||
|
||||
-- set primary camera heading
|
||||
--SetGameCamHeading(spawn.heading)
|
||||
--CamRestoreJumpcut(GetGameCam())
|
||||
|
||||
-- load the scene; streaming expects us to do it
|
||||
--ForceLoadingScreen(true)
|
||||
--loadScene(spawn.x, spawn.y, spawn.z)
|
||||
--ForceLoadingScreen(false)
|
||||
|
||||
local time = GetGameTimer()
|
||||
|
||||
while (not HasCollisionLoadedAroundEntity(ped) and (GetGameTimer() - time) < 5000) do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
ShutdownLoadingScreen()
|
||||
|
||||
if IsScreenFadedOut() then
|
||||
DoScreenFadeIn(500)
|
||||
|
||||
while not IsScreenFadedIn() do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- and unfreeze the player
|
||||
freezePlayer(PlayerId(), false)
|
||||
|
||||
TriggerEvent('playerSpawned', spawn)
|
||||
|
||||
if cb then
|
||||
cb(spawn)
|
||||
end
|
||||
|
||||
spawnLock = false
|
||||
end)
|
||||
end
|
||||
|
||||
-- automatic spawning monitor thread, too
|
||||
local respawnForced
|
||||
local diedAt
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
-- main loop thing
|
||||
while true do
|
||||
Citizen.Wait(50)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if playerPed and playerPed ~= -1 then
|
||||
-- check if we want to autospawn
|
||||
if autoSpawnEnabled then
|
||||
if NetworkIsPlayerActive(PlayerId()) then
|
||||
if (diedAt and (math.abs(GetTimeDifference(GetGameTimer(), diedAt)) > 2000)) or respawnForced then
|
||||
if autoSpawnCallback then
|
||||
autoSpawnCallback()
|
||||
else
|
||||
spawnPlayer()
|
||||
end
|
||||
|
||||
respawnForced = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if IsEntityDead(playerPed) then
|
||||
if not diedAt then
|
||||
diedAt = GetGameTimer()
|
||||
end
|
||||
else
|
||||
diedAt = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function forceRespawn()
|
||||
spawnLock = false
|
||||
respawnForced = true
|
||||
end
|
||||
|
||||
exports('spawnPlayer', spawnPlayer)
|
||||
exports('addSpawnPoint', addSpawnPoint)
|
||||
exports('removeSpawnPoint', removeSpawnPoint)
|
||||
exports('loadSpawns', loadSpawns)
|
||||
exports('setAutoSpawn', setAutoSpawn)
|
||||
exports('setAutoSpawnCallback', setAutoSpawnCallback)
|
||||
exports('forceRespawn', forceRespawn)
|
||||
2
resources/[cfx-default]/[system]/[builders]/webpack/.gitignore
vendored
Normal file
2
resources/[cfx-default]/[system]/[builders]/webpack/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.yarn.installed
|
||||
node_modules/
|
||||
@@ -0,0 +1,13 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Builds resources with webpack. To learn more: https://webpack.js.org'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
dependency 'yarn'
|
||||
server_script 'webpack_builder.js'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'common'
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "webpack-builder",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"async": "^3.1.0",
|
||||
"webpack": "^4.41.2",
|
||||
"worker-farm": "^1.7.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const workerFarm = require('worker-farm');
|
||||
const async = require('async');
|
||||
let buildingInProgress = false;
|
||||
let currentBuildingModule = '';
|
||||
|
||||
// some modules will not like the custom stack trace logic
|
||||
const ops = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = undefined;
|
||||
|
||||
const webpackBuildTask = {
|
||||
shouldBuild(resourceName) {
|
||||
const numMetaData = GetNumResourceMetadata(resourceName, 'webpack_config');
|
||||
|
||||
if (numMetaData > 0) {
|
||||
for (let i = 0; i < numMetaData; i++) {
|
||||
const configName = GetResourceMetadata(resourceName, 'webpack_config');
|
||||
|
||||
if (shouldBuild(configName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
function loadCache(config) {
|
||||
const cachePath = `cache/${resourceName}/${config.replace(/\//g, '_')}.json`;
|
||||
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(cachePath, {encoding: 'utf8'}));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function shouldBuild(config) {
|
||||
const cache = loadCache(config);
|
||||
|
||||
if (!cache) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const file of cache) {
|
||||
const stats = getStat(file.name);
|
||||
|
||||
if (!stats ||
|
||||
stats.mtime !== file.stats.mtime ||
|
||||
stats.size !== file.stats.size ||
|
||||
stats.inode !== file.stats.inode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getStat(path) {
|
||||
try {
|
||||
const stat = fs.statSync(path);
|
||||
|
||||
return stat ? {
|
||||
mtime: stat.mtimeMs,
|
||||
size: stat.size,
|
||||
inode: stat.ino,
|
||||
} : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
build(resourceName, cb) {
|
||||
let buildWebpack = async () => {
|
||||
let error = null;
|
||||
const configs = [];
|
||||
const promises = [];
|
||||
const numMetaData = GetNumResourceMetadata(resourceName, 'webpack_config');
|
||||
|
||||
for (let i = 0; i < numMetaData; i++) {
|
||||
configs.push(GetResourceMetadata(resourceName, 'webpack_config', i));
|
||||
}
|
||||
|
||||
for (const configName of configs) {
|
||||
const configPath = GetResourcePath(resourceName) + '/' + configName;
|
||||
|
||||
const cachePath = `cache/${resourceName}/${configName.replace(/\//g, '_')}.json`;
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(cachePath));
|
||||
} catch {
|
||||
}
|
||||
|
||||
const config = require(configPath);
|
||||
|
||||
const workers = workerFarm(require.resolve('./webpack_runner'));
|
||||
|
||||
if (config) {
|
||||
const resourcePath = path.resolve(GetResourcePath(resourceName));
|
||||
|
||||
while (buildingInProgress) {
|
||||
console.log(`webpack is busy: we are waiting to compile ${resourceName} (${configName})`);
|
||||
await sleep(3000);
|
||||
}
|
||||
|
||||
console.log(`${resourceName}: started building ${configName}`);
|
||||
|
||||
buildingInProgress = true;
|
||||
currentBuildingModule = resourceName;
|
||||
|
||||
promises.push(new Promise((resolve, reject) => {
|
||||
workers({
|
||||
configPath,
|
||||
resourcePath,
|
||||
cachePath
|
||||
}, (err, outp) => {
|
||||
workerFarm.end(workers);
|
||||
|
||||
if (err) {
|
||||
console.error(err.stack || err);
|
||||
if (err.details) {
|
||||
console.error(err.details);
|
||||
}
|
||||
|
||||
buildingInProgress = false;
|
||||
currentBuildingModule = '';
|
||||
currentBuildingScript = '';
|
||||
reject("worker farm webpack errored out");
|
||||
return;
|
||||
}
|
||||
|
||||
if (outp.errors) {
|
||||
for (const error of outp.errors) {
|
||||
console.log(error);
|
||||
}
|
||||
buildingInProgress = false;
|
||||
currentBuildingModule = '';
|
||||
currentBuildingScript = '';
|
||||
reject("webpack got an error");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`${resourceName}: built ${configName}`);
|
||||
buildingInProgress = false;
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
}
|
||||
|
||||
buildingInProgress = false;
|
||||
currentBuildingModule = '';
|
||||
|
||||
if (error) {
|
||||
cb(false, error);
|
||||
} else cb(true);
|
||||
};
|
||||
buildWebpack().then();
|
||||
}
|
||||
};
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
RegisterResourceBuildTaskFactory('z_webpack', () => webpackBuildTask);
|
||||
@@ -0,0 +1,75 @@
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
function getStat(path) {
|
||||
try {
|
||||
const stat = fs.statSync(path);
|
||||
|
||||
return stat ? {
|
||||
mtime: stat.mtimeMs,
|
||||
size: stat.size,
|
||||
inode: stat.ino,
|
||||
} : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SaveStatePlugin {
|
||||
constructor(inp) {
|
||||
this.cache = [];
|
||||
this.cachePath = inp.cachePath;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.hooks.afterCompile.tap('SaveStatePlugin', (compilation) => {
|
||||
for (const file of compilation.fileDependencies) {
|
||||
this.cache.push({
|
||||
name: file,
|
||||
stats: getStat(file)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
compiler.hooks.done.tap('SaveStatePlugin', (stats) => {
|
||||
if (stats.hasErrors()) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFile(this.cachePath, JSON.stringify(this.cache), () => {
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (inp, callback) => {
|
||||
const config = require(inp.configPath);
|
||||
|
||||
config.context = inp.resourcePath;
|
||||
|
||||
if (config.output && config.output.path) {
|
||||
config.output.path = path.resolve(inp.resourcePath, config.output.path);
|
||||
}
|
||||
|
||||
if (!config.plugins) {
|
||||
config.plugins = [];
|
||||
}
|
||||
|
||||
config.plugins.push(new SaveStatePlugin(inp));
|
||||
|
||||
webpack(config, (err, stats) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stats.hasErrors()) {
|
||||
callback(null, stats.toJson());
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, {});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Builds resources with yarn. To learn more: https://classic.yarnpkg.com'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'common'
|
||||
|
||||
server_script 'yarn_builder.js'
|
||||
@@ -0,0 +1,81 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const child_process = require('child_process');
|
||||
let buildingInProgress = false;
|
||||
let currentBuildingModule = '';
|
||||
|
||||
const initCwd = process.cwd();
|
||||
const trimOutput = (data) => {
|
||||
return `[yarn]\t` + data.toString().replace(/\s+$/, '');
|
||||
}
|
||||
|
||||
const yarnBuildTask = {
|
||||
shouldBuild(resourceName) {
|
||||
try {
|
||||
const resourcePath = GetResourcePath(resourceName);
|
||||
|
||||
const packageJson = path.resolve(resourcePath, 'package.json');
|
||||
const yarnLock = path.resolve(resourcePath, '.yarn.installed');
|
||||
|
||||
const packageStat = fs.statSync(packageJson);
|
||||
|
||||
try {
|
||||
const yarnStat = fs.statSync(yarnLock);
|
||||
|
||||
if (packageStat.mtimeMs > yarnStat.mtimeMs) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// no yarn.installed, but package.json - install time!
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
build(resourceName, cb) {
|
||||
(async () => {
|
||||
while (buildingInProgress && currentBuildingModule !== resourceName) {
|
||||
console.log(`yarn is currently busy: we are waiting to compile ${resourceName}`);
|
||||
await sleep(3000);
|
||||
}
|
||||
buildingInProgress = true;
|
||||
currentBuildingModule = resourceName;
|
||||
const proc = child_process.fork(
|
||||
require.resolve('./yarn_cli.js'),
|
||||
['install', '--ignore-scripts', '--cache-folder', path.join(initCwd, 'cache', 'yarn-cache'), '--mutex', 'file:' + path.join(initCwd, 'cache', 'yarn-mutex')],
|
||||
{
|
||||
cwd: path.resolve(GetResourcePath(resourceName)),
|
||||
stdio: 'pipe',
|
||||
});
|
||||
proc.stdout.on('data', (data) => console.log(trimOutput(data)));
|
||||
proc.stderr.on('data', (data) => console.error(trimOutput(data)));
|
||||
proc.on('exit', (code, signal) => {
|
||||
setImmediate(() => {
|
||||
if (code != 0 || signal) {
|
||||
buildingInProgress = false;
|
||||
currentBuildingModule = '';
|
||||
cb(false, 'yarn failed!');
|
||||
return;
|
||||
}
|
||||
|
||||
const resourcePath = GetResourcePath(resourceName);
|
||||
const yarnLock = path.resolve(resourcePath, '.yarn.installed');
|
||||
fs.writeFileSync(yarnLock, '');
|
||||
|
||||
buildingInProgress = false;
|
||||
currentBuildingModule = '';
|
||||
cb(true);
|
||||
});
|
||||
});
|
||||
})();
|
||||
}
|
||||
};
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
RegisterResourceBuildTaskFactory('yarn', () => yarnBuildTask);
|
||||
147392
resources/[cfx-default]/[system]/[builders]/yarn/yarn_cli.js
Normal file
147392
resources/[cfx-default]/[system]/[builders]/yarn/yarn_cli.js
Normal file
File diff suppressed because one or more lines are too long
73
resources/[cfx-default]/[system]/baseevents/deathevents.lua
Normal file
73
resources/[cfx-default]/[system]/baseevents/deathevents.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
Citizen.CreateThread(function()
|
||||
local isDead = false
|
||||
local hasBeenDead = false
|
||||
local diedAt
|
||||
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
local player = PlayerId()
|
||||
|
||||
if NetworkIsPlayerActive(player) then
|
||||
local ped = PlayerPedId()
|
||||
|
||||
if IsPedFatallyInjured(ped) and not isDead then
|
||||
isDead = true
|
||||
if not diedAt then
|
||||
diedAt = GetGameTimer()
|
||||
end
|
||||
|
||||
local killer, killerweapon = NetworkGetEntityKillerOfPlayer(player)
|
||||
local killerentitytype = GetEntityType(killer)
|
||||
local killertype = -1
|
||||
local killerinvehicle = false
|
||||
local killervehiclename = ''
|
||||
local killervehicleseat = 0
|
||||
if killerentitytype == 1 then
|
||||
killertype = GetPedType(killer)
|
||||
if IsPedInAnyVehicle(killer, false) == 1 then
|
||||
killerinvehicle = true
|
||||
killervehiclename = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(killer)))
|
||||
killervehicleseat = GetPedVehicleSeat(killer)
|
||||
else killerinvehicle = false
|
||||
end
|
||||
end
|
||||
|
||||
local killerid = GetPlayerByEntityID(killer)
|
||||
if killer ~= ped and killerid ~= nil and NetworkIsPlayerActive(killerid) then killerid = GetPlayerServerId(killerid)
|
||||
else killerid = -1
|
||||
end
|
||||
|
||||
if killer == ped or killer == -1 then
|
||||
TriggerEvent('baseevents:onPlayerDied', killertype, { table.unpack(GetEntityCoords(ped)) })
|
||||
TriggerServerEvent('baseevents:onPlayerDied', killertype, { table.unpack(GetEntityCoords(ped)) })
|
||||
hasBeenDead = true
|
||||
else
|
||||
TriggerEvent('baseevents:onPlayerKilled', killerid, {killertype=killertype, weaponhash = killerweapon, killerinveh=killerinvehicle, killervehseat=killervehicleseat, killervehname=killervehiclename, killerpos={table.unpack(GetEntityCoords(ped))}})
|
||||
TriggerServerEvent('baseevents:onPlayerKilled', killerid, {killertype=killertype, weaponhash = killerweapon, killerinveh=killerinvehicle, killervehseat=killervehicleseat, killervehname=killervehiclename, killerpos={table.unpack(GetEntityCoords(ped))}})
|
||||
hasBeenDead = true
|
||||
end
|
||||
elseif not IsPedFatallyInjured(ped) then
|
||||
isDead = false
|
||||
diedAt = nil
|
||||
end
|
||||
|
||||
-- check if the player has to respawn in order to trigger an event
|
||||
if not hasBeenDead and diedAt ~= nil and diedAt > 0 then
|
||||
TriggerEvent('baseevents:onPlayerWasted', { table.unpack(GetEntityCoords(ped)) })
|
||||
TriggerServerEvent('baseevents:onPlayerWasted', { table.unpack(GetEntityCoords(ped)) })
|
||||
|
||||
hasBeenDead = true
|
||||
elseif hasBeenDead and diedAt ~= nil and diedAt <= 0 then
|
||||
hasBeenDead = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function GetPlayerByEntityID(id)
|
||||
for i=0,32 do
|
||||
if(NetworkIsPlayerActive(i) and GetPlayerPed(i) == id) then return i end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
14
resources/[cfx-default]/[system]/baseevents/fxmanifest.lua
Normal file
14
resources/[cfx-default]/[system]/baseevents/fxmanifest.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Adds basic events for developers to use in their scripts. Some third party resources may depend on this resource.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'deathevents.lua'
|
||||
client_script 'vehiclechecker.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'gta5'
|
||||
19
resources/[cfx-default]/[system]/baseevents/server.lua
Normal file
19
resources/[cfx-default]/[system]/baseevents/server.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
RegisterServerEvent('baseevents:onPlayerDied')
|
||||
RegisterServerEvent('baseevents:onPlayerKilled')
|
||||
RegisterServerEvent('baseevents:onPlayerWasted')
|
||||
RegisterServerEvent('baseevents:enteringVehicle')
|
||||
RegisterServerEvent('baseevents:enteringAborted')
|
||||
RegisterServerEvent('baseevents:enteredVehicle')
|
||||
RegisterServerEvent('baseevents:leftVehicle')
|
||||
|
||||
AddEventHandler('baseevents:onPlayerKilled', function(killedBy, data)
|
||||
local victim = source
|
||||
|
||||
RconLog({msgType = 'playerKilled', victim = victim, attacker = killedBy, data = data})
|
||||
end)
|
||||
|
||||
AddEventHandler('baseevents:onPlayerDied', function(killedBy, pos)
|
||||
local victim = source
|
||||
|
||||
RconLog({msgType = 'playerDied', victim = victim, attackerType = killedBy, pos = pos})
|
||||
end)
|
||||
@@ -0,0 +1,57 @@
|
||||
local isInVehicle = false
|
||||
local isEnteringVehicle = false
|
||||
local currentVehicle = 0
|
||||
local currentSeat = 0
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
local ped = PlayerPedId()
|
||||
|
||||
if not isInVehicle and not IsPlayerDead(PlayerId()) then
|
||||
if DoesEntityExist(GetVehiclePedIsTryingToEnter(ped)) and not isEnteringVehicle then
|
||||
-- trying to enter a vehicle!
|
||||
local vehicle = GetVehiclePedIsTryingToEnter(ped)
|
||||
local seat = GetSeatPedIsTryingToEnter(ped)
|
||||
local netId = VehToNet(vehicle)
|
||||
isEnteringVehicle = true
|
||||
TriggerServerEvent('baseevents:enteringVehicle', vehicle, seat, GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)), netId)
|
||||
elseif not DoesEntityExist(GetVehiclePedIsTryingToEnter(ped)) and not IsPedInAnyVehicle(ped, true) and isEnteringVehicle then
|
||||
-- vehicle entering aborted
|
||||
TriggerServerEvent('baseevents:enteringAborted')
|
||||
isEnteringVehicle = false
|
||||
elseif IsPedInAnyVehicle(ped, false) then
|
||||
-- suddenly appeared in a vehicle, possible teleport
|
||||
isEnteringVehicle = false
|
||||
isInVehicle = true
|
||||
currentVehicle = GetVehiclePedIsUsing(ped)
|
||||
currentSeat = GetPedVehicleSeat(ped)
|
||||
local model = GetEntityModel(currentVehicle)
|
||||
local name = GetDisplayNameFromVehicleModel()
|
||||
local netId = VehToNet(currentVehicle)
|
||||
TriggerServerEvent('baseevents:enteredVehicle', currentVehicle, currentSeat, GetDisplayNameFromVehicleModel(GetEntityModel(currentVehicle)), netId)
|
||||
end
|
||||
elseif isInVehicle then
|
||||
if not IsPedInAnyVehicle(ped, false) or IsPlayerDead(PlayerId()) then
|
||||
-- bye, vehicle
|
||||
local model = GetEntityModel(currentVehicle)
|
||||
local name = GetDisplayNameFromVehicleModel()
|
||||
local netId = VehToNet(currentVehicle)
|
||||
TriggerServerEvent('baseevents:leftVehicle', currentVehicle, currentSeat, GetDisplayNameFromVehicleModel(GetEntityModel(currentVehicle)), netId)
|
||||
isInVehicle = false
|
||||
currentVehicle = 0
|
||||
currentSeat = 0
|
||||
end
|
||||
end
|
||||
Citizen.Wait(50)
|
||||
end
|
||||
end)
|
||||
|
||||
function GetPedVehicleSeat(ped)
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
for i=-2,GetVehicleMaxNumberOfPassengers(vehicle) do
|
||||
if(GetPedInVehicleSeat(vehicle, i) == ped) then return i end
|
||||
end
|
||||
return -2
|
||||
end
|
||||
11
resources/[cfx-default]/[system]/hardcap/client.lua
Normal file
11
resources/[cfx-default]/[system]/hardcap/client.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
if NetworkIsSessionStarted() then
|
||||
TriggerServerEvent('hardcap:playerActivated')
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
14
resources/[cfx-default]/[system]/hardcap/fxmanifest.lua
Normal file
14
resources/[cfx-default]/[system]/hardcap/fxmanifest.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Limits the number of players to the amount set by sv_maxclients in your server.cfg.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'gta5', 'rdr3' }
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
31
resources/[cfx-default]/[system]/hardcap/server.lua
Normal file
31
resources/[cfx-default]/[system]/hardcap/server.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local playerCount = 0
|
||||
local list = {}
|
||||
|
||||
RegisterServerEvent('hardcap:playerActivated')
|
||||
|
||||
AddEventHandler('hardcap:playerActivated', function()
|
||||
if not list[source] then
|
||||
playerCount = playerCount + 1
|
||||
list[source] = true
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
if list[source] then
|
||||
playerCount = playerCount - 1
|
||||
list[source] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerConnecting', function(name, setReason)
|
||||
local cv = GetConvarInt('sv_maxclients', 32)
|
||||
|
||||
print('Connecting: ' .. name .. '^7')
|
||||
|
||||
if playerCount >= cv then
|
||||
print('Full. :(')
|
||||
|
||||
setReason('This server is full (past ' .. tostring(cv) .. ' players).')
|
||||
CancelEvent()
|
||||
end
|
||||
end)
|
||||
15
resources/[cfx-default]/[system]/rconlog/fxmanifest.lua
Normal file
15
resources/[cfx-default]/[system]/rconlog/fxmanifest.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Handles old-style server player management commands.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'rconlog_client.lua'
|
||||
server_script 'rconlog_server.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'gta5', 'rdr3' }
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
25
resources/[cfx-default]/[system]/rconlog/rconlog_client.lua
Normal file
25
resources/[cfx-default]/[system]/rconlog/rconlog_client.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
RegisterNetEvent('rlUpdateNames')
|
||||
|
||||
AddEventHandler('rlUpdateNames', function()
|
||||
local names = {}
|
||||
|
||||
for i = 0, 31 do
|
||||
if NetworkIsPlayerActive(i) then
|
||||
names[GetPlayerServerId(i)] = { id = i, name = GetPlayerName(i) }
|
||||
end
|
||||
end
|
||||
|
||||
TriggerServerEvent('rlUpdateNamesResult', names)
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
if NetworkIsSessionStarted() then
|
||||
TriggerServerEvent('rlPlayerActivated')
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
84
resources/[cfx-default]/[system]/rconlog/rconlog_server.lua
Normal file
84
resources/[cfx-default]/[system]/rconlog/rconlog_server.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
RconLog({ msgType = 'serverStart', hostname = 'lovely', maxplayers = 32 })
|
||||
|
||||
RegisterServerEvent('rlPlayerActivated')
|
||||
|
||||
local names = {}
|
||||
|
||||
AddEventHandler('rlPlayerActivated', function()
|
||||
RconLog({ msgType = 'playerActivated', netID = source, name = GetPlayerName(source), guid = GetPlayerIdentifiers(source)[1], ip = GetPlayerEP(source) })
|
||||
|
||||
names[source] = { name = GetPlayerName(source), id = source }
|
||||
|
||||
if GetHostId() then
|
||||
TriggerClientEvent('rlUpdateNames', GetHostId())
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('rlUpdateNamesResult')
|
||||
|
||||
AddEventHandler('rlUpdateNamesResult', function(res)
|
||||
if source ~= tonumber(GetHostId()) then
|
||||
print('bad guy')
|
||||
return
|
||||
end
|
||||
|
||||
for id, data in pairs(res) do
|
||||
if data then
|
||||
if data.name then
|
||||
if not names[id] then
|
||||
names[id] = data
|
||||
end
|
||||
|
||||
if names[id].name ~= data.name or names[id].id ~= data.id then
|
||||
names[id] = data
|
||||
|
||||
RconLog({ msgType = 'playerRenamed', netID = id, name = data.name })
|
||||
end
|
||||
end
|
||||
else
|
||||
names[id] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
RconLog({ msgType = 'playerDropped', netID = source, name = GetPlayerName(source) })
|
||||
|
||||
names[source] = nil
|
||||
end)
|
||||
|
||||
AddEventHandler('chatMessage', function(netID, name, message)
|
||||
RconLog({ msgType = 'chatMessage', netID = netID, name = name, message = message, guid = GetPlayerIdentifiers(netID)[1] })
|
||||
end)
|
||||
|
||||
-- NOTE: DO NOT USE THIS METHOD FOR HANDLING COMMANDS
|
||||
-- This resource has not been updated to use newer methods such as RegisterCommand.
|
||||
AddEventHandler('rconCommand', function(commandName, args)
|
||||
if commandName == 'status' then
|
||||
for netid, data in pairs(names) do
|
||||
local guid = GetPlayerIdentifiers(netid)
|
||||
|
||||
if guid and guid[1] and data then
|
||||
local ping = GetPlayerPing(netid)
|
||||
|
||||
RconPrint(netid .. ' ' .. guid[1] .. ' ' .. data.name .. ' ' .. GetPlayerEP(netid) .. ' ' .. ping .. "\n")
|
||||
end
|
||||
end
|
||||
|
||||
CancelEvent()
|
||||
elseif commandName:lower() == 'clientkick' then
|
||||
local playerId = table.remove(args, 1)
|
||||
local msg = table.concat(args, ' ')
|
||||
|
||||
DropPlayer(playerId, msg)
|
||||
|
||||
CancelEvent()
|
||||
elseif commandName:lower() == 'tempbanclient' then
|
||||
local playerId = table.remove(args, 1)
|
||||
local msg = table.concat(args, ' ')
|
||||
|
||||
TempBanPlayer(playerId, msg)
|
||||
|
||||
CancelEvent()
|
||||
end
|
||||
end)
|
||||
1
resources/[cfx-default]/[system]/runcode/.gitignore
vendored
Normal file
1
resources/[cfx-default]/[system]/runcode/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
data.json
|
||||
24
resources/[cfx-default]/[system]/runcode/fxmanifest.lua
Normal file
24
resources/[cfx-default]/[system]/runcode/fxmanifest.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Allows server owners to execute arbitrary server-side or client-side JavaScript/Lua code. *Consider only using this on development servers.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
game 'common'
|
||||
fx_version 'bodacious'
|
||||
|
||||
client_script 'runcode_cl.lua'
|
||||
server_script 'runcode_sv.lua'
|
||||
server_script 'runcode_web.lua'
|
||||
|
||||
shared_script 'runcode_shared.lua'
|
||||
shared_script 'runcode.js'
|
||||
|
||||
client_script 'runcode_ui.lua'
|
||||
|
||||
ui_page 'web/nui.html'
|
||||
files {
|
||||
'web/nui.html'
|
||||
}
|
||||
11
resources/[cfx-default]/[system]/runcode/runcode.js
Normal file
11
resources/[cfx-default]/[system]/runcode/runcode.js
Normal file
@@ -0,0 +1,11 @@
|
||||
exports('runJS', (snippet) => {
|
||||
if (IsDuplicityVersion() && GetInvokingResource() !== GetCurrentResourceName()) {
|
||||
return [ 'Invalid caller.', false ];
|
||||
}
|
||||
|
||||
try {
|
||||
return [ new Function(snippet)(), false ];
|
||||
} catch (e) {
|
||||
return [ false, e.toString() ];
|
||||
}
|
||||
});
|
||||
15
resources/[cfx-default]/[system]/runcode/runcode_cl.lua
Normal file
15
resources/[cfx-default]/[system]/runcode/runcode_cl.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
RegisterNetEvent('runcode:gotSnippet')
|
||||
|
||||
AddEventHandler('runcode:gotSnippet', function(id, lang, code)
|
||||
local res, err = RunCode(lang, code)
|
||||
|
||||
if not err then
|
||||
if type(res) == 'vector3' then
|
||||
res = json.encode({ table.unpack(res) })
|
||||
elseif type(res) == 'table' then
|
||||
res = json.encode(res)
|
||||
end
|
||||
end
|
||||
|
||||
TriggerServerEvent('runcode:gotResult', id, res, err)
|
||||
end)
|
||||
32
resources/[cfx-default]/[system]/runcode/runcode_shared.lua
Normal file
32
resources/[cfx-default]/[system]/runcode/runcode_shared.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local runners = {}
|
||||
|
||||
function runners.lua(arg)
|
||||
local code, err = load('return ' .. arg, '@runcode')
|
||||
|
||||
-- if failed, try without return
|
||||
if err then
|
||||
code, err = load(arg, '@runcode')
|
||||
end
|
||||
|
||||
if err then
|
||||
print(err)
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local status, result = pcall(code)
|
||||
print(result)
|
||||
|
||||
if status then
|
||||
return result
|
||||
end
|
||||
|
||||
return nil, result
|
||||
end
|
||||
|
||||
function runners.js(arg)
|
||||
return table.unpack(exports[GetCurrentResourceName()]:runJS(arg))
|
||||
end
|
||||
|
||||
function RunCode(lang, str)
|
||||
return runners[lang](str)
|
||||
end
|
||||
42
resources/[cfx-default]/[system]/runcode/runcode_sv.lua
Normal file
42
resources/[cfx-default]/[system]/runcode/runcode_sv.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
function GetPrivs(source)
|
||||
return {
|
||||
canServer = IsPlayerAceAllowed(source, 'command.run'),
|
||||
canClient = IsPlayerAceAllowed(source, 'command.crun'),
|
||||
canSelf = IsPlayerAceAllowed(source, 'runcode.self'),
|
||||
}
|
||||
end
|
||||
|
||||
RegisterCommand('run', function(source, args, rawCommand)
|
||||
local res, err = RunCode('lua', rawCommand:sub(4))
|
||||
end, true)
|
||||
|
||||
RegisterCommand('crun', function(source, args, rawCommand)
|
||||
if not source then
|
||||
return
|
||||
end
|
||||
|
||||
TriggerClientEvent('runcode:gotSnippet', source, -1, 'lua', rawCommand:sub(5))
|
||||
end, true)
|
||||
|
||||
RegisterCommand('runcode', function(source, args, rawCommand)
|
||||
if not source then
|
||||
return
|
||||
end
|
||||
|
||||
local df = LoadResourceFile(GetCurrentResourceName(), 'data.json')
|
||||
local saveData = {}
|
||||
|
||||
if df then
|
||||
saveData = json.decode(df)
|
||||
end
|
||||
|
||||
local p = GetPrivs(source)
|
||||
|
||||
if not p.canServer and not p.canClient and not p.canSelf then
|
||||
return
|
||||
end
|
||||
|
||||
p.saveData = saveData
|
||||
|
||||
TriggerClientEvent('runcode:openUi', source, p)
|
||||
end, true)
|
||||
66
resources/[cfx-default]/[system]/runcode/runcode_ui.lua
Normal file
66
resources/[cfx-default]/[system]/runcode/runcode_ui.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
local openData
|
||||
|
||||
RegisterNetEvent('runcode:openUi')
|
||||
|
||||
AddEventHandler('runcode:openUi', function(options)
|
||||
openData = {
|
||||
type = 'open',
|
||||
options = options,
|
||||
url = 'http://' .. GetCurrentServerEndpoint() .. '/' .. GetCurrentResourceName() .. '/',
|
||||
res = GetCurrentResourceName()
|
||||
}
|
||||
|
||||
SendNuiMessage(json.encode(openData))
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getOpenData', function(args, cb)
|
||||
cb(openData)
|
||||
end)
|
||||
|
||||
RegisterNUICallback('doOk', function(args, cb)
|
||||
SendNuiMessage(json.encode({
|
||||
type = 'ok'
|
||||
}))
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('doClose', function(args, cb)
|
||||
SendNuiMessage(json.encode({
|
||||
type = 'close'
|
||||
}))
|
||||
|
||||
SetNuiFocus(false, false)
|
||||
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
local rcCbs = {}
|
||||
local id = 1
|
||||
|
||||
RegisterNUICallback('runCodeInBand', function(args, cb)
|
||||
id = id + 1
|
||||
|
||||
rcCbs[id] = cb
|
||||
|
||||
TriggerServerEvent('runcode:runInBand', id, args)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('runcode:inBandResult')
|
||||
|
||||
AddEventHandler('runcode:inBandResult', function(id, result)
|
||||
if rcCbs[id] then
|
||||
local cb = rcCbs[id]
|
||||
rcCbs[id] = nil
|
||||
|
||||
cb(result)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if resourceName == GetCurrentResourceName() then
|
||||
SetNuiFocus(false, false)
|
||||
end
|
||||
end)
|
||||
192
resources/[cfx-default]/[system]/runcode/runcode_web.lua
Normal file
192
resources/[cfx-default]/[system]/runcode/runcode_web.lua
Normal file
@@ -0,0 +1,192 @@
|
||||
local cachedFiles = {}
|
||||
|
||||
local function sendFile(res, fileName)
|
||||
if cachedFiles[fileName] then
|
||||
res.send(cachedFiles[fileName])
|
||||
return
|
||||
end
|
||||
|
||||
local fileData = LoadResourceFile(GetCurrentResourceName(), 'web/' .. fileName)
|
||||
|
||||
if not fileData then
|
||||
res.writeHead(404)
|
||||
res.send('Not found.')
|
||||
return
|
||||
end
|
||||
|
||||
cachedFiles[fileName] = fileData
|
||||
res.send(fileData)
|
||||
end
|
||||
|
||||
local codeId = 1
|
||||
local codes = {}
|
||||
|
||||
local attempts = 0
|
||||
local lastAttempt
|
||||
|
||||
local function handleRunCode(data, res)
|
||||
if not data.lang then
|
||||
data.lang = 'lua'
|
||||
end
|
||||
|
||||
if not data.client or data.client == '' then
|
||||
CreateThread(function()
|
||||
local result, err = RunCode(data.lang, data.code)
|
||||
|
||||
res.send(json.encode({
|
||||
result = result,
|
||||
error = err
|
||||
}))
|
||||
end)
|
||||
else
|
||||
codes[codeId] = {
|
||||
timeout = GetGameTimer() + 1000,
|
||||
res = res
|
||||
}
|
||||
|
||||
TriggerClientEvent('runcode:gotSnippet', tonumber(data.client), codeId, data.lang, data.code)
|
||||
|
||||
codeId = codeId + 1
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('runcode:runInBand')
|
||||
|
||||
AddEventHandler('runcode:runInBand', function(id, data)
|
||||
local s = source
|
||||
local privs = GetPrivs(s)
|
||||
|
||||
local res = {
|
||||
send = function(str)
|
||||
TriggerClientEvent('runcode:inBandResult', s, id, str)
|
||||
end
|
||||
}
|
||||
|
||||
if (not data.client or data.client == '') and not privs.canServer then
|
||||
res.send(json.encode({ error = 'Insufficient permissions.'}))
|
||||
return
|
||||
end
|
||||
|
||||
if (data.client and data.client ~= '') and not privs.canClient then
|
||||
if privs.canSelf then
|
||||
data.client = s
|
||||
else
|
||||
res.send(json.encode({ error = 'Insufficient permissions.'}))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
SaveResourceFile(GetCurrentResourceName(), 'data.json', json.encode({
|
||||
lastSnippet = data.code,
|
||||
lastLang = data.lang or 'lua'
|
||||
}), -1)
|
||||
|
||||
handleRunCode(data, res)
|
||||
end)
|
||||
|
||||
local function handlePost(req, res)
|
||||
req.setDataHandler(function(body)
|
||||
local data = json.decode(body)
|
||||
|
||||
if not data or not data.password or not data.code then
|
||||
res.send(json.encode({ error = 'Bad request.'}))
|
||||
return
|
||||
end
|
||||
|
||||
if GetConvar('rcon_password', '') == '' then
|
||||
res.send(json.encode({ error = 'The server has an empty rcon_password.'}))
|
||||
return
|
||||
end
|
||||
|
||||
if attempts > 5 or data.password ~= GetConvar('rcon_password', '') then
|
||||
attempts = attempts + 1
|
||||
lastAttempt = GetGameTimer()
|
||||
|
||||
res.send(json.encode({ error = 'Bad password.'}))
|
||||
return
|
||||
end
|
||||
|
||||
handleRunCode(data, res)
|
||||
end)
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1000)
|
||||
|
||||
if attempts > 0 and (GetGameTimer() - lastAttempt) > 5000 then
|
||||
attempts = 0
|
||||
lastAttempt = 0
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function returnCode(id, res, err)
|
||||
if not codes[id] then
|
||||
return
|
||||
end
|
||||
|
||||
local code = codes[id]
|
||||
codes[id] = nil
|
||||
|
||||
local gotFrom
|
||||
|
||||
if source then
|
||||
gotFrom = GetPlayerName(source) .. ' [' .. tostring(source) .. ']'
|
||||
end
|
||||
|
||||
code.res.send(json.encode({
|
||||
result = res,
|
||||
error = err,
|
||||
from = gotFrom
|
||||
}))
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(100)
|
||||
|
||||
for k, v in ipairs(codes) do
|
||||
if GetGameTimer() > v.timeout then
|
||||
source = nil
|
||||
returnCode(k, '', 'Timed out waiting on the target client.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('runcode:gotResult')
|
||||
AddEventHandler('runcode:gotResult', returnCode)
|
||||
|
||||
SetHttpHandler(function(req, res)
|
||||
local path = req.path
|
||||
|
||||
if req.method == 'POST' then
|
||||
return handlePost(req, res)
|
||||
end
|
||||
|
||||
-- client shortcuts
|
||||
if req.path == '/clients' then
|
||||
local clientList = {}
|
||||
|
||||
for _, id in ipairs(GetPlayers()) do
|
||||
table.insert(clientList, { GetPlayerName(id), id })
|
||||
end
|
||||
|
||||
res.send(json.encode({
|
||||
clients = clientList
|
||||
}))
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- should this be the index?
|
||||
if req.path == '/' then
|
||||
path = 'index.html'
|
||||
end
|
||||
|
||||
-- remove any '..' from the path
|
||||
path = path:gsub("%.%.", "")
|
||||
|
||||
return sendFile(res, path)
|
||||
end)
|
||||
486
resources/[cfx-default]/[system]/runcode/web/index.html
Normal file
486
resources/[cfx-default]/[system]/runcode/web/index.html
Normal file
@@ -0,0 +1,486 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>fivem runcode</title>
|
||||
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulmaswatch/0.7.2/cyborg/bulmaswatch.min.css">
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
z-index: inherit;
|
||||
}
|
||||
|
||||
html.in-nui {
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
|
||||
margin-top: 5vh;
|
||||
margin-left: 7.5vw;
|
||||
margin-right: 7.5vw;
|
||||
margin-bottom: 5vh;
|
||||
|
||||
height: calc(100% - 10vh);
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
||||
html.in-nui body > div.bg {
|
||||
background-color: rgba(0, 0, 0, 1);
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
z-index: -999;
|
||||
|
||||
box-shadow: 0 22px 70px 4px rgba(0, 0, 0, 0.56);
|
||||
}
|
||||
|
||||
span.nui-edition {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html.in-nui span.nui-edition {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html.in-nui #close {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#result {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="bg">
|
||||
|
||||
</div>
|
||||
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/runcode">
|
||||
<strong>runcode</strong> <span class="nui-edition"> in-game</span>
|
||||
</a>
|
||||
|
||||
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarMain">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="navbarMain" class="navbar-menu">
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<div class="field" id="cl-field">
|
||||
<div class="control has-icons-left">
|
||||
<div class="select">
|
||||
<select id="cl-select">
|
||||
</select>
|
||||
</div>
|
||||
<div class="icon is-small is-left">
|
||||
<i class="fas fa-user"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar-item">
|
||||
<div class="field has-addons" id="lang-toggle">
|
||||
<p class="control">
|
||||
<button class="button" id="lua-button">
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-moon"></i>
|
||||
</span>
|
||||
<span>Lua</span>
|
||||
</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button class="button" id="js-button">
|
||||
<span class="icon is-small">
|
||||
<i class="fab fa-js"></i>
|
||||
</span>
|
||||
<span>JS</span>
|
||||
</button>
|
||||
</p>
|
||||
<!-- TODO pending add-on resource that'll contain webpack'd compiler
|
||||
<p class="control">
|
||||
<button class="button" id="ts-button">
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-code"></i>
|
||||
</span>
|
||||
<span>TS</span>
|
||||
</button>
|
||||
</p>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar-item">
|
||||
<div class="field has-addons" id="cl-sv-toggle">
|
||||
<p class="control">
|
||||
<button class="button" id="cl-button">
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-user-friends"></i>
|
||||
</span>
|
||||
<span>Client</span>
|
||||
</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button class="button" id="sv-button">
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-server"></i>
|
||||
</span>
|
||||
<span>Server</span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar-item" id="close">
|
||||
<button class="button is-danger">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div id="code-container" style="width:100%;height:60vh;border:1px solid grey"></div><br>
|
||||
<div class="field" id="passwordField">
|
||||
<p class="control has-icons-left">
|
||||
<input class="input" type="password" id="password" placeholder="RCon Password">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-lock"></i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<button class="button is-primary" id="run">Run</button>
|
||||
<div id="result">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
to use a local deployment, uncomment; do note currently the server isn't optimized to serve >1MB files
|
||||
<script src="monaco-editor/vs/loader.js"></script>
|
||||
-->
|
||||
|
||||
<script src="https://unpkg.com/monaco-editor@0.18.1/min/vs/loader.js"></script>
|
||||
|
||||
<script>
|
||||
function fetchClients() {
|
||||
fetch('/runcode/clients').then(res => res.json()).then(res => {
|
||||
const el = document.querySelector('#cl-select');
|
||||
|
||||
const clients = res.clients;
|
||||
const realClients = [['All', '-1'], ...clients];
|
||||
|
||||
const createdClients = new Set([...el.querySelectorAll('option').entries()].map(([i, el]) => el.value));
|
||||
const existentClients = new Set(realClients.map(([ name, id ]) => id));
|
||||
|
||||
const toRemove = [...createdClients].filter(a => !existentClients.has(a));
|
||||
|
||||
for (const [name, id] of realClients) {
|
||||
const ex = el.querySelector(`option[value="${id}"]`);
|
||||
|
||||
if (!ex) {
|
||||
const l = document.createElement('option');
|
||||
l.setAttribute('value', id);
|
||||
l.appendChild(document.createTextNode(name));
|
||||
|
||||
el.appendChild(l);
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of toRemove) {
|
||||
const l = el.querySelector(`option[value="${id}"]`);
|
||||
|
||||
if (l) {
|
||||
el.removeChild(l);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let useClient = false;
|
||||
let editServerCb = null;
|
||||
|
||||
[['#cl-button', true], ['#sv-button', false]].forEach(([ selector, isClient ]) => {
|
||||
const eh = () => {
|
||||
if (isClient) {
|
||||
document.querySelector('#cl-select').disabled = false;
|
||||
useClient = true;
|
||||
} else {
|
||||
document.querySelector('#cl-select').disabled = true;
|
||||
useClient = false;
|
||||
}
|
||||
|
||||
document.querySelectorAll('#cl-sv-toggle button').forEach(el => {
|
||||
el.classList.remove('is-selected', 'is-info');
|
||||
});
|
||||
|
||||
const tgt = document.querySelector(selector);
|
||||
|
||||
tgt.classList.add('is-selected', 'is-info');
|
||||
|
||||
if (editServerCb) {
|
||||
editServerCb();
|
||||
}
|
||||
};
|
||||
|
||||
// default to not-client
|
||||
if (!isClient) {
|
||||
eh();
|
||||
}
|
||||
|
||||
document.querySelector(selector).addEventListener('click', ev => {
|
||||
eh();
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
let lang = 'lua';
|
||||
let editLangCb = null;
|
||||
let initCb = null;
|
||||
|
||||
function getLangCode(lang) {
|
||||
switch (lang) {
|
||||
case 'js':
|
||||
return 'javascript';
|
||||
case 'ts':
|
||||
return 'typescript';
|
||||
}
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
||||
[['#lua-button', 'lua'], ['#js-button', 'js']/*, ['#ts-button', 'ts']*/].forEach(([ selector, langOpt ]) => {
|
||||
const eh = () => {
|
||||
lang = langOpt;
|
||||
|
||||
document.querySelectorAll('#lang-toggle button').forEach(el => {
|
||||
el.classList.remove('is-selected', 'is-info');
|
||||
});
|
||||
|
||||
const tgt = document.querySelector(selector);
|
||||
|
||||
tgt.classList.add('is-selected', 'is-info');
|
||||
|
||||
if (editLangCb) {
|
||||
editLangCb();
|
||||
}
|
||||
};
|
||||
|
||||
// default to not-client
|
||||
if (langOpt === 'lua') {
|
||||
eh();
|
||||
}
|
||||
|
||||
document.querySelector(selector).addEventListener('click', ev => {
|
||||
eh();
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
setInterval(() => fetchClients(), 1000);
|
||||
|
||||
const inNui = (!!window.invokeNative);
|
||||
let openData = {};
|
||||
|
||||
if (inNui) {
|
||||
document.querySelector('#passwordField').style.display = 'none';
|
||||
document.querySelector('html').classList.add('in-nui');
|
||||
|
||||
fetch(`http://${window.parent.GetParentResourceName()}/getOpenData`, {
|
||||
method: 'POST',
|
||||
body: '{}'
|
||||
}).then(a => a.json())
|
||||
.then(a => {
|
||||
openData = a;
|
||||
|
||||
if (!openData.options.canServer) {
|
||||
document.querySelector('#cl-sv-toggle').style.display = 'none';
|
||||
|
||||
const trigger = document.createEvent('HTMLEvents');
|
||||
trigger.initEvent('click', true, true);
|
||||
|
||||
document.querySelector('#cl-button').dispatchEvent(trigger);
|
||||
} else if (!openData.options.canClient && !openData.options.canSelf) {
|
||||
document.querySelector('#cl-sv-toggle').style.display = 'none';
|
||||
document.querySelector('#cl-field').style.display = 'none';
|
||||
|
||||
const trigger = document.createEvent('HTMLEvents');
|
||||
trigger.initEvent('click', true, true);
|
||||
|
||||
document.querySelector('#sv-button').dispatchEvent(trigger);
|
||||
}
|
||||
|
||||
if (!openData.options.canClient && openData.options.canSelf) {
|
||||
document.querySelector('#cl-field').style.display = 'none';
|
||||
}
|
||||
|
||||
if (openData.options.saveData) {
|
||||
const cb = () => {
|
||||
if (initCb) {
|
||||
initCb({
|
||||
lastLang: openData.options.saveData.lastLang,
|
||||
lastSnippet: openData.options.saveData.lastSnippet
|
||||
});
|
||||
} else {
|
||||
setTimeout(cb, 50);
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(cb, 50);
|
||||
}
|
||||
|
||||
fetch(`https://${window.parent.GetParentResourceName()}/doOk`, {
|
||||
method: 'POST',
|
||||
body: '{}'
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#close button').addEventListener('click', ev => {
|
||||
fetch(`https://${window.parent.GetParentResourceName()}/doClose`, {
|
||||
method: 'POST',
|
||||
body: '{}'
|
||||
});
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
const defFiles = ['index.d.ts'];
|
||||
const defFilesServer = [...defFiles, 'natives_server.d.ts'];
|
||||
const defFilesClient = [...defFiles, 'natives_universal.d.ts'];
|
||||
|
||||
const prefix = 'https://unpkg.com/@citizenfx/{}/';
|
||||
const prefixClient = prefix.replace('{}', 'client');
|
||||
const prefixServer = prefix.replace('{}', 'server');
|
||||
|
||||
require.config({ paths: { 'vs': 'https://unpkg.com/monaco-editor@0.18.1/min/vs' }});
|
||||
require(['vs/editor/editor.main'], function() {
|
||||
const editor = monaco.editor.create(document.getElementById('code-container'), {
|
||||
value: 'return 42',
|
||||
language: 'lua'
|
||||
});
|
||||
|
||||
monaco.editor.setTheme('vs-dark');
|
||||
|
||||
let finalizers = [];
|
||||
|
||||
const updateScript = (client, lang) => {
|
||||
finalizers.forEach(a => a());
|
||||
finalizers = [];
|
||||
|
||||
if (lang === 'js' || lang === 'ts') {
|
||||
const defaults = (lang === 'js') ? monaco.languages.typescript.javascriptDefaults :
|
||||
monaco.languages.typescript.typescriptDefaults;
|
||||
|
||||
defaults.setCompilerOptions({
|
||||
noLib: true,
|
||||
allowNonTsExtensions: true
|
||||
});
|
||||
|
||||
for (const file of (client ? defFilesClient : defFilesServer)) {
|
||||
const prefix = (client ? prefixClient : prefixServer);
|
||||
|
||||
fetch(`${prefix}${file}`)
|
||||
.then(a => a.text())
|
||||
.then(a => {
|
||||
const l = defaults.addExtraLib(a, file);
|
||||
|
||||
finalizers.push(() => l.dispose());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editLangCb = () => {
|
||||
monaco.editor.setModelLanguage(editor.getModel(), getLangCode(lang));
|
||||
|
||||
updateScript(useClient, lang);
|
||||
};
|
||||
|
||||
editServerCb = () => {
|
||||
updateScript(useClient, lang);
|
||||
};
|
||||
|
||||
initCb = (data) => {
|
||||
if (data.lastLang) {
|
||||
const trigger = document.createEvent('HTMLEvents');
|
||||
trigger.initEvent('click', true, true);
|
||||
document.querySelector(`#${data.lastLang}-button`).dispatchEvent(trigger);
|
||||
}
|
||||
|
||||
if (data.lastSnippet) {
|
||||
editor.getModel().setValue(data.lastSnippet);
|
||||
}
|
||||
};
|
||||
|
||||
document.querySelector('#run').addEventListener('click', e => {
|
||||
const text = editor.getValue();
|
||||
|
||||
fetch((!inNui) ? '/runcode/' : `https://${openData.res}/runCodeInBand`, {
|
||||
method: 'post',
|
||||
body: JSON.stringify({
|
||||
password: document.querySelector('#password').value,
|
||||
client: (useClient) ? document.querySelector('#cl-select').value : '',
|
||||
code: text,
|
||||
lang: lang
|
||||
})
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (inNui) {
|
||||
res = JSON.parse(res); // double packing for sad msgpack-to-json
|
||||
}
|
||||
|
||||
const resultElement = document.querySelector('#result');
|
||||
|
||||
if (res.error) {
|
||||
resultElement.classList.remove('notification', 'is-success');
|
||||
resultElement.classList.add('notification', 'is-danger');
|
||||
} else {
|
||||
resultElement.classList.remove('notification', 'is-danger');
|
||||
resultElement.classList.add('notification', 'is-success');
|
||||
}
|
||||
|
||||
resultElement.innerHTML = res.error || res.result;
|
||||
|
||||
if (res.from) {
|
||||
resultElement.innerHTML += ' (from ' + res.from + ')';
|
||||
}
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
60
resources/[cfx-default]/[system]/runcode/web/nui.html
Normal file
60
resources/[cfx-default]/[system]/runcode/web/nui.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>runcode nui</title>
|
||||
|
||||
<style type="text/css">
|
||||
html {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: transparent;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="holder">
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
let openData = null;
|
||||
|
||||
window.addEventListener('message', ev => {
|
||||
switch (ev.data.type) {
|
||||
case 'open':
|
||||
const frame = document.createElement('iframe');
|
||||
|
||||
frame.name = 'rc';
|
||||
frame.allow = 'microphone *;';
|
||||
frame.src = ev.data.url;
|
||||
frame.style.visibility = 'hidden';
|
||||
|
||||
openData = ev.data;
|
||||
openData.frame = frame;
|
||||
|
||||
document.querySelector('#holder').appendChild(frame);
|
||||
break;
|
||||
case 'ok':
|
||||
openData.frame.style.visibility = 'visible';
|
||||
break;
|
||||
case 'close':
|
||||
document.querySelector('#holder').removeChild(openData.frame);
|
||||
|
||||
openData = null;
|
||||
break;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
2
resources/[cfx-default]/[system]/sessionmanager-rdr3/.gitignore
vendored
Normal file
2
resources/[cfx-default]/[system]/sessionmanager-rdr3/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.yarn.installed
|
||||
@@ -0,0 +1,17 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Handles Social Club conductor session API for RedM. Do not disable.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
fx_version 'adamant'
|
||||
game 'rdr3'
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
|
||||
dependencies {
|
||||
'yarn'
|
||||
}
|
||||
|
||||
server_script 'sm_server.js'
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@citizenfx/protobufjs": "6.8.8"
|
||||
}
|
||||
}
|
||||
192
resources/[cfx-default]/[system]/sessionmanager-rdr3/rline.proto
Normal file
192
resources/[cfx-default]/[system]/sessionmanager-rdr3/rline.proto
Normal file
@@ -0,0 +1,192 @@
|
||||
syntax = "proto3";
|
||||
package rline;
|
||||
|
||||
message RpcErrorData {
|
||||
string ErrorCodeString = 1;
|
||||
int32 ErrorCode = 2;
|
||||
string DomainString = 3;
|
||||
int32 DomainCode = 4;
|
||||
bytes DataEx = 5;
|
||||
};
|
||||
|
||||
message RpcError {
|
||||
int32 ErrorCode = 1;
|
||||
string ErrorMessage = 2;
|
||||
RpcErrorData Data = 3;
|
||||
};
|
||||
|
||||
message RpcHeader {
|
||||
string RequestId = 1;
|
||||
string MethodName = 2;
|
||||
RpcError Error = 3;
|
||||
string srcTid = 4;
|
||||
};
|
||||
|
||||
message RpcMessage {
|
||||
RpcHeader Header = 1;
|
||||
bytes Content = 2;
|
||||
};
|
||||
|
||||
message RpcResponseContainer {
|
||||
bytes Content = 1;
|
||||
};
|
||||
|
||||
message RpcResponseMessage {
|
||||
RpcHeader Header = 1;
|
||||
RpcResponseContainer Container = 2;
|
||||
};
|
||||
|
||||
message TokenStuff {
|
||||
string tkn = 1;
|
||||
};
|
||||
|
||||
message InitSessionResponse {
|
||||
bytes sesid = 1;
|
||||
TokenStuff token = 2;
|
||||
};
|
||||
|
||||
message MpGamerHandleDto {
|
||||
string gh = 1;
|
||||
};
|
||||
|
||||
message MpPeerAddressDto {
|
||||
string addr = 1;
|
||||
};
|
||||
|
||||
message InitPlayer2_Parameters {
|
||||
MpGamerHandleDto gh = 1;
|
||||
MpPeerAddressDto peerAddress = 2;
|
||||
int32 discriminator = 3;
|
||||
int32 seamlessType = 4;
|
||||
uint32 connectionReason = 5;
|
||||
};
|
||||
|
||||
message InitPlayerResult {
|
||||
uint32 code = 1;
|
||||
};
|
||||
|
||||
message Restriction {
|
||||
int32 u1 = 1;
|
||||
int32 u2 = 2;
|
||||
int32 u3 = 3;
|
||||
}
|
||||
|
||||
message GetRestrictionsData {
|
||||
repeated Restriction restriction = 1;
|
||||
repeated string unk2 = 2;
|
||||
};
|
||||
|
||||
message GetRestrictionsResult {
|
||||
GetRestrictionsData data = 1;
|
||||
};
|
||||
|
||||
message PlayerIdSto {
|
||||
int32 acctId = 1;
|
||||
int32 platId = 2;
|
||||
};
|
||||
|
||||
message MpSessionRequestIdDto {
|
||||
PlayerIdSto requestor = 1;
|
||||
int32 index = 2;
|
||||
int32 hash = 3;
|
||||
};
|
||||
|
||||
message QueueForSession_Seamless_Parameters {
|
||||
MpSessionRequestIdDto requestId = 1;
|
||||
uint32 optionFlags = 2;
|
||||
int32 x = 3;
|
||||
int32 y = 4;
|
||||
};
|
||||
|
||||
message QueueForSessionResult {
|
||||
uint32 code = 1;
|
||||
};
|
||||
|
||||
message QueueEntered_Parameters {
|
||||
uint32 queueGroup = 1;
|
||||
MpSessionRequestIdDto requestId = 2;
|
||||
uint32 optionFlags = 3;
|
||||
};
|
||||
|
||||
message GuidDto {
|
||||
fixed64 a = 1;
|
||||
fixed64 b = 2;
|
||||
};
|
||||
|
||||
message MpTransitionIdDto {
|
||||
GuidDto value = 1;
|
||||
};
|
||||
|
||||
message MpSessionIdDto {
|
||||
GuidDto value = 1;
|
||||
};
|
||||
|
||||
message SessionSubcommandEnterSession {
|
||||
int32 index = 1;
|
||||
int32 hindex = 2;
|
||||
uint32 sessionFlags = 3;
|
||||
uint32 mode = 4;
|
||||
int32 size = 5;
|
||||
int32 teamIndex = 6;
|
||||
MpTransitionIdDto transitionId = 7;
|
||||
uint32 sessionManagerType = 8;
|
||||
int32 slotCount = 9;
|
||||
};
|
||||
|
||||
message SessionSubcommandLeaveSession {
|
||||
uint32 reason = 1;
|
||||
};
|
||||
|
||||
message SessionSubcommandAddPlayer {
|
||||
PlayerIdSto id = 1;
|
||||
MpGamerHandleDto gh = 2;
|
||||
MpPeerAddressDto addr = 3;
|
||||
int32 index = 4;
|
||||
};
|
||||
|
||||
message SessionSubcommandRemovePlayer {
|
||||
PlayerIdSto id = 1;
|
||||
};
|
||||
|
||||
message SessionSubcommandHostChanged {
|
||||
int32 index = 1;
|
||||
};
|
||||
|
||||
message SessionCommand {
|
||||
uint32 cmd = 1;
|
||||
string cmdname = 2;
|
||||
SessionSubcommandEnterSession EnterSession = 3;
|
||||
SessionSubcommandLeaveSession LeaveSession = 4;
|
||||
SessionSubcommandAddPlayer AddPlayer = 5;
|
||||
SessionSubcommandRemovePlayer RemovePlayer = 6;
|
||||
SessionSubcommandHostChanged HostChanged = 7;
|
||||
};
|
||||
|
||||
message scmds_Parameters {
|
||||
MpSessionIdDto sid = 1;
|
||||
int32 ncmds = 2;
|
||||
repeated SessionCommand cmds = 3;
|
||||
};
|
||||
|
||||
message UriType {
|
||||
string url = 1;
|
||||
};
|
||||
|
||||
message TransitionReady_PlayerQueue_Parameters {
|
||||
UriType serverUri = 1;
|
||||
uint32 serverSandbox = 2;
|
||||
MpTransitionIdDto id = 3;
|
||||
uint32 sessionType = 4;
|
||||
MpSessionRequestIdDto requestId = 5;
|
||||
MpSessionIdDto transferId = 6;
|
||||
};
|
||||
|
||||
message TransitionToSession_Parameters {
|
||||
MpTransitionIdDto id = 1;
|
||||
float x = 2;
|
||||
float y = 3;
|
||||
};
|
||||
|
||||
message TransitionToSessionResult {
|
||||
uint32 code = 1;
|
||||
};
|
||||
@@ -0,0 +1,328 @@
|
||||
const protobuf = require("@citizenfx/protobufjs");
|
||||
|
||||
const playerDatas = {};
|
||||
let slotsUsed = 0;
|
||||
|
||||
function assignSlotId() {
|
||||
for (let i = 0; i < 32; i++) {
|
||||
if (!(slotsUsed & (1 << i))) {
|
||||
slotsUsed |= (1 << i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
let hostIndex = -1;
|
||||
const isOneSync = GetConvar("onesync", "off") !== "off";
|
||||
|
||||
protobuf.load(GetResourcePath(GetCurrentResourceName()) + "/rline.proto", function(err, root) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
const RpcMessage = root.lookupType("rline.RpcMessage");
|
||||
const RpcResponseMessage = root.lookupType("rline.RpcResponseMessage");
|
||||
const InitSessionResponse = root.lookupType("rline.InitSessionResponse");
|
||||
const InitPlayer2_Parameters = root.lookupType("rline.InitPlayer2_Parameters");
|
||||
const InitPlayerResult = root.lookupType("rline.InitPlayerResult");
|
||||
const GetRestrictionsResult = root.lookupType("rline.GetRestrictionsResult");
|
||||
const QueueForSession_Seamless_Parameters = root.lookupType("rline.QueueForSession_Seamless_Parameters");
|
||||
const QueueForSessionResult = root.lookupType("rline.QueueForSessionResult");
|
||||
const QueueEntered_Parameters = root.lookupType("rline.QueueEntered_Parameters");
|
||||
const TransitionReady_PlayerQueue_Parameters = root.lookupType("rline.TransitionReady_PlayerQueue_Parameters");
|
||||
const TransitionToSession_Parameters = root.lookupType("rline.TransitionToSession_Parameters");
|
||||
const TransitionToSessionResult = root.lookupType("rline.TransitionToSessionResult");
|
||||
const scmds_Parameters = root.lookupType("rline.scmds_Parameters");
|
||||
|
||||
function toArrayBuffer(buf) {
|
||||
var ab = new ArrayBuffer(buf.length);
|
||||
var view = new Uint8Array(ab);
|
||||
for (var i = 0; i < buf.length; ++i) {
|
||||
view[i] = buf[i];
|
||||
}
|
||||
return ab;
|
||||
}
|
||||
|
||||
function emitMsg(target, data) {
|
||||
emitNet('__cfx_internal:pbRlScSession', target, toArrayBuffer(data));
|
||||
}
|
||||
|
||||
function emitSessionCmds(target, cmd, cmdname, msg) {
|
||||
const stuff = {};
|
||||
stuff[cmdname] = msg;
|
||||
|
||||
emitMsg(target, RpcMessage.encode({
|
||||
Header: {
|
||||
MethodName: 'scmds'
|
||||
},
|
||||
Content: scmds_Parameters.encode({
|
||||
sid: {
|
||||
value: {
|
||||
a: 2,
|
||||
b: 2
|
||||
}
|
||||
},
|
||||
ncmds: 1,
|
||||
cmds: [
|
||||
{
|
||||
cmd,
|
||||
cmdname,
|
||||
...stuff
|
||||
}
|
||||
]
|
||||
}).finish()
|
||||
}).finish());
|
||||
}
|
||||
|
||||
function emitAddPlayer(target, msg) {
|
||||
emitSessionCmds(target, 2, 'AddPlayer', msg);
|
||||
}
|
||||
|
||||
function emitRemovePlayer(target, msg) {
|
||||
emitSessionCmds(target, 3, 'RemovePlayer', msg);
|
||||
}
|
||||
|
||||
function emitHostChanged(target, msg) {
|
||||
emitSessionCmds(target, 5, 'HostChanged', msg);
|
||||
}
|
||||
|
||||
onNet('playerDropped', () => {
|
||||
if (isOneSync) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const oData = playerDatas[source];
|
||||
delete playerDatas[source];
|
||||
|
||||
if (oData && hostIndex === oData.slot) {
|
||||
const pda = Object.entries(playerDatas);
|
||||
|
||||
if (pda.length > 0) {
|
||||
hostIndex = pda[0][1].slot | 0; // TODO: actually use <=31 slot index *and* check for id
|
||||
|
||||
for (const [ id, data ] of Object.entries(playerDatas)) {
|
||||
emitHostChanged(id, {
|
||||
index: hostIndex
|
||||
});
|
||||
}
|
||||
} else {
|
||||
hostIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!oData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (oData.slot > -1) {
|
||||
slotsUsed &= ~(1 << oData.slot);
|
||||
}
|
||||
|
||||
for (const [ id, data ] of Object.entries(playerDatas)) {
|
||||
emitRemovePlayer(id, {
|
||||
id: oData.id
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log(e.stack);
|
||||
}
|
||||
});
|
||||
|
||||
function makeResponse(type, data) {
|
||||
return {
|
||||
Header: {
|
||||
},
|
||||
Container: {
|
||||
Content: type.encode(data).finish()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const handlers = {
|
||||
async InitSession(source, data) {
|
||||
return makeResponse(InitSessionResponse, {
|
||||
sesid: Buffer.alloc(16),
|
||||
/*token: {
|
||||
tkn: 'ACSTOKEN token="meow",signature="meow"'
|
||||
}*/
|
||||
});
|
||||
},
|
||||
|
||||
async InitPlayer2(source, data) {
|
||||
const req = InitPlayer2_Parameters.decode(data);
|
||||
|
||||
if (!isOneSync) {
|
||||
playerDatas[source] = {
|
||||
gh: req.gh,
|
||||
peerAddress: req.peerAddress,
|
||||
discriminator: req.discriminator,
|
||||
slot: -1
|
||||
};
|
||||
}
|
||||
|
||||
return makeResponse(InitPlayerResult, {
|
||||
code: 0
|
||||
});
|
||||
},
|
||||
|
||||
async GetRestrictions(source, data) {
|
||||
return makeResponse(GetRestrictionsResult, {
|
||||
data: {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async ConfirmSessionEntered(source, data) {
|
||||
return {};
|
||||
},
|
||||
|
||||
async TransitionToSession(source, data) {
|
||||
const req = TransitionToSession_Parameters.decode(data);
|
||||
|
||||
return makeResponse(TransitionToSessionResult, {
|
||||
code: 1 // in this message, 1 is success
|
||||
});
|
||||
},
|
||||
|
||||
async QueueForSession_Seamless(source, data) {
|
||||
const req = QueueForSession_Seamless_Parameters.decode(data);
|
||||
|
||||
if (!isOneSync) {
|
||||
playerDatas[source].req = req.requestId;
|
||||
playerDatas[source].id = req.requestId.requestor;
|
||||
playerDatas[source].slot = assignSlotId();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
emitMsg(source, RpcMessage.encode({
|
||||
Header: {
|
||||
MethodName: 'QueueEntered'
|
||||
},
|
||||
Content: QueueEntered_Parameters.encode({
|
||||
queueGroup: 69,
|
||||
requestId: req.requestId,
|
||||
optionFlags: req.optionFlags
|
||||
}).finish()
|
||||
}).finish());
|
||||
|
||||
if (isOneSync) {
|
||||
hostIndex = 16
|
||||
} else if (hostIndex === -1) {
|
||||
hostIndex = playerDatas[source].slot | 0;
|
||||
}
|
||||
|
||||
emitMsg(source, RpcMessage.encode({
|
||||
Header: {
|
||||
MethodName: 'TransitionReady_PlayerQueue'
|
||||
},
|
||||
Content: TransitionReady_PlayerQueue_Parameters.encode({
|
||||
serverUri: {
|
||||
url: ''
|
||||
},
|
||||
requestId: req.requestId,
|
||||
id: {
|
||||
value: {
|
||||
a: 2,
|
||||
b: 0
|
||||
}
|
||||
},
|
||||
serverSandbox: 0xD656C677,
|
||||
sessionType: 3,
|
||||
transferId: {
|
||||
value: {
|
||||
a: 2,
|
||||
b: 2
|
||||
}
|
||||
},
|
||||
}).finish()
|
||||
}).finish());
|
||||
|
||||
setTimeout(() => {
|
||||
emitSessionCmds(source, 0, 'EnterSession', {
|
||||
index: (isOneSync) ? 16 : playerDatas[source].slot | 0,
|
||||
hindex: hostIndex,
|
||||
sessionFlags: 0,
|
||||
mode: 0,
|
||||
size: (isOneSync) ? 0 : Object.entries(playerDatas).filter(a => a[1].id).length,
|
||||
//size: 2,
|
||||
//size: Object.entries(playerDatas).length,
|
||||
teamIndex: 0,
|
||||
transitionId: {
|
||||
value: {
|
||||
a: 2,
|
||||
b: 0
|
||||
}
|
||||
},
|
||||
sessionManagerType: 0,
|
||||
slotCount: 32
|
||||
});
|
||||
}, 50);
|
||||
|
||||
if (!isOneSync) {
|
||||
setTimeout(() => {
|
||||
// tell player about everyone, and everyone about player
|
||||
const meData = playerDatas[source];
|
||||
|
||||
const aboutMe = {
|
||||
id: meData.id,
|
||||
gh: meData.gh,
|
||||
addr: meData.peerAddress,
|
||||
index: playerDatas[source].slot | 0
|
||||
};
|
||||
|
||||
for (const [ id, data ] of Object.entries(playerDatas)) {
|
||||
if (id == source || !data.id) continue;
|
||||
|
||||
emitAddPlayer(source, {
|
||||
id: data.id,
|
||||
gh: data.gh,
|
||||
addr: data.peerAddress,
|
||||
index: data.slot | 0
|
||||
});
|
||||
|
||||
emitAddPlayer(id, aboutMe);
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
}, 250);
|
||||
|
||||
return makeResponse(QueueForSessionResult, {
|
||||
code: 1
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
async function handleMessage(source, method, data) {
|
||||
if (handlers[method]) {
|
||||
return await handlers[method](source, data);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
onNet('__cfx_internal:pbRlScSession', async (data) => {
|
||||
const s = source;
|
||||
|
||||
try {
|
||||
const message = RpcMessage.decode(new Uint8Array(data));
|
||||
const response = await handleMessage(s, message.Header.MethodName, message.Content);
|
||||
|
||||
if (!response || !response.Header) {
|
||||
return;
|
||||
}
|
||||
|
||||
response.Header.RequestId = message.Header.RequestId;
|
||||
|
||||
emitMsg(s, RpcResponseMessage.encode(response).finish());
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log(e.stack);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
--This empty file causes the scheduler.lua to load clientside
|
||||
--scheduler.lua when loaded inside the sessionmanager resource currently manages remote callbacks.
|
||||
--Without this, callbacks will only work server->client and not client->server.
|
||||
@@ -0,0 +1,13 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Handles the "host lock" for non-OneSync servers. Do not disable.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
fx_version 'cerulean'
|
||||
games { 'gta4', 'gta5' }
|
||||
|
||||
server_script 'server/host_lock.lua'
|
||||
client_script 'client/empty.lua'
|
||||
@@ -0,0 +1,69 @@
|
||||
-- whitelist c2s events
|
||||
RegisterServerEvent('hostingSession')
|
||||
RegisterServerEvent('hostedSession')
|
||||
|
||||
-- event handler for pre-session 'acquire'
|
||||
local currentHosting
|
||||
local hostReleaseCallbacks = {}
|
||||
|
||||
-- TODO: add a timeout for the hosting lock to be held
|
||||
-- TODO: add checks for 'fraudulent' conflict cases of hosting attempts (typically whenever the host can not be reached)
|
||||
AddEventHandler('hostingSession', function()
|
||||
-- if the lock is currently held, tell the client to await further instruction
|
||||
if currentHosting then
|
||||
TriggerClientEvent('sessionHostResult', source, 'wait')
|
||||
|
||||
-- register a callback for when the lock is freed
|
||||
table.insert(hostReleaseCallbacks, function()
|
||||
TriggerClientEvent('sessionHostResult', source, 'free')
|
||||
end)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- if the current host was last contacted less than a second ago
|
||||
if GetHostId() then
|
||||
if GetPlayerLastMsg(GetHostId()) < 1000 then
|
||||
TriggerClientEvent('sessionHostResult', source, 'conflict')
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
hostReleaseCallbacks = {}
|
||||
|
||||
currentHosting = source
|
||||
|
||||
TriggerClientEvent('sessionHostResult', source, 'go')
|
||||
|
||||
-- set a timeout of 5 seconds
|
||||
SetTimeout(5000, function()
|
||||
if not currentHosting then
|
||||
return
|
||||
end
|
||||
|
||||
currentHosting = nil
|
||||
|
||||
for _, cb in ipairs(hostReleaseCallbacks) do
|
||||
cb()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('hostedSession', function()
|
||||
-- check if the client is the original locker
|
||||
if currentHosting ~= source then
|
||||
-- TODO: drop client as they're clearly lying
|
||||
print(currentHosting, '~=', source)
|
||||
return
|
||||
end
|
||||
|
||||
-- free the host lock (call callbacks and remove the lock value)
|
||||
for _, cb in ipairs(hostReleaseCallbacks) do
|
||||
cb()
|
||||
end
|
||||
|
||||
currentHosting = nil
|
||||
end)
|
||||
|
||||
EnableEnhancedHostSupport(true)
|
||||
BIN
resources/[cfx-default]/[test]/example-loadscreen/bankgothic.ttf
Normal file
BIN
resources/[cfx-default]/[test]/example-loadscreen/bankgothic.ttf
Normal file
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Example loading screen.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
files {
|
||||
'index.html',
|
||||
'keks.css',
|
||||
'bankgothic.ttf',
|
||||
'loadscreen.jpg'
|
||||
}
|
||||
|
||||
loadscreen 'index.html'
|
||||
|
||||
fx_version 'bodacious'
|
||||
game 'gta5'
|
||||
77
resources/[cfx-default]/[test]/example-loadscreen/index.html
Normal file
77
resources/[cfx-default]/[test]/example-loadscreen/index.html
Normal file
@@ -0,0 +1,77 @@
|
||||
<html>
|
||||
<head>
|
||||
<link href="keks.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="backdrop">
|
||||
<div class="top">
|
||||
<h1 title="Free Mode">Free Mode</h1>
|
||||
<h2 title="Not Algonquin">Not Algonquin</h2>
|
||||
</div>
|
||||
|
||||
<div class="letni">
|
||||
<h2 title="INTEL">Intel</h2>
|
||||
<h3></h3>
|
||||
<div class="loadbar"><div class="thingy"></div></div>
|
||||
<p>The Statue of Happiness has no heart. You do.</p>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div id="gradient">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// this will actually restart the loading bar a lot, making multiple loading bars is an exercise to the reader... for now.
|
||||
// for a set of possible events, see https://github.com/citizenfx/fivem/blob/master/code/components/loading-screens-five/src/LoadingScreens.cpp
|
||||
var count = 0;
|
||||
var thisCount = 0;
|
||||
|
||||
const emoji = {
|
||||
INIT_BEFORE_MAP_LOADED: [ '🍉' ],
|
||||
INIT_AFTER_MAP_LOADED: [ '🍋', '🍊' ],
|
||||
INIT_SESSION: [ '🍐', '🍅', '🍆' ],
|
||||
};
|
||||
|
||||
const handlers = {
|
||||
startInitFunctionOrder(data)
|
||||
{
|
||||
count = data.count;
|
||||
|
||||
document.querySelector('.letni h3').innerHTML += emoji[data.type][data.order - 1] || '';
|
||||
},
|
||||
|
||||
initFunctionInvoking(data)
|
||||
{
|
||||
document.querySelector('.thingy').style.left = '0%';
|
||||
document.querySelector('.thingy').style.width = ((data.idx / count) * 100) + '%';
|
||||
},
|
||||
|
||||
startDataFileEntries(data)
|
||||
{
|
||||
count = data.count;
|
||||
|
||||
document.querySelector('.letni h3').innerHTML += "\u{1f358}";
|
||||
},
|
||||
|
||||
performMapLoadFunction(data)
|
||||
{
|
||||
++thisCount;
|
||||
|
||||
document.querySelector('.thingy').style.left = '0%';
|
||||
document.querySelector('.thingy').style.width = ((thisCount / count) * 100) + '%';
|
||||
},
|
||||
|
||||
onLogLine(data)
|
||||
{
|
||||
document.querySelector('.letni p').innerHTML = data.message + "..!";
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', function(e)
|
||||
{
|
||||
(handlers[e.data.eventName] || function() {})(e.data);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
151
resources/[cfx-default]/[test]/example-loadscreen/keks.css
Normal file
151
resources/[cfx-default]/[test]/example-loadscreen/keks.css
Normal file
@@ -0,0 +1,151 @@
|
||||
body
|
||||
{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.backdrop
|
||||
{
|
||||
position: relative;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background-image: url(loadscreen.jpg);
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.bottom
|
||||
{
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#gradient
|
||||
{
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
|
||||
height: 25%;
|
||||
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'BankGothic';
|
||||
src: url('bankgothic.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
position: relative;
|
||||
background: transparent;
|
||||
z-index: 0;
|
||||
}
|
||||
/* add a single stroke */
|
||||
h1:before, h2:before {
|
||||
content: attr(title);
|
||||
position: absolute;
|
||||
-webkit-text-stroke: 0.1em #000;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
|
||||
.letni
|
||||
{
|
||||
position: absolute;
|
||||
left: 5%;
|
||||
right: 5%;
|
||||
bottom: 10%;
|
||||
|
||||
z-index: 5;
|
||||
|
||||
color: #fff;
|
||||
|
||||
font-family: "Segoe UI";
|
||||
}
|
||||
|
||||
.letni p
|
||||
{
|
||||
font-size: 22px;
|
||||
|
||||
margin-left: 3px;
|
||||
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.letni h2, .letni h3
|
||||
{
|
||||
font-family: BankGothic;
|
||||
|
||||
text-transform: uppercase;
|
||||
|
||||
font-size: 50px;
|
||||
|
||||
margin: 0px;
|
||||
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.top
|
||||
{
|
||||
color: #fff;
|
||||
|
||||
position: absolute;
|
||||
top: 7%;
|
||||
left: 5%;
|
||||
right: 5%;
|
||||
}
|
||||
|
||||
.top h1
|
||||
{
|
||||
font-family: BankGothic;
|
||||
font-size: 60px;
|
||||
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.top h2
|
||||
{
|
||||
font-family: BankGothic;
|
||||
font-size: 40px;
|
||||
|
||||
margin: 0px;
|
||||
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.loadbar
|
||||
{
|
||||
width: 100%;
|
||||
background-color: rgba(140, 140, 140, .9);
|
||||
height: 20px;
|
||||
|
||||
margin-left: 2px;
|
||||
margin-right: 3px;
|
||||
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
position: relative;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
.thingy
|
||||
{
|
||||
width: 10%;
|
||||
background-color: #eee;
|
||||
height: 20px;
|
||||
|
||||
position: absolute;
|
||||
left: 10%;
|
||||
}
|
||||
BIN
resources/[cfx-default]/[test]/example-loadscreen/loadscreen.jpg
Normal file
BIN
resources/[cfx-default]/[test]/example-loadscreen/loadscreen.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 KiB |
13
resources/[cfx-default]/[test]/fivem/fxmanifest.lua
Normal file
13
resources/[cfx-default]/[test]/fivem/fxmanifest.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'A compatibility resource to load basic-gamemode.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
-- compatibility wrapper
|
||||
fx_version 'adamant'
|
||||
game 'common'
|
||||
|
||||
dependency 'basic-gamemode'
|
||||
674
resources/[core]/cron/LICENSE
Normal file
674
resources/[core]/cron/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
cron
|
||||
Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
cron Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
37
resources/[core]/cron/README.md
Normal file
37
resources/[core]/cron/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
<h1 align='center'>[ESX] Cron</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
|
||||
|
||||
A simple, but vital, resource that allows resources to Run tasks at specific intervals.
|
||||
|
||||
# Example Usage
|
||||
|
||||
```lua
|
||||
|
||||
-- Execute task 5:10, every day
|
||||
function CronTask(d, h, m)
|
||||
print('Task done')
|
||||
end
|
||||
|
||||
TriggerEvent('cron:runAt', 5, 10, CronTask)
|
||||
|
||||
-- Execute task every monday at 18:30
|
||||
function CronTask(d, h, m)
|
||||
if d == 1 then
|
||||
print('Task done')
|
||||
end
|
||||
end
|
||||
|
||||
TriggerEvent('cron:runAt', 18, 30, CronTask)
|
||||
|
||||
```
|
||||
|
||||
# Legal
|
||||
|
||||
cron - run tasks at specific intervals!
|
||||
|
||||
Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
|
||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||
|
||||
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
|
||||
|
||||
You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/.
|
||||
9
resources/[core]/cron/fxmanifest.lua
Normal file
9
resources/[core]/cron/fxmanifest.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
fx_version 'adamant'
|
||||
|
||||
game 'gta5'
|
||||
author 'ESX-Framework'
|
||||
description 'Allows resources to Run tasks at specific intervals.'
|
||||
lua54 'yes'
|
||||
version '1.13.5'
|
||||
|
||||
server_script 'server/main.lua'
|
||||
75
resources/[core]/cron/server/main.lua
Normal file
75
resources/[core]/cron/server/main.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
---@class CronJob
|
||||
---@field h number
|
||||
---@field m number
|
||||
---@field cb function|table
|
||||
|
||||
---@type CronJob[]
|
||||
local cronJobs = {}
|
||||
---@type number|false
|
||||
local lastTimestamp = false
|
||||
|
||||
---@param h number
|
||||
---@param m number
|
||||
---@param cb function|table
|
||||
function RunAt(h, m, cb)
|
||||
cronJobs[#cronJobs + 1] = {
|
||||
h = h,
|
||||
m = m,
|
||||
cb = cb,
|
||||
}
|
||||
end
|
||||
|
||||
---@return number
|
||||
function GetUnixTimestamp()
|
||||
return os.time()
|
||||
end
|
||||
|
||||
---@param timestamp number
|
||||
function OnTime(timestamp)
|
||||
for i = 1, #cronJobs, 1 do
|
||||
local scheduledTimestamp = os.time({
|
||||
hour = cronJobs[i].h,
|
||||
min = cronJobs[i].m,
|
||||
sec = 0, -- Assuming tasks run at the start of the minute
|
||||
day = os.date("%d", timestamp),
|
||||
month = os.date("%m", timestamp),
|
||||
year = os.date("%Y", timestamp),
|
||||
})
|
||||
|
||||
if timestamp >= scheduledTimestamp and (not lastTimestamp or lastTimestamp < scheduledTimestamp) then
|
||||
local d = os.date('*t', scheduledTimestamp).wday
|
||||
cronJobs[i].cb(d, cronJobs[i].h, cronJobs[i].m)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@return nil
|
||||
function Tick()
|
||||
local timestamp = GetUnixTimestamp()
|
||||
|
||||
if not lastTimestamp or os.date("%M", timestamp) ~= os.date("%M", lastTimestamp) then
|
||||
OnTime(timestamp)
|
||||
lastTimestamp = timestamp
|
||||
end
|
||||
|
||||
SetTimeout(60000, Tick)
|
||||
end
|
||||
|
||||
lastTimestamp = GetUnixTimestamp()
|
||||
Tick()
|
||||
|
||||
---@param h number
|
||||
---@param m number
|
||||
---@param cb function|table
|
||||
AddEventHandler("cron:runAt", function(h, m, cb)
|
||||
local invokingResource = GetInvokingResource() or "Unknown"
|
||||
local typeH = type(h)
|
||||
local typeM = type(m)
|
||||
local typeCb = type(cb)
|
||||
|
||||
assert(typeH == "number", ("Expected number for h, got %s. Invoking Resource: '%s'"):format(typeH, invokingResource))
|
||||
assert(typeM == "number", ("Expected number for m, got %s. Invoking Resource: '%s'"):format(typeM, invokingResource))
|
||||
assert(typeCb == "function" or (typeCb == "table" and type(getmetatable(cb)?.__call) == "function"), ("Expected function for cb, got %s. Invoking Resource: '%s'"):format(typeCb, invokingResource))
|
||||
|
||||
RunAt(h, m, cb)
|
||||
end)
|
||||
674
resources/[core]/es_extended/LICENSE
Normal file
674
resources/[core]/es_extended/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
es_extended
|
||||
Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
es_extended Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
13
resources/[core]/es_extended/README.md
Normal file
13
resources/[core]/es_extended/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
<h1 align='center'>es_extended</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
|
||||
|
||||
## Legal
|
||||
|
||||
es_extended
|
||||
|
||||
Copyright (C) 2015-2024 Jérémie N'gadi
|
||||
|
||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||
|
||||
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
|
||||
|
||||
You should have received a copy Of the GNU General Public License along with this program. If Not, see <http://www.gnu.org/licenses/>.
|
||||
1367
resources/[core]/es_extended/client/functions.lua
Normal file
1367
resources/[core]/es_extended/client/functions.lua
Normal file
File diff suppressed because it is too large
Load Diff
21
resources/[core]/es_extended/client/imports/class.lua
Normal file
21
resources/[core]/es_extended/client/imports/class.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local class = {}
|
||||
class.__index = class
|
||||
|
||||
function class:new(...)
|
||||
local instance = setmetatable({}, self)
|
||||
if instance.constructor then
|
||||
local ret = instance:constructor(...)
|
||||
if type(ret) == 'table' then
|
||||
return ret
|
||||
end
|
||||
end
|
||||
return instance
|
||||
end
|
||||
|
||||
function Class(body, heritage)
|
||||
local prototype = body or {}
|
||||
prototype.__index = prototype
|
||||
return setmetatable(prototype, heritage or class)
|
||||
end
|
||||
|
||||
return Class
|
||||
53
resources/[core]/es_extended/client/imports/point.lua
Normal file
53
resources/[core]/es_extended/client/imports/point.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local Point = ESX.Class()
|
||||
|
||||
local nearby, loop = {}, nil
|
||||
|
||||
function Point:constructor(properties)
|
||||
self.coords = properties.coords
|
||||
self.hidden = properties.hidden
|
||||
self.enter = properties.enter
|
||||
self.leave = properties.leave
|
||||
self.inside = properties.inside
|
||||
self.handle = ESX.CreatePointInternal(properties.coords, properties.distance, properties.hidden, function()
|
||||
nearby[self.handle] = self
|
||||
if self.enter then
|
||||
self:enter()
|
||||
end
|
||||
if not loop then
|
||||
loop = true
|
||||
CreateThread(function()
|
||||
while loop do
|
||||
local coords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
for _, point in pairs(nearby) do
|
||||
if point.inside then
|
||||
point:inside(#(coords - point.coords))
|
||||
end
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end, function()
|
||||
nearby[self.handle] = nil
|
||||
if self.leave then
|
||||
self:leave()
|
||||
end
|
||||
if #nearby == 0 then
|
||||
loop = false
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Point:delete()
|
||||
ESX.RemovePointInternal(self.handle)
|
||||
end
|
||||
|
||||
function Point:toggle(hidden)
|
||||
if hidden == nil then
|
||||
hidden = not self.hidden
|
||||
end
|
||||
self.hidden = hidden
|
||||
ESX.HidePointInternal(self.handle, hidden)
|
||||
end
|
||||
|
||||
return Point
|
||||
30
resources/[core]/es_extended/client/main.lua
Normal file
30
resources/[core]/es_extended/client/main.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
Core = {}
|
||||
Core.Input = {}
|
||||
Core.Events = {}
|
||||
|
||||
ESX.PlayerData = {}
|
||||
ESX.PlayerLoaded = false
|
||||
ESX.playerId = PlayerId()
|
||||
ESX.serverId = GetPlayerServerId(ESX.playerId)
|
||||
|
||||
ESX.UI = {}
|
||||
ESX.UI.Menu = {}
|
||||
ESX.UI.Menu.RegisteredTypes = {}
|
||||
ESX.UI.Menu.Opened = {}
|
||||
|
||||
ESX.Game = {}
|
||||
ESX.Game.Utils = {}
|
||||
|
||||
CreateThread(function()
|
||||
while not Config.Multichar do
|
||||
Wait(100)
|
||||
|
||||
if NetworkIsPlayerActive(ESX.playerId) then
|
||||
ESX.DisableSpawnManager()
|
||||
DoScreenFadeOut(0)
|
||||
Wait(500)
|
||||
TriggerServerEvent("esx:onPlayerJoined")
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
234
resources/[core]/es_extended/client/modules/actions.lua
Normal file
234
resources/[core]/es_extended/client/modules/actions.lua
Normal file
@@ -0,0 +1,234 @@
|
||||
Actions = {}
|
||||
Actions._index = Actions
|
||||
|
||||
Actions.inVehicle = false
|
||||
Actions.enteringVehicle = false
|
||||
Actions.inPauseMenu = false
|
||||
Actions.currentWeapon = false
|
||||
|
||||
function Actions:GetSeatPedIsIn()
|
||||
for i = -1, 16 do
|
||||
if GetPedInVehicleSeat(self.vehicle, i) == ESX.PlayerData.ped then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
function Actions:GetVehicleData()
|
||||
if not DoesEntityExist(self.vehicle) then
|
||||
return
|
||||
end
|
||||
|
||||
local vehicleModel = GetEntityModel(self.vehicle)
|
||||
local displayName = GetDisplayNameFromVehicleModel(vehicleModel)
|
||||
local netId = NetworkGetEntityIsNetworked(self.vehicle) and VehToNet(self.vehicle) or self.vehicle
|
||||
local plate = GetVehicleNumberPlateText(self.vehicle)
|
||||
|
||||
return displayName, netId, plate
|
||||
end
|
||||
|
||||
function Actions:SetVehicleStatus()
|
||||
ESX.SetPlayerData("vehicle", self.vehicle)
|
||||
ESX.SetPlayerData("seat", self.seat)
|
||||
end
|
||||
|
||||
function Actions:TrackPedCoordsOnce()
|
||||
CreateThread(function()
|
||||
while not ESX.IsPlayerLoaded() do
|
||||
Wait(250)
|
||||
end
|
||||
|
||||
ESX.PlayerData.coords = nil
|
||||
|
||||
setmetatable(ESX.PlayerData, {
|
||||
__index = function(_, key)
|
||||
if key ~= "coords" then
|
||||
return
|
||||
end
|
||||
|
||||
local coords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
|
||||
return coords
|
||||
end
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
function Actions:TrackPed()
|
||||
local playerPed = ESX.PlayerData.ped
|
||||
local newPed = PlayerPedId()
|
||||
|
||||
if playerPed ~= newPed then
|
||||
ESX.SetPlayerData("ped", newPed)
|
||||
|
||||
TriggerEvent("esx:playerPedChanged", newPed)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Player ped changed:", newPed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:TrackPauseMenu()
|
||||
local isActive = IsPauseMenuActive()
|
||||
|
||||
if isActive ~= self.inPauseMenu then
|
||||
self.inPauseMenu = isActive
|
||||
TriggerEvent("esx:pauseMenuActive", isActive)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Pause menu active:", isActive)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:EnterVehicle()
|
||||
self.seat = GetSeatPedIsTryingToEnter(ESX.PlayerData.ped)
|
||||
|
||||
local _, netId, plate = self:GetVehicleData()
|
||||
|
||||
self.enteringVehicle = true
|
||||
TriggerEvent("esx:enteringVehicle", self.vehicle, plate, self.seat, netId)
|
||||
TriggerServerEvent("esx:enteringVehicle", plate, self.seat, netId)
|
||||
|
||||
self:SetVehicleStatus()
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Entering vehicle:", self.vehicle, plate, self.seat, netId)
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:ResetVehicleData()
|
||||
self.enteringVehicle = false
|
||||
self.vehicle = false
|
||||
self.seat = false
|
||||
self.inVehicle = false
|
||||
|
||||
self:SetVehicleStatus()
|
||||
end
|
||||
|
||||
function Actions:EnterAborted()
|
||||
self:ResetVehicleData()
|
||||
|
||||
TriggerEvent("esx:enteringVehicleAborted")
|
||||
TriggerServerEvent("esx:enteringVehicleAborted")
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Entering vehicle aborted")
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:WarpEnter()
|
||||
self.enteringVehicle = false
|
||||
self.inVehicle = true
|
||||
|
||||
self.seat = self:GetSeatPedIsIn()
|
||||
|
||||
local displayName, netId, plate = self:GetVehicleData()
|
||||
|
||||
self:SetVehicleStatus()
|
||||
TriggerEvent("esx:enteredVehicle", self.vehicle, plate, self.seat, displayName, netId)
|
||||
TriggerServerEvent("esx:enteredVehicle", plate, self.seat, displayName, netId)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Entered vehicle:", self.vehicle, plate, self.seat, displayName, netId)
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:ExitVehicle()
|
||||
local currentVehicle = GetVehiclePedIsIn(ESX.PlayerData.ped, false)
|
||||
|
||||
if currentVehicle ~= self.vehicle or ESX.PlayerData.dead then
|
||||
local displayName, netId, plate = self:GetVehicleData()
|
||||
|
||||
TriggerEvent("esx:exitedVehicle", self.vehicle, plate, self.seat, displayName, netId)
|
||||
TriggerServerEvent("esx:exitedVehicle", plate, self.seat, displayName, netId)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Exited vehicle:", self.vehicle, plate, self.seat, displayName, netId)
|
||||
end
|
||||
|
||||
self:ResetVehicleData()
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:TrackVehicle()
|
||||
if not self.inVehicle and not ESX.PlayerData.dead then
|
||||
local tempVehicle = GetVehiclePedIsTryingToEnter(ESX.PlayerData.ped)
|
||||
|
||||
if DoesEntityExist(tempVehicle) and not self.enteringVehicle then
|
||||
self.vehicle = tempVehicle
|
||||
self:EnterVehicle()
|
||||
elseif not DoesEntityExist(tempVehicle) and not IsPedInAnyVehicle(ESX.PlayerData.ped, true) and self.enteringVehicle then
|
||||
self:EnterAborted()
|
||||
elseif IsPedInAnyVehicle(ESX.PlayerData.ped, false) then
|
||||
self.vehicle = GetVehiclePedIsIn(ESX.PlayerData.ped, false)
|
||||
self:WarpEnter()
|
||||
end
|
||||
elseif self.inVehicle then
|
||||
self:ExitVehicle()
|
||||
self:TrackSeat()
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:TrackSeat()
|
||||
if not self.inVehicle then
|
||||
return
|
||||
end
|
||||
|
||||
local newSeat = self:GetSeatPedIsIn()
|
||||
if newSeat ~= self.seat then
|
||||
self.seat = newSeat
|
||||
ESX.SetPlayerData("seat", self.seat)
|
||||
TriggerEvent("esx:vehicleSeatChanged", self.seat)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Vehicle seat changed:", self.seat)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:TrackWeapon()
|
||||
---@type number|false
|
||||
local newWeapon = GetSelectedPedWeapon(ESX.PlayerData.ped)
|
||||
newWeapon = newWeapon ~= `WEAPON_UNARMED` and newWeapon or false
|
||||
|
||||
if newWeapon ~= self.currentWeapon then
|
||||
self.currentWeapon = newWeapon
|
||||
ESX.SetPlayerData("weapon", self.currentWeapon)
|
||||
TriggerEvent("esx:weaponChanged", self.currentWeapon)
|
||||
|
||||
if Config.EnableDebug then
|
||||
print("[DEBUG] Weapon changed:", self.currentWeapon)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Actions:SlowLoop()
|
||||
CreateThread(function()
|
||||
while ESX.PlayerLoaded do
|
||||
self:TrackPauseMenu()
|
||||
self:TrackVehicle()
|
||||
self:TrackWeapon()
|
||||
Wait(500)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Actions:PedLoop()
|
||||
CreateThread(function()
|
||||
while ESX.PlayerLoaded do
|
||||
self:TrackPed()
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Actions:Init()
|
||||
self:SlowLoop()
|
||||
self:PedLoop()
|
||||
self:TrackPedCoordsOnce()
|
||||
end
|
||||
|
||||
Actions:Init()
|
||||
253
resources/[core]/es_extended/client/modules/adjustments.lua
Normal file
253
resources/[core]/es_extended/client/modules/adjustments.lua
Normal file
@@ -0,0 +1,253 @@
|
||||
Adjustments = {}
|
||||
|
||||
function Adjustments:RemoveHudComponents()
|
||||
for i = 1, #Config.RemoveHudComponents do
|
||||
if Config.RemoveHudComponents[i] then
|
||||
SetHudComponentSize(i, 0.0, 0.0)
|
||||
SetHudComponentPosition(i, 900.0, 900.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:DisableAimAssist()
|
||||
if Config.DisableAimAssist then
|
||||
SetPlayerTargetingMode(3)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:DisableNPCDrops()
|
||||
if Config.DisableNPCDrops then
|
||||
local weaponPickups = { `PICKUP_WEAPON_CARBINERIFLE`, `PICKUP_WEAPON_PISTOL`, `PICKUP_WEAPON_PUMPSHOTGUN` }
|
||||
for i = 1, #weaponPickups do
|
||||
ToggleUsePickupsForPlayer(ESX.playerId, weaponPickups[i], false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:SeatShuffle()
|
||||
if Config.DisableVehicleSeatShuff then
|
||||
AddEventHandler("esx:enteredVehicle", function(vehicle, _, seat)
|
||||
if seat > -1 then
|
||||
SetPedIntoVehicle(ESX.PlayerData.ped, vehicle, seat)
|
||||
SetPedConfigFlag(ESX.PlayerData.ped, 184, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:HealthRegeneration()
|
||||
if Config.DisableHealthRegeneration then
|
||||
SetPlayerHealthRechargeMultiplier(ESX.playerId, 0.0)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:AmmoAndVehicleRewards()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
if Config.DisableDisplayAmmo then
|
||||
DisplayAmmoThisFrame(false)
|
||||
end
|
||||
|
||||
if Config.DisableVehicleRewards then
|
||||
DisablePlayerVehicleRewards(ESX.playerId)
|
||||
end
|
||||
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Adjustments:EnablePvP()
|
||||
if Config.EnablePVP then
|
||||
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:DispatchServices()
|
||||
if Config.DisableDispatchServices then
|
||||
for i = 1, 15 do
|
||||
EnableDispatchService(i, false)
|
||||
end
|
||||
SetAudioFlag('PoliceScannerDisabled', true)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:NPCScenarios()
|
||||
if Config.DisableScenarios then
|
||||
local scenarios = {
|
||||
"WORLD_VEHICLE_ATTRACTOR",
|
||||
"WORLD_VEHICLE_AMBULANCE",
|
||||
"WORLD_VEHICLE_BICYCLE_BMX",
|
||||
"WORLD_VEHICLE_BICYCLE_BMX_BALLAS",
|
||||
"WORLD_VEHICLE_BICYCLE_BMX_FAMILY",
|
||||
"WORLD_VEHICLE_BICYCLE_BMX_HARMONY",
|
||||
"WORLD_VEHICLE_BICYCLE_BMX_VAGOS",
|
||||
"WORLD_VEHICLE_BICYCLE_MOUNTAIN",
|
||||
"WORLD_VEHICLE_BICYCLE_ROAD",
|
||||
"WORLD_VEHICLE_BIKE_OFF_ROAD_RACE",
|
||||
"WORLD_VEHICLE_BIKER",
|
||||
"WORLD_VEHICLE_BOAT_IDLE",
|
||||
"WORLD_VEHICLE_BOAT_IDLE_ALAMO",
|
||||
"WORLD_VEHICLE_BOAT_IDLE_MARQUIS",
|
||||
"WORLD_VEHICLE_BROKEN_DOWN",
|
||||
"WORLD_VEHICLE_BUSINESSMEN",
|
||||
"WORLD_VEHICLE_HELI_LIFEGUARD",
|
||||
"WORLD_VEHICLE_CLUCKIN_BELL_TRAILER",
|
||||
"WORLD_VEHICLE_CONSTRUCTION_SOLO",
|
||||
"WORLD_VEHICLE_CONSTRUCTION_PASSENGERS",
|
||||
"WORLD_VEHICLE_DRIVE_PASSENGERS",
|
||||
"WORLD_VEHICLE_DRIVE_PASSENGERS_LIMITED",
|
||||
"WORLD_VEHICLE_DRIVE_SOLO",
|
||||
"WORLD_VEHICLE_FIRE_TRUCK",
|
||||
"WORLD_VEHICLE_EMPTY",
|
||||
"WORLD_VEHICLE_MARIACHI",
|
||||
"WORLD_VEHICLE_MECHANIC",
|
||||
"WORLD_VEHICLE_MILITARY_PLANES_BIG",
|
||||
"WORLD_VEHICLE_MILITARY_PLANES_SMALL",
|
||||
"WORLD_VEHICLE_PARK_PARALLEL",
|
||||
"WORLD_VEHICLE_PARK_PERPENDICULAR_NOSE_IN",
|
||||
"WORLD_VEHICLE_PASSENGER_EXIT",
|
||||
"WORLD_VEHICLE_POLICE_BIKE",
|
||||
"WORLD_VEHICLE_POLICE_CAR",
|
||||
"WORLD_VEHICLE_POLICE",
|
||||
"WORLD_VEHICLE_POLICE_NEXT_TO_CAR",
|
||||
"WORLD_VEHICLE_QUARRY",
|
||||
"WORLD_VEHICLE_SALTON",
|
||||
"WORLD_VEHICLE_SALTON_DIRT_BIKE",
|
||||
"WORLD_VEHICLE_SECURITY_CAR",
|
||||
"WORLD_VEHICLE_STREETRACE",
|
||||
"WORLD_VEHICLE_TOURBUS",
|
||||
"WORLD_VEHICLE_TOURIST",
|
||||
"WORLD_VEHICLE_TANDL",
|
||||
"WORLD_VEHICLE_TRACTOR",
|
||||
"WORLD_VEHICLE_TRACTOR_BEACH",
|
||||
"WORLD_VEHICLE_TRUCK_LOGS",
|
||||
"WORLD_VEHICLE_TRUCKS_TRAILERS",
|
||||
"WORLD_VEHICLE_DISTANT_EMPTY_GROUND",
|
||||
"WORLD_HUMAN_PAPARAZZI",
|
||||
}
|
||||
|
||||
for i=1, #scenarios do
|
||||
SetScenarioTypeEnabled(scenarios[i], false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:LicensePlates()
|
||||
SetDefaultVehicleNumberPlateTextPattern(-1, Config.CustomAIPlates)
|
||||
end
|
||||
|
||||
local placeHolders = {
|
||||
server_name = function()
|
||||
return GetConvar("sv_projectName", "ESX-Framework")
|
||||
end,
|
||||
server_endpoint = function()
|
||||
return GetCurrentServerEndpoint() or "localhost:30120"
|
||||
end,
|
||||
server_players = function()
|
||||
return GlobalState.playerCount or 0
|
||||
end,
|
||||
server_maxplayers = function()
|
||||
return GetConvarInt("sv_maxClients", 48)
|
||||
end,
|
||||
player_name = function()
|
||||
return GetPlayerName(ESX.playerId)
|
||||
end,
|
||||
player_rp_name = function()
|
||||
return ESX.PlayerData.name or "John Doe"
|
||||
end,
|
||||
player_id = function()
|
||||
return ESX.serverId
|
||||
end,
|
||||
player_street = function()
|
||||
if not ESX.PlayerData.ped then return "Unknown" end
|
||||
|
||||
local playerCoords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
local streetHash = GetStreetNameAtCoord(playerCoords.x, playerCoords.y, playerCoords.z)
|
||||
|
||||
return GetStreetNameFromHashKey(streetHash) or "Unknown"
|
||||
end,
|
||||
}
|
||||
|
||||
function Adjustments:ReplacePlaceholders(text)
|
||||
for placeholder, cb in pairs(placeHolders) do
|
||||
local success, result = pcall(cb)
|
||||
|
||||
if not success then
|
||||
error(("Failed to execute placeholder: ^5%s^7\n%s"):format(placeholder, result))
|
||||
result = "Unknown"
|
||||
end
|
||||
|
||||
text = text:gsub(("{%s}"):format(placeholder), tostring(result))
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
function Adjustments:DiscordPresence()
|
||||
if Config.DiscordActivity.appId ~= 0 then
|
||||
CreateThread(function()
|
||||
while true do
|
||||
SetDiscordAppId(Config.DiscordActivity.appId)
|
||||
SetRichPresence(self:ReplacePlaceholders(Config.DiscordActivity.presence))
|
||||
SetDiscordRichPresenceAsset(Config.DiscordActivity.assetName)
|
||||
SetDiscordRichPresenceAssetText(self:ReplacePlaceholders(Config.DiscordActivity.assetText))
|
||||
|
||||
for i = 1, #Config.DiscordActivity.buttons do
|
||||
local button = Config.DiscordActivity.buttons[i]
|
||||
local buttonUrl = self:ReplacePlaceholders(button.url)
|
||||
SetDiscordRichPresenceAction(i - 1, button.label, buttonUrl)
|
||||
end
|
||||
|
||||
Wait(Config.DiscordActivity.refresh)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:WantedLevel()
|
||||
if not Config.EnableWantedLevel then
|
||||
ClearPlayerWantedLevel(ESX.playerId)
|
||||
SetMaxWantedLevel(0)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:DisableRadio()
|
||||
if Config.RemoveHudComponents[16] then
|
||||
AddEventHandler("esx:enteredVehicle", function(vehicle, plate, seat, displayName, netId)
|
||||
SetVehRadioStation(vehicle,"OFF")
|
||||
SetUserRadioControlEnabled(false)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function Adjustments:Multipliers()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
SetPedDensityMultiplierThisFrame(Config.Multipliers.pedDensity)
|
||||
SetScenarioPedDensityMultiplierThisFrame(Config.Multipliers.scenarioPedDensityInterior, Config.Multipliers.scenarioPedDensityExterior)
|
||||
SetAmbientVehicleRangeMultiplierThisFrame(Config.Multipliers.ambientVehicleRange)
|
||||
SetParkedVehicleDensityMultiplierThisFrame(Config.Multipliers.parkedVehicleDensity)
|
||||
SetRandomVehicleDensityMultiplierThisFrame(Config.Multipliers.randomVehicleDensity)
|
||||
SetVehicleDensityMultiplierThisFrame(Config.Multipliers.vehicleDensity)
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Adjustments:Load()
|
||||
self:RemoveHudComponents()
|
||||
self:DisableAimAssist()
|
||||
self:DisableNPCDrops()
|
||||
self:SeatShuffle()
|
||||
self:HealthRegeneration()
|
||||
self:AmmoAndVehicleRewards()
|
||||
self:EnablePvP()
|
||||
self:DispatchServices()
|
||||
self:NPCScenarios()
|
||||
self:LicensePlates()
|
||||
self:DiscordPresence()
|
||||
self:WantedLevel()
|
||||
self:DisableRadio()
|
||||
self:Multipliers()
|
||||
end
|
||||
146
resources/[core]/es_extended/client/modules/callback.lua
Normal file
146
resources/[core]/es_extended/client/modules/callback.lua
Normal file
@@ -0,0 +1,146 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
|
||||
-- =============================================
|
||||
-- MARK: Variables
|
||||
-- =============================================
|
||||
|
||||
Callbacks = {}
|
||||
|
||||
Callbacks.requests = {}
|
||||
Callbacks.storage = {}
|
||||
Callbacks.id = 0
|
||||
|
||||
-- =============================================
|
||||
-- MARK: Internal Functions
|
||||
-- =============================================
|
||||
|
||||
|
||||
function Callbacks:Register(name, resource, cb)
|
||||
self.storage[name] = {
|
||||
resource = resource,
|
||||
cb = cb
|
||||
}
|
||||
end
|
||||
|
||||
function Callbacks:Execute(cb, id, ...)
|
||||
local success, errorString = pcall(cb, ...)
|
||||
|
||||
if not success then
|
||||
print(("[^1ERROR^7] Failed to execute Callback with RequestId: ^5%s^7"):format(id))
|
||||
error(errorString)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function Callbacks:Trigger(event, cb, invoker, ...)
|
||||
self.requests[self.id] = {
|
||||
await = type(cb) == "boolean",
|
||||
cb = cb or promise:new()
|
||||
}
|
||||
local table = self.requests[self.id]
|
||||
|
||||
TriggerServerEvent("esx:triggerServerCallback", event, self.id, invoker, ...)
|
||||
|
||||
self.id += 1
|
||||
|
||||
return table.cb
|
||||
end
|
||||
|
||||
function Callbacks:ServerRecieve(requestId, invoker, ...)
|
||||
if not self.requests[requestId] then
|
||||
return error(("Server Callback with requestId ^5%s^1 Was Called by ^5%s^1 but does not exist."):format(requestId, invoker))
|
||||
end
|
||||
|
||||
local callback = self.requests[requestId]
|
||||
|
||||
self.requests[requestId] = nil
|
||||
|
||||
if callback.await then
|
||||
callback.cb:resolve({ ... })
|
||||
else
|
||||
self:Execute(callback.cb, requestId, ...)
|
||||
end
|
||||
end
|
||||
|
||||
function Callbacks:ClientRecieve(eventName, requestId, invoker, ...)
|
||||
if not self.storage[eventName] then
|
||||
return error(("Client Callback with requestId ^5%s^1 Was Called by ^5%s^1 but does not exist."):format(eventName, invoker))
|
||||
end
|
||||
|
||||
local returnCb = function(...)
|
||||
TriggerServerEvent("esx:clientCallback", requestId, invoker, ...)
|
||||
end
|
||||
local callback = self.storage[eventName].cb
|
||||
|
||||
self:Execute(callback, requestId, returnCb, ...)
|
||||
end
|
||||
|
||||
-- =============================================
|
||||
-- MARK: ESX Functions
|
||||
-- =============================================
|
||||
|
||||
---@param eventName string
|
||||
---@param callback function
|
||||
---@param ... any
|
||||
---@return nil
|
||||
function ESX.TriggerServerCallback(eventName, callback, ...)
|
||||
local invokingResource = GetInvokingResource()
|
||||
local invoker = (invokingResource and invokingResource ~= "unknown") and invokingResource or "es_extended"
|
||||
|
||||
Callbacks:Trigger(eventName, callback, invoker, ...)
|
||||
end
|
||||
|
||||
---@param eventName string
|
||||
---@param ... any
|
||||
---@return ...
|
||||
function ESX.AwaitServerCallback(eventName, ...)
|
||||
local invokingResource = GetInvokingResource()
|
||||
local invoker = (invokingResource and invokingResource ~= "unknown") and invokingResource or "es_extended"
|
||||
|
||||
local p = Callbacks:Trigger(eventName, false, invoker, ...)
|
||||
if not p then return end
|
||||
|
||||
-- if the server callback takes longer than 15 seconds to respond, reject the promise
|
||||
SetTimeout(15000, function()
|
||||
if p.state == "pending" then
|
||||
p:reject("Server Callback Timed Out")
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.Await(p)
|
||||
|
||||
return table.unpack(p.value)
|
||||
end
|
||||
|
||||
function ESX.RegisterClientCallback(eventName, callback)
|
||||
local invokingResource = GetInvokingResource()
|
||||
local invoker = (invokingResource and invokingResource ~= "Unknown") and invokingResource or "es_extended"
|
||||
|
||||
Callbacks:Register(eventName, invoker, callback)
|
||||
end
|
||||
|
||||
---@param eventName string
|
||||
---@return boolean
|
||||
function ESX.DoesClientCallbackExist(eventName)
|
||||
return Callbacks.storage[eventName] ~= nil
|
||||
end
|
||||
|
||||
-- =============================================
|
||||
-- MARK: Events
|
||||
-- =============================================
|
||||
|
||||
ESX.SecureNetEvent("esx:serverCallback", function(...)
|
||||
Callbacks:ServerRecieve(...)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:triggerClientCallback", function(...)
|
||||
Callbacks:ClientRecieve(...)
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resource)
|
||||
for k, v in pairs(Callbacks.storage) do
|
||||
if v.resource == resource then
|
||||
Callbacks.storage[k] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
75
resources/[core]/es_extended/client/modules/death.lua
Normal file
75
resources/[core]/es_extended/client/modules/death.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
Death = {}
|
||||
Death._index = Death
|
||||
|
||||
function Death:ResetValues()
|
||||
self.killerEntity = nil
|
||||
self.deathCause = nil
|
||||
self.killerId = nil
|
||||
self.killerServerId = nil
|
||||
end
|
||||
|
||||
function Death:ByPlayer()
|
||||
local victimCoords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
local killerCoords = GetEntityCoords(self.killerEntity)
|
||||
local distance = #(victimCoords - killerCoords)
|
||||
|
||||
local data = {
|
||||
victimCoords = { x = ESX.Math.Round(victimCoords.x, 1), y = ESX.Math.Round(victimCoords.y, 1), z = ESX.Math.Round(victimCoords.z, 1) },
|
||||
killerCoords = { x = ESX.Math.Round(killerCoords.x, 1), y = ESX.Math.Round(killerCoords.y, 1), z = ESX.Math.Round(killerCoords.z, 1) },
|
||||
|
||||
killedByPlayer = true,
|
||||
deathCause = self.deathCause,
|
||||
distance = ESX.Math.Round(distance, 1),
|
||||
|
||||
killerServerId = self.killerServerId,
|
||||
killerClientId = self.killerId,
|
||||
}
|
||||
|
||||
TriggerEvent("esx:onPlayerDeath", data)
|
||||
TriggerServerEvent("esx:onPlayerDeath", data)
|
||||
end
|
||||
|
||||
function Death:Natural()
|
||||
local coords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
|
||||
local data = {
|
||||
victimCoords = { x = ESX.Math.Round(coords.x, 1), y = ESX.Math.Round(coords.y, 1), z = ESX.Math.Round(coords.z, 1) },
|
||||
|
||||
killedByPlayer = false,
|
||||
deathCause = self.deathCause,
|
||||
}
|
||||
|
||||
TriggerEvent("esx:onPlayerDeath", data)
|
||||
TriggerServerEvent("esx:onPlayerDeath", data)
|
||||
end
|
||||
|
||||
function Death:Died()
|
||||
self.killerEntity = GetPedSourceOfDeath(ESX.PlayerData.ped)
|
||||
self.deathCause = GetPedCauseOfDeath(ESX.PlayerData.ped)
|
||||
self.killerId = NetworkGetPlayerIndexFromPed(self.killerEntity)
|
||||
self.killerServerId = GetPlayerServerId(self.killerId)
|
||||
|
||||
local isActive = NetworkIsPlayerActive(self.killerId)
|
||||
|
||||
if self.killerEntity ~= ESX.PlayerData.ped and self.killerId and isActive then
|
||||
self:ByPlayer()
|
||||
else
|
||||
self:Natural()
|
||||
end
|
||||
|
||||
self:ResetValues()
|
||||
end
|
||||
|
||||
AddEventHandler("esx:onPlayerSpawn", function()
|
||||
Citizen.CreateThreadNow(function()
|
||||
while not ESX.PlayerLoaded do Wait(0) end
|
||||
|
||||
while ESX.PlayerLoaded and not ESX.PlayerData.dead do
|
||||
if DoesEntityExist(ESX.PlayerData.ped) and (IsPedDeadOrDying(ESX.PlayerData.ped, true) or IsPedFatallyInjured(ESX.PlayerData.ped)) then
|
||||
Death:Died()
|
||||
break
|
||||
end
|
||||
Citizen.Wait(250)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
615
resources/[core]/es_extended/client/modules/events.lua
Normal file
615
resources/[core]/es_extended/client/modules/events.lua
Normal file
@@ -0,0 +1,615 @@
|
||||
local pickups = {}
|
||||
|
||||
RegisterNetEvent("esx:requestModel", function(model)
|
||||
ESX.Streaming.RequestModel(model)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:playerLoaded", function(xPlayer, _, skin)
|
||||
ESX.PlayerData = xPlayer
|
||||
|
||||
if not Config.Multichar then
|
||||
ESX.SpawnPlayer(skin, ESX.PlayerData.coords, function()
|
||||
TriggerEvent("esx:onPlayerSpawn")
|
||||
TriggerEvent("esx:restoreLoadout")
|
||||
TriggerServerEvent("esx:onPlayerSpawn")
|
||||
TriggerEvent("esx:loadingScreenOff")
|
||||
ShutdownLoadingScreen()
|
||||
ShutdownLoadingScreenNui()
|
||||
end)
|
||||
end
|
||||
|
||||
while not DoesEntityExist(ESX.PlayerData.ped) do
|
||||
Wait(20)
|
||||
end
|
||||
|
||||
ESX.PlayerLoaded = true
|
||||
|
||||
local timer = GetGameTimer()
|
||||
while not HaveAllStreamingRequestsCompleted(ESX.PlayerData.ped) and (GetGameTimer() - timer) < 2000 do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
Adjustments:Load()
|
||||
|
||||
ClearPedTasksImmediately(ESX.PlayerData.ped)
|
||||
|
||||
if not Config.Multichar then
|
||||
Core.FreezePlayer(false)
|
||||
end
|
||||
|
||||
if IsScreenFadedOut() then
|
||||
DoScreenFadeIn(500)
|
||||
end
|
||||
|
||||
Actions:Init()
|
||||
StartPointsLoop()
|
||||
StartServerSyncLoops()
|
||||
NetworkSetLocalPlayerSyncLookAt(true)
|
||||
end)
|
||||
|
||||
local isFirstSpawn = true
|
||||
ESX.SecureNetEvent("esx:onPlayerLogout", function()
|
||||
ESX.PlayerLoaded = false
|
||||
isFirstSpawn = true
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:setMaxWeight", function(newMaxWeight)
|
||||
ESX.SetPlayerData("maxWeight", newMaxWeight)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:setInventory", function(newInventory)
|
||||
ESX.SetPlayerData("inventory", newInventory)
|
||||
end)
|
||||
|
||||
local function onPlayerSpawn()
|
||||
ESX.SetPlayerData("ped", PlayerPedId())
|
||||
ESX.SetPlayerData("dead", false)
|
||||
end
|
||||
|
||||
AddEventHandler("playerSpawned", onPlayerSpawn)
|
||||
AddEventHandler("esx:onPlayerSpawn", function()
|
||||
onPlayerSpawn()
|
||||
|
||||
if isFirstSpawn then
|
||||
isFirstSpawn = false
|
||||
|
||||
if ESX.PlayerData.metadata.health and (ESX.PlayerData.metadata.health > 0 or Config.SaveDeathStatus) then
|
||||
SetEntityHealth(ESX.PlayerData.ped, ESX.PlayerData.metadata.health)
|
||||
end
|
||||
|
||||
if ESX.PlayerData.metadata.armor and ESX.PlayerData.metadata.armor > 0 then
|
||||
SetPedArmour(ESX.PlayerData.ped, ESX.PlayerData.metadata.armor)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:onPlayerDeath", function()
|
||||
ESX.SetPlayerData("ped", PlayerPedId())
|
||||
ESX.SetPlayerData("dead", true)
|
||||
end)
|
||||
|
||||
AddEventHandler("skinchanger:modelLoaded", function()
|
||||
while not ESX.PlayerLoaded do
|
||||
Wait(100)
|
||||
end
|
||||
TriggerEvent("esx:restoreLoadout")
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:restoreLoadout", function()
|
||||
ESX.SetPlayerData("ped", PlayerPedId())
|
||||
|
||||
if not Config.CustomInventory then
|
||||
local ammoTypes = {}
|
||||
RemoveAllPedWeapons(ESX.PlayerData.ped, true)
|
||||
|
||||
for _, v in ipairs(ESX.PlayerData.loadout) do
|
||||
local weaponName = v.name
|
||||
local weaponHash = joaat(weaponName)
|
||||
|
||||
GiveWeaponToPed(ESX.PlayerData.ped, weaponHash, 0, false, false)
|
||||
SetPedWeaponTintIndex(ESX.PlayerData.ped, weaponHash, v.tintIndex)
|
||||
|
||||
local ammoType = GetPedAmmoTypeFromWeapon(ESX.PlayerData.ped, weaponHash)
|
||||
|
||||
for _, v2 in ipairs(v.components) do
|
||||
local componentHash = ESX.GetWeaponComponent(weaponName, v2).hash
|
||||
GiveWeaponComponentToPed(ESX.PlayerData.ped, weaponHash, componentHash)
|
||||
end
|
||||
|
||||
if not ammoTypes[ammoType] then
|
||||
AddAmmoToPed(ESX.PlayerData.ped, weaponHash, v.ammo)
|
||||
ammoTypes[ammoType] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
AddStateBagChangeHandler("VehicleProperties", nil, function(bagName, _, value)
|
||||
if not value then
|
||||
return
|
||||
end
|
||||
|
||||
bagName = bagName:gsub("entity:", "")
|
||||
local netId = tonumber(bagName)
|
||||
if not netId then
|
||||
error("Tried to set vehicle properties with invalid netId")
|
||||
return
|
||||
end
|
||||
|
||||
local tries = 0
|
||||
|
||||
while not NetworkDoesEntityExistWithNetworkId(netId) do
|
||||
Wait(200)
|
||||
tries = tries + 1
|
||||
if tries > 20 then
|
||||
return error(("Invalid entity - ^5%s^7!"):format(netId))
|
||||
end
|
||||
end
|
||||
|
||||
local vehicle = NetToVeh(netId)
|
||||
|
||||
if NetworkGetEntityOwner(vehicle) ~= ESX.playerId then
|
||||
return
|
||||
end
|
||||
|
||||
ESX.Game.SetVehicleProperties(vehicle, value)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:setAccountMoney", function(account)
|
||||
for i = 1, #ESX.PlayerData.accounts do
|
||||
if ESX.PlayerData.accounts[i].name == account.name then
|
||||
ESX.PlayerData.accounts[i] = account
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
ESX.SetPlayerData("accounts", ESX.PlayerData.accounts)
|
||||
end)
|
||||
|
||||
if not Config.CustomInventory then
|
||||
ESX.SecureNetEvent("esx:addInventoryItem", function(item, count, showNotification)
|
||||
for k, v in ipairs(ESX.PlayerData.inventory) do
|
||||
if v.name == item then
|
||||
ESX.UI.ShowInventoryItemNotification(true, v.label, count - v.count)
|
||||
ESX.PlayerData.inventory[k].count = count
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if showNotification then
|
||||
ESX.UI.ShowInventoryItemNotification(true, item, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeInventoryItem", function(item, count, showNotification)
|
||||
for i = 1, #ESX.PlayerData.inventory do
|
||||
if ESX.PlayerData.inventory[i].name == item then
|
||||
ESX.UI.ShowInventoryItemNotification(false, ESX.PlayerData.inventory[i].label, ESX.PlayerData.inventory[i].count - count)
|
||||
ESX.PlayerData.inventory[i].count = count
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if showNotification then
|
||||
ESX.UI.ShowInventoryItemNotification(false, item, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:addLoadoutItem", function(weaponName, weaponLabel, ammo)
|
||||
table.insert(ESX.PlayerData.loadout, {
|
||||
name = weaponName,
|
||||
ammo = ammo,
|
||||
label = weaponLabel,
|
||||
components = {},
|
||||
tintIndex = 0,
|
||||
})
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeLoadoutItem", function(weaponName, weaponLabel)
|
||||
for i = 1, #ESX.PlayerData.loadout do
|
||||
if ESX.PlayerData.loadout[i].name == weaponName then
|
||||
table.remove(ESX.PlayerData.loadout, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:addWeapon", function()
|
||||
error("event ^5'esx:addWeapon'^1 Has Been Removed. Please use ^5xPlayer.addWeapon^1 Instead!")
|
||||
end)
|
||||
|
||||
|
||||
RegisterNetEvent("esx:addWeaponComponent", function()
|
||||
error("event ^5'esx:addWeaponComponent'^1 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^1 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:setWeaponAmmo", function()
|
||||
error("event ^5'esx:setWeaponAmmo'^1 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^1 Instead!")
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:setWeaponTint", function(weapon, weaponTintIndex)
|
||||
SetPedWeaponTintIndex(ESX.PlayerData.ped, joaat(weapon), weaponTintIndex)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:removeWeapon", function()
|
||||
error("event ^5'esx:removeWeapon'^1 Has Been Removed. Please use ^5xPlayer.removeWeapon^1 Instead!")
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeWeaponComponent", function(weapon, weaponComponent)
|
||||
local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash
|
||||
RemoveWeaponComponentFromPed(ESX.PlayerData.ped, joaat(weapon), componentHash)
|
||||
end)
|
||||
end
|
||||
|
||||
ESX.SecureNetEvent("esx:setJob", function(Job)
|
||||
ESX.SetPlayerData("job", Job)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:setGroup", function(group)
|
||||
ESX.SetPlayerData("group", group)
|
||||
end)
|
||||
|
||||
if not Config.CustomInventory then
|
||||
ESX.SecureNetEvent("esx:createPickup", function(pickupId, label, coords, itemType, name, components, tintIndex)
|
||||
local function setObjectProperties(object)
|
||||
SetEntityAsMissionEntity(object, true, false)
|
||||
PlaceObjectOnGroundProperly(object)
|
||||
FreezeEntityPosition(object, true)
|
||||
SetEntityCollision(object, false, true)
|
||||
|
||||
pickups[pickupId] = {
|
||||
obj = object,
|
||||
label = label,
|
||||
inRange = false,
|
||||
coords = coords,
|
||||
}
|
||||
end
|
||||
|
||||
if itemType == "item_weapon" then
|
||||
local weaponHash = joaat(name)
|
||||
ESX.Streaming.RequestWeaponAsset(weaponHash)
|
||||
local pickupObject = CreateWeaponObject(weaponHash, 50, coords.x, coords.y, coords.z, true, 1.0, 0)
|
||||
SetWeaponObjectTintIndex(pickupObject, tintIndex)
|
||||
|
||||
for _, v in ipairs(components) do
|
||||
local component = ESX.GetWeaponComponent(name, v)
|
||||
if component then
|
||||
GiveWeaponComponentToWeaponObject(pickupObject, component.hash)
|
||||
end
|
||||
end
|
||||
|
||||
setObjectProperties(pickupObject)
|
||||
else
|
||||
ESX.Game.SpawnLocalObject("prop_money_bag_01", coords, setObjectProperties)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:createMissingPickups", function(missingPickups)
|
||||
for pickupId, pickup in pairs(missingPickups) do
|
||||
TriggerEvent("esx:createPickup", pickupId, pickup.label, vector3(pickup.coords.x, pickup.coords.y, pickup.coords.z - 1.0), pickup.type, pickup.name, pickup.components, pickup.tintIndex)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
ESX.SecureNetEvent("esx:registerSuggestions", function(registeredCommands)
|
||||
for name, command in pairs(registeredCommands) do
|
||||
if command.suggestion then
|
||||
TriggerEvent("chat:addSuggestion", ("/%s"):format(name), command.suggestion.help, command.suggestion.arguments)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if not Config.CustomInventory then
|
||||
ESX.SecureNetEvent("esx:removePickup", function(pickupId)
|
||||
if pickups[pickupId] and pickups[pickupId].obj then
|
||||
ESX.Game.DeleteObject(pickups[pickupId].obj)
|
||||
pickups[pickupId] = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function StartServerSyncLoops()
|
||||
if Config.CustomInventory then return end
|
||||
|
||||
local currentWeapon = {
|
||||
---@type number
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
hash = `WEAPON_UNARMED`,
|
||||
ammo = 0,
|
||||
}
|
||||
|
||||
local function updateCurrentWeaponAmmo(weaponName)
|
||||
local newAmmo = GetAmmoInPedWeapon(ESX.PlayerData.ped, currentWeapon.hash)
|
||||
|
||||
if newAmmo ~= currentWeapon.ammo then
|
||||
currentWeapon.ammo = newAmmo
|
||||
TriggerServerEvent("esx:updateWeaponAmmo", weaponName, newAmmo)
|
||||
end
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
while ESX.PlayerLoaded do
|
||||
currentWeapon.hash = GetSelectedPedWeapon(ESX.PlayerData.ped)
|
||||
|
||||
if currentWeapon.hash ~= `WEAPON_UNARMED` then
|
||||
local weaponConfig = ESX.GetWeaponFromHash(currentWeapon.hash)
|
||||
|
||||
if weaponConfig then
|
||||
currentWeapon.ammo = GetAmmoInPedWeapon(ESX.PlayerData.ped, currentWeapon.hash)
|
||||
|
||||
while GetSelectedPedWeapon(ESX.PlayerData.ped) == currentWeapon.hash do
|
||||
updateCurrentWeaponAmmo(weaponConfig.name)
|
||||
Wait(1000)
|
||||
end
|
||||
|
||||
updateCurrentWeaponAmmo(weaponConfig.name)
|
||||
end
|
||||
end
|
||||
Wait(250)
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
local PARACHUTE_OPENING <const> = 1
|
||||
local PARACHUTE_OPEN <const> = 2
|
||||
|
||||
while ESX.PlayerLoaded do
|
||||
local parachuteState = GetPedParachuteState(ESX.PlayerData.ped)
|
||||
|
||||
if parachuteState == PARACHUTE_OPENING or parachuteState == PARACHUTE_OPEN then
|
||||
TriggerServerEvent("esx:updateWeaponAmmo", "GADGET_PARACHUTE", 0)
|
||||
|
||||
while GetPedParachuteState(ESX.PlayerData.ped) ~= -1 do Wait(1000) end
|
||||
end
|
||||
Wait(500)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if not Config.CustomInventory then
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local Sleep = 1500
|
||||
local playerCoords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
local _, closestDistance = ESX.Game.GetClosestPlayer(playerCoords)
|
||||
|
||||
for pickupId, pickup in pairs(pickups) do
|
||||
local distance = #(playerCoords - pickup.coords)
|
||||
|
||||
if distance < 5 then
|
||||
Sleep = 0
|
||||
local label = pickup.label
|
||||
|
||||
if distance < 1 then
|
||||
if IsControlJustReleased(0, 38) then
|
||||
if IsPedOnFoot(ESX.PlayerData.ped) and (closestDistance == -1 or closestDistance > 3) and not pickup.inRange then
|
||||
pickup.inRange = true
|
||||
|
||||
local dict, anim = "weapons@first_person@aim_rng@generic@projectile@sticky_bomb@", "plant_floor"
|
||||
ESX.Streaming.RequestAnimDict(dict)
|
||||
TaskPlayAnim(ESX.PlayerData.ped, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
RemoveAnimDict(dict)
|
||||
Wait(1000)
|
||||
|
||||
TriggerServerEvent("esx:onPickup", pickupId)
|
||||
PlaySoundFrontend(-1, "PICK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET", false)
|
||||
end
|
||||
end
|
||||
|
||||
label = ("%s~n~%s"):format(label, TranslateCap("threw_pickup_prompt"))
|
||||
end
|
||||
|
||||
local textCoords = pickup.coords + vector3(0.0, 0.0, 0.25)
|
||||
ESX.Game.Utils.DrawText3D(textCoords, label, 1.2, 1)
|
||||
elseif pickup.inRange then
|
||||
pickup.inRange = false
|
||||
end
|
||||
end
|
||||
Wait(Sleep)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
----- Admin commands from esx_adminplus
|
||||
RegisterNetEvent("esx:tpm", function()
|
||||
local GetEntityCoords = GetEntityCoords
|
||||
local GetGroundZFor_3dCoord = GetGroundZFor_3dCoord
|
||||
local GetFirstBlipInfoId = GetFirstBlipInfoId
|
||||
local DoesBlipExist = DoesBlipExist
|
||||
local DoScreenFadeOut = DoScreenFadeOut
|
||||
local GetBlipInfoIdCoord = GetBlipInfoIdCoord
|
||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
||||
|
||||
ESX.TriggerServerCallback("esx:isUserAdmin", function(admin)
|
||||
if not admin then
|
||||
return
|
||||
end
|
||||
local blipMarker = GetFirstBlipInfoId(8)
|
||||
if not DoesBlipExist(blipMarker) then
|
||||
ESX.ShowNotification(TranslateCap("tpm_nowaypoint"), "error")
|
||||
return "marker"
|
||||
end
|
||||
|
||||
-- Fade screen to hide how clients get teleported.
|
||||
DoScreenFadeOut(650)
|
||||
while not IsScreenFadedOut() do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
local ped, coords = ESX.PlayerData.ped, GetBlipInfoIdCoord(blipMarker)
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
local oldCoords = GetEntityCoords(ped)
|
||||
|
||||
-- Unpack coords instead of having to unpack them while iterating.
|
||||
-- 825.0 seems to be the max a player can reach while 0.0 being the lowest.
|
||||
local x, y, groundZ, Z_START = coords["x"], coords["y"], 850.0, 950.0
|
||||
local found = false
|
||||
FreezeEntityPosition(vehicle > 0 and vehicle or ped, true)
|
||||
|
||||
for i = Z_START, 0, -25.0 do
|
||||
local z = i
|
||||
if (i % 2) ~= 0 then
|
||||
z = Z_START - i
|
||||
end
|
||||
|
||||
NewLoadSceneStart(x, y, z, x, y, z, 50.0, 0)
|
||||
local curTime = GetGameTimer()
|
||||
while IsNetworkLoadingScene() do
|
||||
if GetGameTimer() - curTime > 1000 then
|
||||
break
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
NewLoadSceneStop()
|
||||
SetPedCoordsKeepVehicle(ped, x, y, z)
|
||||
|
||||
while not HasCollisionLoadedAroundEntity(ped) do
|
||||
RequestCollisionAtCoord(x, y, z)
|
||||
if GetGameTimer() - curTime > 1000 then
|
||||
break
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
-- Get ground coord. As mentioned in the natives, this only works if the client is in render distance.
|
||||
found, groundZ = GetGroundZFor_3dCoord(x, y, z, false)
|
||||
if found then
|
||||
Wait(0)
|
||||
SetPedCoordsKeepVehicle(ped, x, y, groundZ)
|
||||
break
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
-- Remove black screen once the loop has ended.
|
||||
DoScreenFadeIn(650)
|
||||
FreezeEntityPosition(vehicle > 0 and vehicle or ped, false)
|
||||
|
||||
if not found then
|
||||
-- If we can't find the coords, set the coords to the old ones.
|
||||
-- We don't unpack them before since they aren't in a loop and only called once.
|
||||
SetPedCoordsKeepVehicle(ped, oldCoords["x"], oldCoords["y"], oldCoords["z"] - 1.0)
|
||||
ESX.ShowNotification(TranslateCap("tpm_success"), "success")
|
||||
end
|
||||
|
||||
-- If Z coord was found, set coords in found coords.
|
||||
SetPedCoordsKeepVehicle(ped, x, y, groundZ)
|
||||
ESX.ShowNotification(TranslateCap("tpm_success"), "success")
|
||||
end)
|
||||
end)
|
||||
|
||||
local noclip = false
|
||||
local noclip_pos = vector3(0, 0, 70)
|
||||
local heading = 0
|
||||
|
||||
local function noclipThread()
|
||||
while noclip do
|
||||
SetEntityCoordsNoOffset(ESX.PlayerData.ped, noclip_pos.x, noclip_pos.y, noclip_pos.z, false, false, true)
|
||||
|
||||
if IsControlPressed(1, 34) then
|
||||
heading = heading + 1.5
|
||||
if heading > 360 then
|
||||
heading = 0
|
||||
end
|
||||
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 9) then
|
||||
heading = heading - 1.5
|
||||
if heading < 0 then
|
||||
heading = 360
|
||||
end
|
||||
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 8) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 32) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 27) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 173) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0)
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx:noclip", function()
|
||||
ESX.TriggerServerCallback("esx:isUserAdmin", function(admin)
|
||||
if not admin then
|
||||
return
|
||||
end
|
||||
|
||||
if not noclip then
|
||||
noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false)
|
||||
heading = GetEntityHeading(ESX.PlayerData.ped)
|
||||
end
|
||||
|
||||
noclip = not noclip
|
||||
if noclip then
|
||||
CreateThread(noclipThread)
|
||||
end
|
||||
|
||||
if noclip then
|
||||
ESX.ShowNotification(TranslateCap("noclip_message", Translate("enabled")), "success")
|
||||
else
|
||||
ESX.ShowNotification(TranslateCap("noclip_message", Translate("disabled")), "error")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:killPlayer", function()
|
||||
SetEntityHealth(ESX.PlayerData.ped, 0)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:repairPedVehicle", function()
|
||||
local ped = ESX.PlayerData.ped
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
SetVehicleEngineHealth(vehicle, 1000)
|
||||
SetVehicleEngineOn(vehicle, true, true, false)
|
||||
SetVehicleFixed(vehicle)
|
||||
SetVehicleDirtLevel(vehicle, 0)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:freezePlayer", function(input)
|
||||
if input == "freeze" then
|
||||
SetEntityCollision(ESX.PlayerData.ped, false, false)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, true)
|
||||
SetPlayerInvincible(ESX.playerId, true)
|
||||
elseif input == "unfreeze" then
|
||||
SetEntityCollision(ESX.PlayerData.ped, true, true)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, false)
|
||||
SetPlayerInvincible(ESX.playerId, false)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterClientCallback("esx:GetVehicleType", function(cb, model)
|
||||
cb(ESX.GetVehicleTypeClient(model))
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent('esx:updatePlayerData', function(key, val)
|
||||
ESX.SetPlayerData(key, val)
|
||||
end)
|
||||
|
||||
---@param command string
|
||||
ESX.SecureNetEvent("esx:executeCommand", function(command)
|
||||
ExecuteCommand(command)
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resource)
|
||||
if Core.Events[resource] then
|
||||
for i = 1, #Core.Events[resource] do
|
||||
RemoveEventHandler(Core.Events[resource][i])
|
||||
end
|
||||
end
|
||||
end)
|
||||
38
resources/[core]/es_extended/client/modules/interactions.lua
Normal file
38
resources/[core]/es_extended/client/modules/interactions.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local interactions = {}
|
||||
local pressedInteractions = {}
|
||||
|
||||
function ESX.RemoveInteraction(name)
|
||||
if not interactions[name] then return end
|
||||
interactions[name] = nil
|
||||
end
|
||||
|
||||
ESX.RegisterInteraction = function(name, onPress, condition)
|
||||
interactions[name] = {
|
||||
condition = condition or function() return true end,
|
||||
onPress = onPress,
|
||||
creator = GetInvokingResource() or "es_extended"
|
||||
}
|
||||
end
|
||||
|
||||
function ESX.GetInteractKey()
|
||||
local hash = joaat('esx_interact') | 0x80000000
|
||||
return GetControlInstructionalButton(0, hash, true):sub(3)
|
||||
end
|
||||
|
||||
ESX.RegisterInput("esx_interact", "Interact", "keyboard", "e", function()
|
||||
for _, interaction in pairs(interactions) do
|
||||
local success, result = pcall(interaction.condition)
|
||||
if success and result then
|
||||
pressedInteractions[#pressedInteractions+1] = interaction
|
||||
interaction.onPress()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resource)
|
||||
for name, interaction in pairs(interactions) do
|
||||
if interaction.creator == resource then
|
||||
interactions[name] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
57
resources/[core]/es_extended/client/modules/npwd.lua
Normal file
57
resources/[core]/es_extended/client/modules/npwd.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
local npwd = GetResourceState("npwd"):find("start") and exports.npwd or nil
|
||||
|
||||
local function checkPhone()
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
local phoneItem <const> = ESX.SearchInventory("phone")
|
||||
npwd:setPhoneDisabled((phoneItem and phoneItem.count or 0) <= 0)
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx:playerLoaded", checkPhone)
|
||||
|
||||
AddEventHandler("onClientResourceStart", function(resource)
|
||||
if resource ~= "npwd" then
|
||||
return
|
||||
end
|
||||
|
||||
npwd = GetResourceState("npwd"):find("start") and exports.npwd or nil
|
||||
|
||||
if ESX.PlayerLoaded then
|
||||
checkPhone()
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler("onClientResourceStop", function(resource)
|
||||
if resource == "npwd" then
|
||||
npwd = nil
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:onPlayerLogout", function()
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
npwd:setPhoneVisible(false)
|
||||
npwd:setPhoneDisabled(true)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeInventoryItem", function(item, count)
|
||||
if not npwd then
|
||||
return
|
||||
end
|
||||
|
||||
if item == "phone" and count == 0 then
|
||||
npwd:setPhoneDisabled(true)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:addInventoryItem", function(item)
|
||||
if not npwd or item ~= "phone" then
|
||||
return
|
||||
end
|
||||
|
||||
npwd:setPhoneDisabled(false)
|
||||
end)
|
||||
54
resources/[core]/es_extended/client/modules/points.lua
Normal file
54
resources/[core]/es_extended/client/modules/points.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
local points = {}
|
||||
|
||||
function ESX.CreatePointInternal(coords, distance, hidden, enter, leave)
|
||||
local point = {
|
||||
coords = coords,
|
||||
distance = distance,
|
||||
hidden = hidden,
|
||||
enter = enter,
|
||||
leave = leave,
|
||||
resource = GetInvokingResource()
|
||||
}
|
||||
local handle = ESX.Table.SizeOf(points) + 1
|
||||
points[handle] = point
|
||||
return handle
|
||||
end
|
||||
|
||||
function ESX.RemovePointInternal(handle)
|
||||
points[handle] = nil
|
||||
end
|
||||
|
||||
function ESX.HidePointInternal(handle, hidden)
|
||||
if points[handle] then
|
||||
points[handle].hidden = hidden
|
||||
end
|
||||
end
|
||||
|
||||
function StartPointsLoop()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local coords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
for handle, point in pairs(points) do
|
||||
if not point.hidden and #(coords - point.coords) <= point.distance then
|
||||
if not point.nearby then
|
||||
points[handle].nearby = true
|
||||
points[handle].enter()
|
||||
end
|
||||
elseif point.nearby then
|
||||
points[handle].nearby = false
|
||||
points[handle].leave()
|
||||
end
|
||||
end
|
||||
Wait(500)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
for handle, point in pairs(points) do
|
||||
if point.resource == resource then
|
||||
points[handle] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
99
resources/[core]/es_extended/client/modules/scaleform.lua
Normal file
99
resources/[core]/es_extended/client/modules/scaleform.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
ESX.Scaleform = {}
|
||||
ESX.Scaleform.Utils = {}
|
||||
|
||||
function ESX.Scaleform.ShowFreemodeMessage(title, msg, sec)
|
||||
local scaleform = ESX.Scaleform.Utils.RunMethod("MP_BIG_MESSAGE_FREEMODE", "SHOW_SHARD_WASTED_MP_MESSAGE", false, title, msg)
|
||||
|
||||
local endTime = GetGameTimer() + (sec * 1000)
|
||||
while GetGameTimer() < endTime do
|
||||
Wait(0)
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
end
|
||||
|
||||
SetScaleformMovieAsNoLongerNeeded(scaleform)
|
||||
end
|
||||
|
||||
function ESX.Scaleform.ShowBreakingNews(title, msg, bottom, sec)
|
||||
local scaleform = ESX.Scaleform.Utils.RunMethod("BREAKING_NEWS", "SET_TEXT", false, msg, bottom)
|
||||
ESX.Scaleform.Utils.RunMethod(scaleform, "SET_SCROLL_TEXT", false, 0, 0, title)
|
||||
ESX.Scaleform.Utils.RunMethod(scaleform, "DISPLAY_SCROLL_TEXT", false, 0, 0)
|
||||
|
||||
local endTime = GetGameTimer() + (sec * 1000)
|
||||
while GetGameTimer() < endTime do
|
||||
Wait(0)
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
end
|
||||
|
||||
SetScaleformMovieAsNoLongerNeeded(scaleform)
|
||||
end
|
||||
|
||||
function ESX.Scaleform.ShowPopupWarning(title, msg, bottom, sec)
|
||||
local scaleform = ESX.Scaleform.Utils.RunMethod("POPUP_WARNING", "SHOW_POPUP_WARNING", false, 500.0, title, msg, bottom, true)
|
||||
|
||||
local endTime = GetGameTimer() + (sec * 1000)
|
||||
while GetGameTimer() < endTime do
|
||||
Wait(0)
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
end
|
||||
|
||||
SetScaleformMovieAsNoLongerNeeded(scaleform)
|
||||
end
|
||||
|
||||
function ESX.Scaleform.ShowTrafficMovie(sec)
|
||||
local scaleform = ESX.Scaleform.Utils.RunMethod("TRAFFIC_CAM", "PLAY_CAM_MOVIE", false)
|
||||
|
||||
local endTime = GetGameTimer() + (sec * 1000)
|
||||
while GetGameTimer() < endTime do
|
||||
Wait(0)
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
end
|
||||
|
||||
SetScaleformMovieAsNoLongerNeeded(scaleform)
|
||||
end
|
||||
|
||||
function ESX.Scaleform.Utils.RequestScaleformMovie(movie)
|
||||
local scaleform = RequestScaleformMovie(movie)
|
||||
|
||||
while not HasScaleformMovieLoaded(scaleform) do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
return scaleform
|
||||
end
|
||||
|
||||
--- Executes a method on a scaleform movie with optional arguments and return value.
|
||||
--- The caller is responsible for disposing of the scaleform using `SetScaleformMovieAsNoLongerNeeded`.
|
||||
---@param scaleform number|string # Scaleform handle or name to request the scaleform movie
|
||||
---@param methodName string # The method name to call on the scaleform
|
||||
---@param returnValue? boolean # Whether to return the value from the method
|
||||
---@param ... number|string|boolean # Arguments to pass to the method
|
||||
---@return number, number? # The scaleform handle, and the return value if `returnValue` is true
|
||||
function ESX.Scaleform.Utils.RunMethod(scaleform, methodName, returnValue, ...)
|
||||
scaleform = type(scaleform) == "number" and scaleform or ESX.Scaleform.Utils.RequestScaleformMovie(scaleform)
|
||||
BeginScaleformMovieMethod(scaleform, methodName)
|
||||
|
||||
local args = { ... }
|
||||
for _, arg in ipairs(args) do
|
||||
local typeArg = type(arg)
|
||||
|
||||
if typeArg == "number" then
|
||||
if math.type(arg) == "float" then
|
||||
ScaleformMovieMethodAddParamFloat(arg)
|
||||
else
|
||||
ScaleformMovieMethodAddParamInt(arg)
|
||||
end
|
||||
elseif typeArg == "string" then
|
||||
ScaleformMovieMethodAddParamTextureNameString(arg)
|
||||
elseif typeArg == "boolean" then
|
||||
ScaleformMovieMethodAddParamBool(arg)
|
||||
end
|
||||
end
|
||||
|
||||
if returnValue then
|
||||
return scaleform, EndScaleformMovieMethodReturnValue()
|
||||
end
|
||||
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
return scaleform
|
||||
end
|
||||
70
resources/[core]/es_extended/client/modules/streaming.lua
Normal file
70
resources/[core]/es_extended/client/modules/streaming.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
ESX.Streaming = {}
|
||||
|
||||
---@param modelHash number | string
|
||||
---@param cb? function
|
||||
---@return number | nil
|
||||
function ESX.Streaming.RequestModel(modelHash, cb)
|
||||
modelHash = type(modelHash) == "number" and modelHash or joaat(modelHash)
|
||||
|
||||
if not IsModelInCdimage(modelHash) then return end
|
||||
|
||||
RequestModel(modelHash)
|
||||
while not HasModelLoaded(modelHash) do Wait(500) end
|
||||
|
||||
return cb and cb(modelHash) or modelHash
|
||||
end
|
||||
|
||||
---@param textureDict string
|
||||
---@param cb? function
|
||||
---@return string | nil
|
||||
function ESX.Streaming.RequestStreamedTextureDict(textureDict, cb)
|
||||
RequestStreamedTextureDict(textureDict, false)
|
||||
|
||||
while not HasStreamedTextureDictLoaded(textureDict) do Wait(500) end
|
||||
|
||||
return cb and cb(textureDict) or textureDict
|
||||
end
|
||||
|
||||
---@param assetName string
|
||||
---@param cb? function
|
||||
---@return string | nil
|
||||
function ESX.Streaming.RequestNamedPtfxAsset(assetName, cb)
|
||||
RequestNamedPtfxAsset(assetName)
|
||||
|
||||
while not HasNamedPtfxAssetLoaded(assetName) do Wait(500) end
|
||||
|
||||
return cb and cb(assetName) or assetName
|
||||
end
|
||||
|
||||
---@param animSet string
|
||||
---@param cb? function
|
||||
---@return string | nil
|
||||
function ESX.Streaming.RequestAnimSet(animSet, cb)
|
||||
RequestAnimSet(animSet)
|
||||
|
||||
while not HasAnimSetLoaded(animSet) do Wait(500) end
|
||||
|
||||
return cb and cb(animSet) or animSet
|
||||
end
|
||||
|
||||
---@param animDict string
|
||||
---@param cb? function
|
||||
---@return string | nil
|
||||
function ESX.Streaming.RequestAnimDict(animDict, cb)
|
||||
RequestAnimDict(animDict)
|
||||
|
||||
while not HasAnimDictLoaded(animDict) do Wait(500) end
|
||||
|
||||
return cb and cb(animDict) or animDict
|
||||
end
|
||||
|
||||
---@param weaponHash number | string
|
||||
---@param cb? function
|
||||
---@return string | number | nil
|
||||
function ESX.Streaming.RequestWeaponAsset(weaponHash, cb)
|
||||
RequestWeaponAsset(weaponHash, 31, 0)
|
||||
|
||||
while not HasWeaponAssetLoaded(weaponHash) do Wait(500) end
|
||||
|
||||
return cb and cb(weaponHash) or weaponHash
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user