mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
chore(coding-style): correct indentation
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
+12
-16
@@ -3,24 +3,20 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
|||||||
description 'Instance'
|
description 'Instance'
|
||||||
|
|
||||||
server_scripts {
|
server_scripts {
|
||||||
|
'@es_extended/locale.lua',
|
||||||
'@es_extended/locale.lua',
|
'locales/br.lua',
|
||||||
'locales/br.lua',
|
'locales/en.lua',
|
||||||
'locales/en.lua',
|
'locales/fr.lua',
|
||||||
'locales/fr.lua',
|
'config.lua',
|
||||||
'config.lua',
|
'server/main.lua'
|
||||||
'server/main.lua'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
client_scripts {
|
client_scripts {
|
||||||
|
'@es_extended/locale.lua',
|
||||||
'@es_extended/locale.lua',
|
'locales/br.lua',
|
||||||
'locales/br.lua',
|
'locales/en.lua',
|
||||||
'locales/en.lua',
|
'locales/fr.lua',
|
||||||
'locales/fr.lua',
|
'config.lua',
|
||||||
'config.lua',
|
'client/main.lua'
|
||||||
'client/main.lua'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+119
-119
@@ -1,13 +1,13 @@
|
|||||||
local Keys = {
|
local Keys = {
|
||||||
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
|
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
|
||||||
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
|
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
|
||||||
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
|
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
|
||||||
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
|
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
|
||||||
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
|
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
|
||||||
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
|
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
|
||||||
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
|
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
|
||||||
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
|
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
|
||||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
||||||
}
|
}
|
||||||
|
|
||||||
local GUI = {}
|
local GUI = {}
|
||||||
@@ -18,146 +18,146 @@ local InstancedPlayers = {}
|
|||||||
local RegisteredInstanceTypes = {}
|
local RegisteredInstanceTypes = {}
|
||||||
|
|
||||||
function ShowNotification(msg)
|
function ShowNotification(msg)
|
||||||
SetNotificationTextEntry('STRING')
|
SetNotificationTextEntry('STRING')
|
||||||
AddTextComponentString(msg)
|
AddTextComponentString(msg)
|
||||||
DrawNotification(0, 1)
|
DrawNotification(0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetInstance()
|
function GetInstance()
|
||||||
return Instance
|
return Instance
|
||||||
end
|
end
|
||||||
|
|
||||||
function CreateInstance(type, data)
|
function CreateInstance(type, data)
|
||||||
TriggerServerEvent('instance:create', type, data)
|
TriggerServerEvent('instance:create', type, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CloseInstance()
|
function CloseInstance()
|
||||||
Instance = {}
|
Instance = {}
|
||||||
TriggerServerEvent('instance:close')
|
TriggerServerEvent('instance:close')
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnterInstance(instance)
|
function EnterInstance(instance)
|
||||||
|
|
||||||
TriggerServerEvent('instance:enter', instance.host)
|
|
||||||
|
|
||||||
if RegisteredInstanceTypes[instance.type].enter ~= nil then
|
TriggerServerEvent('instance:enter', instance.host)
|
||||||
RegisteredInstanceTypes[instance.type].enter(instance)
|
|
||||||
end
|
if RegisteredInstanceTypes[instance.type].enter ~= nil then
|
||||||
|
RegisteredInstanceTypes[instance.type].enter(instance)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function LeaveInstance()
|
function LeaveInstance()
|
||||||
|
|
||||||
if Instance.host ~= nil then
|
if Instance.host ~= nil then
|
||||||
|
|
||||||
if #Instance.players > 1 then
|
if #Instance.players > 1 then
|
||||||
TriggerEvent('esx:showNotification', _U('left_instance'))
|
TriggerEvent('esx:showNotification', _U('left_instance'))
|
||||||
end
|
end
|
||||||
|
|
||||||
if RegisteredInstanceTypes[Instance.type].exit ~= nil then
|
if RegisteredInstanceTypes[Instance.type].exit ~= nil then
|
||||||
RegisteredInstanceTypes[Instance.type].exit(Instance)
|
RegisteredInstanceTypes[Instance.type].exit(Instance)
|
||||||
end
|
end
|
||||||
|
|
||||||
TriggerServerEvent('instance:leave', Instance.host)
|
TriggerServerEvent('instance:leave', Instance.host)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function InviteToInstance(type, player, data)
|
function InviteToInstance(type, player, data)
|
||||||
TriggerServerEvent('instance:invite', Instance.host, type, player, data)
|
TriggerServerEvent('instance:invite', Instance.host, type, player, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RegisterInstanceType(type, enter, exit)
|
function RegisterInstanceType(type, enter, exit)
|
||||||
RegisteredInstanceTypes[type] = {
|
RegisteredInstanceTypes[type] = {
|
||||||
enter = enter,
|
enter = enter,
|
||||||
exit = exit
|
exit = exit
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('instance:get', function(cb)
|
AddEventHandler('instance:get', function(cb)
|
||||||
cb(GetInstance())
|
cb(GetInstance())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:create', function(type, data)
|
AddEventHandler('instance:create', function(type, data)
|
||||||
CreateInstance(type, data)
|
CreateInstance(type, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:close', function()
|
AddEventHandler('instance:close', function()
|
||||||
CloseInstance()
|
CloseInstance()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:enter', function(instance)
|
AddEventHandler('instance:enter', function(instance)
|
||||||
EnterInstance(instance)
|
EnterInstance(instance)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:leave', function()
|
AddEventHandler('instance:leave', function()
|
||||||
LeaveInstance()
|
LeaveInstance()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:invite', function(type, player, data)
|
AddEventHandler('instance:invite', function(type, player, data)
|
||||||
InviteToInstance(type, player, data)
|
InviteToInstance(type, player, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('instance:registerType', function(name, enter, exit)
|
AddEventHandler('instance:registerType', function(name, enter, exit)
|
||||||
RegisterInstanceType(name, enter, exit)
|
RegisterInstanceType(name, enter, exit)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onInstancedPlayersData')
|
RegisterNetEvent('instance:onInstancedPlayersData')
|
||||||
AddEventHandler('instance:onInstancedPlayersData', function(instancedPlayers)
|
AddEventHandler('instance:onInstancedPlayersData', function(instancedPlayers)
|
||||||
InstancedPlayers = instancedPlayers
|
InstancedPlayers = instancedPlayers
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onCreate')
|
RegisterNetEvent('instance:onCreate')
|
||||||
AddEventHandler('instance:onCreate', function(instance)
|
AddEventHandler('instance:onCreate', function(instance)
|
||||||
Instance = {}
|
Instance = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onEnter')
|
RegisterNetEvent('instance:onEnter')
|
||||||
AddEventHandler('instance:onEnter', function(instance)
|
AddEventHandler('instance:onEnter', function(instance)
|
||||||
Instance = instance
|
Instance = instance
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onLeave')
|
RegisterNetEvent('instance:onLeave')
|
||||||
AddEventHandler('instance:onClose', function(instance)
|
AddEventHandler('instance:onClose', function(instance)
|
||||||
Instance = {}
|
Instance = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onClose')
|
RegisterNetEvent('instance:onClose')
|
||||||
AddEventHandler('instance:onClose', function(instance)
|
AddEventHandler('instance:onClose', function(instance)
|
||||||
Instance = {}
|
Instance = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onPlayerEntered')
|
RegisterNetEvent('instance:onPlayerEntered')
|
||||||
AddEventHandler('instance:onPlayerEntered', function(instance, player)
|
AddEventHandler('instance:onPlayerEntered', function(instance, player)
|
||||||
Instance = instance
|
Instance = instance
|
||||||
ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('entered_into'))
|
ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('entered_into'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onPlayerLeft')
|
RegisterNetEvent('instance:onPlayerLeft')
|
||||||
AddEventHandler('instance:onPlayerLeft', function(instance, player)
|
AddEventHandler('instance:onPlayerLeft', function(instance, player)
|
||||||
Instance = instance
|
Instance = instance
|
||||||
ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('left_out'))
|
ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('left_out'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('instance:onInvite')
|
RegisterNetEvent('instance:onInvite')
|
||||||
AddEventHandler('instance:onInvite', function(instance, type, data)
|
AddEventHandler('instance:onInvite', function(instance, type, data)
|
||||||
|
|
||||||
InstanceInvite = {
|
InstanceInvite = {
|
||||||
type = type,
|
type = type,
|
||||||
host = instance,
|
host = instance,
|
||||||
data = data
|
data = data
|
||||||
}
|
}
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
|
|
||||||
Citizen.Wait(10000)
|
Citizen.Wait(10000)
|
||||||
|
|
||||||
if InstanceInvite ~= nil then
|
if InstanceInvite ~= nil then
|
||||||
ShowNotification(_U('invite_expired'))
|
ShowNotification(_U('invite_expired'))
|
||||||
InstanceInvite = nil
|
InstanceInvite = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -165,111 +165,111 @@ RegisterInstanceType('default')
|
|||||||
|
|
||||||
-- Input invites
|
-- Input invites
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
|
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
if InstanceInvite ~= nil then
|
if InstanceInvite ~= nil then
|
||||||
SetTextComponentFormat('STRING')
|
SetTextComponentFormat('STRING')
|
||||||
AddTextComponentString(_U('press_to_enter'))
|
AddTextComponentString(_U('press_to_enter'))
|
||||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Controls
|
-- Controls
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
|
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
if InstanceInvite ~= nil and IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 150 then
|
if InstanceInvite ~= nil and IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 150 then
|
||||||
|
|
||||||
local playerPed = GetPlayerPed(-1)
|
local playerPed = GetPlayerPed(-1)
|
||||||
|
|
||||||
EnterInstance(InstanceInvite)
|
EnterInstance(InstanceInvite)
|
||||||
|
|
||||||
ShowNotification(_U('entered_instance'))
|
ShowNotification(_U('entered_instance'))
|
||||||
|
|
||||||
InstanceInvite = nil
|
InstanceInvite = nil
|
||||||
GUI.Time = GetGameTimer()
|
GUI.Time = GetGameTimer()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Instance players
|
-- Instance players
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
|
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
if Instance.host ~= nil then
|
if Instance.host ~= nil then
|
||||||
|
|
||||||
local playerPed = GetPlayerPed(-1)
|
local playerPed = GetPlayerPed(-1)
|
||||||
|
|
||||||
for i=0, 32, 1 do
|
for i=0, 32, 1 do
|
||||||
|
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
for j=1, #Instance.players, 1 do
|
for j=1, #Instance.players, 1 do
|
||||||
|
|
||||||
instancePlayer = GetPlayerFromServerId(Instance.players[j])
|
instancePlayer = GetPlayerFromServerId(Instance.players[j])
|
||||||
|
|
||||||
if i == instancePlayer then
|
if i == instancePlayer then
|
||||||
found = true
|
found = true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
|
|
||||||
local otherPlayerPed = GetPlayerPed(i)
|
local otherPlayerPed = GetPlayerPed(i)
|
||||||
|
|
||||||
SetEntityLocallyInvisible(otherPlayerPed)
|
SetEntityLocallyInvisible(otherPlayerPed)
|
||||||
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
|
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
local playerPed = GetPlayerPed(-1)
|
local playerPed = GetPlayerPed(-1)
|
||||||
|
|
||||||
for i=0, 32, 1 do
|
for i=0, 32, 1 do
|
||||||
|
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
for j=1, #InstancedPlayers, 1 do
|
for j=1, #InstancedPlayers, 1 do
|
||||||
|
|
||||||
instancePlayer = GetPlayerFromServerId(InstancedPlayers[j])
|
instancePlayer = GetPlayerFromServerId(InstancedPlayers[j])
|
||||||
|
|
||||||
if i == instancePlayer then
|
if i == instancePlayer then
|
||||||
found = true
|
found = true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if found then
|
if found then
|
||||||
|
|
||||||
local otherPlayerPed = GetPlayerPed(i)
|
local otherPlayerPed = GetPlayerPed(i)
|
||||||
|
|
||||||
SetEntityLocallyInvisible(otherPlayerPed)
|
SetEntityLocallyInvisible(otherPlayerPed)
|
||||||
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
|
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
TriggerEvent('instance:loaded')
|
TriggerEvent('instance:loaded')
|
||||||
end)
|
end)
|
||||||
|
|||||||
+4
-6
@@ -1,8 +1,6 @@
|
|||||||
Locales['br'] = {
|
Locales['br'] = {
|
||||||
|
['left_instance'] = 'Você deixou a instância',
|
||||||
['left_instance'] = 'Você deixou a instância',
|
['invite_expired'] = 'Convite expirado',
|
||||||
['invite_expired'] = 'Convite expirado',
|
['press_to_enter'] = 'Pressione ~INPUT_CONTEXT~ para entrar na instância',
|
||||||
['press_to_enter'] = 'Pressione ~INPUT_CONTEXT~ para entrar na instância',
|
['entered_instance'] = 'Você entrou na instância',
|
||||||
['entered_instance'] = 'Você entrou na instância',
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -1,10 +1,8 @@
|
|||||||
Locales['en'] = {
|
Locales['en'] = {
|
||||||
|
['left_instance'] = 'you have left the instance',
|
||||||
['left_instance'] = 'you have left the instance',
|
['invite_expired'] = 'invite expired',
|
||||||
['invite_expired'] = 'invite expired',
|
['press_to_enter'] = 'press ~INPUT_CONTEXT~ to enter the instance',
|
||||||
['press_to_enter'] = 'press ~INPUT_CONTEXT~ to enter the instance',
|
['entered_instance'] = 'you entered the instance',
|
||||||
['entered_instance'] = 'you entered the instance',
|
['entered_into'] = ' entered the instance',
|
||||||
['entered_into'] = ' entered the instance',
|
['left_out'] = ' left the instance',
|
||||||
['left_out'] = ' left the instance',
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -1,10 +1,8 @@
|
|||||||
Locales['fr'] = {
|
Locales['fr'] = {
|
||||||
|
['left_instance'] = 'vous avez quitté l\'instance',
|
||||||
['left_instance'] = 'vous avez quitté l\'instance',
|
['invite_expired'] = 'invitation expirée',
|
||||||
['invite_expired'] = 'invitation expirée',
|
['press_to_enter'] = 'appuyez sur ~INPUT_CONTEXT~ pour entrer dans l\'instance',
|
||||||
['press_to_enter'] = 'appuyez sur ~INPUT_CONTEXT~ pour entrer dans l\'instance',
|
['entered_instance'] = 'vous êtes entré dans l\'instance',
|
||||||
['entered_instance'] = 'vous êtes entré dans l\'instance',
|
['entered_into'] = ' est entré dans l\'instance',
|
||||||
['entered_into'] = ' est entré dans l\'instance',
|
['left_out'] = ' est sorti dans l\'instance',
|
||||||
['left_out'] = ' est sorti dans l\'instance',
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+74
-74
@@ -2,142 +2,142 @@ local Instances = {}
|
|||||||
|
|
||||||
function GetInstancedPlayers()
|
function GetInstancedPlayers()
|
||||||
|
|
||||||
local players = {}
|
local players = {}
|
||||||
|
|
||||||
for k,v in pairs(Instances) do
|
for k,v in pairs(Instances) do
|
||||||
for i=1, #v.players, 1 do
|
for i=1, #v.players, 1 do
|
||||||
table.insert(players, v.players[i])
|
table.insert(players, v.players[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return players
|
return players
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CreateInstance(type, player, data)
|
function CreateInstance(type, player, data)
|
||||||
|
|
||||||
Instances[player] = {
|
Instances[player] = {
|
||||||
type = type,
|
type = type,
|
||||||
host = player,
|
host = player,
|
||||||
players = {},
|
players = {},
|
||||||
data = data
|
data = data
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerEvent('instance:onCreate', Instances[player])
|
TriggerEvent('instance:onCreate', Instances[player])
|
||||||
TriggerClientEvent('instance:onCreate', player, Instances[player])
|
TriggerClientEvent('instance:onCreate', player, Instances[player])
|
||||||
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CloseInstance(instance)
|
function CloseInstance(instance)
|
||||||
|
|
||||||
if Instances[instance] ~= nil then
|
if Instances[instance] ~= nil then
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
for i=1, #Instances[instance].players, 1 do
|
||||||
TriggerClientEvent('instance:onClose', Instances[instance].players[i])
|
TriggerClientEvent('instance:onClose', Instances[instance].players[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
Instances[instance] = nil
|
Instances[instance] = nil
|
||||||
|
|
||||||
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
||||||
TriggerEvent('instance:onClose', instance)
|
TriggerEvent('instance:onClose', instance)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function AddPlayerToInstance(instance, player)
|
function AddPlayerToInstance(instance, player)
|
||||||
|
|
||||||
local found = false
|
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
local found = false
|
||||||
if Instances[instance].players[i] == player then
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not found then
|
for i=1, #Instances[instance].players, 1 do
|
||||||
table.insert(Instances[instance].players, player)
|
if Instances[instance].players[i] == player then
|
||||||
end
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
TriggerClientEvent('instance:onEnter', player, Instances[instance])
|
if not found then
|
||||||
|
table.insert(Instances[instance].players, player)
|
||||||
|
end
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
TriggerClientEvent('instance:onEnter', player, Instances[instance])
|
||||||
if Instances[instance].players[i] ~= player then
|
|
||||||
TriggerClientEvent('instance:onPlayerEntered', Instances[instance].players[i], Instances[instance], player)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
for i=1, #Instances[instance].players, 1 do
|
||||||
|
if Instances[instance].players[i] ~= player then
|
||||||
|
TriggerClientEvent('instance:onPlayerEntered', Instances[instance].players[i], Instances[instance], player)
|
||||||
|
end
|
||||||
|
|
||||||
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
end
|
||||||
|
|
||||||
|
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function RemovePlayerFromInstance(instance, player)
|
function RemovePlayerFromInstance(instance, player)
|
||||||
|
|
||||||
if Instances[instance] ~= nil then
|
if Instances[instance] ~= nil then
|
||||||
|
|
||||||
TriggerClientEvent('instance:onLeave', player, Instances[instance])
|
TriggerClientEvent('instance:onLeave', player, Instances[instance])
|
||||||
|
|
||||||
if Instances[instance].host == player then
|
if Instances[instance].host == player then
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
|
||||||
if Instances[instance].players[i] ~= player then
|
|
||||||
TriggerClientEvent('instance:onPlayerLeft', Instances[instance].players[i], Instances[instance], player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
CloseInstance(instance)
|
for i=1, #Instances[instance].players, 1 do
|
||||||
|
if Instances[instance].players[i] ~= player then
|
||||||
else
|
TriggerClientEvent('instance:onPlayerLeft', Instances[instance].players[i], Instances[instance], player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
CloseInstance(instance)
|
||||||
if Instances[instance].players[i] == player then
|
|
||||||
Instances[instance].players[i] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1, #Instances[instance].players, 1 do
|
else
|
||||||
if Instances[instance].players[i] ~= player then
|
|
||||||
TriggerClientEvent('instance:onPlayerLeft', Instances[instance].players[i], Instances[instance], player)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
for i=1, #Instances[instance].players, 1 do
|
||||||
|
if Instances[instance].players[i] == player then
|
||||||
|
Instances[instance].players[i] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
for i=1, #Instances[instance].players, 1 do
|
||||||
|
if Instances[instance].players[i] ~= player then
|
||||||
|
TriggerClientEvent('instance:onPlayerLeft', Instances[instance].players[i], Instances[instance], player)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function InvitePlayerToInstance(instance, type, player, data)
|
function InvitePlayerToInstance(instance, type, player, data)
|
||||||
TriggerClientEvent('instance:onInvite', player, instance, type, data)
|
TriggerClientEvent('instance:onInvite', player, instance, type, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterServerEvent('instance:create')
|
RegisterServerEvent('instance:create')
|
||||||
AddEventHandler('instance:create', function(type, data)
|
AddEventHandler('instance:create', function(type, data)
|
||||||
CreateInstance(type, source, data)
|
CreateInstance(type, source, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('instance:close')
|
RegisterServerEvent('instance:close')
|
||||||
AddEventHandler('instance:close', function()
|
AddEventHandler('instance:close', function()
|
||||||
CloseInstance(source)
|
CloseInstance(source)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('instance:enter')
|
RegisterServerEvent('instance:enter')
|
||||||
AddEventHandler('instance:enter', function(instance)
|
AddEventHandler('instance:enter', function(instance)
|
||||||
AddPlayerToInstance(instance, source)
|
AddPlayerToInstance(instance, source)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('instance:leave')
|
RegisterServerEvent('instance:leave')
|
||||||
AddEventHandler('instance:leave', function(instance)
|
AddEventHandler('instance:leave', function(instance)
|
||||||
RemovePlayerFromInstance(instance, source)
|
RemovePlayerFromInstance(instance, source)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('instance:invite')
|
RegisterServerEvent('instance:invite')
|
||||||
AddEventHandler('instance:invite', function(instance, type, player, data)
|
AddEventHandler('instance:invite', function(instance, type, player, data)
|
||||||
InvitePlayerToInstance(instance, type, player, data)
|
InvitePlayerToInstance(instance, type, player, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user