Locale formatting, 4 tab indent

This commit is contained in:
ElPumpo
2018-08-21 20:22:50 +02:00
parent 39c03cb0b6
commit 9db250359a
6 changed files with 199 additions and 220 deletions
+117 -130
View File
@@ -10,8 +10,6 @@ local Keys = {
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
local GUI = {}
GUI.Time = 0
local Instance = {}
local InstanceInvite = nil
local InstancedPlayers = {}
@@ -27,255 +25,243 @@ Citizen.CreateThread(function()
end)
function GetInstance()
return Instance
return Instance
end
function CreateInstance(type, data)
TriggerServerEvent('instance:create', type, data)
TriggerServerEvent('instance:create', type, data)
end
function CloseInstance()
Instance = {}
TriggerServerEvent('instance:close')
InsideInstance = false
Instance = {}
TriggerServerEvent('instance:close')
InsideInstance = false
end
function EnterInstance(instance)
InsideInstance = true
TriggerServerEvent('instance:enter', instance.host)
if RegisteredInstanceTypes[instance.type].enter ~= nil then
RegisteredInstanceTypes[instance.type].enter(instance)
end
InsideInstance = true
TriggerServerEvent('instance:enter', instance.host)
if RegisteredInstanceTypes[instance.type].enter ~= nil then
RegisteredInstanceTypes[instance.type].enter(instance)
end
end
function LeaveInstance()
if Instance.host ~= nil then
if Instance.host ~= nil then
if #Instance.players > 1 then
TriggerEvent('esx:showNotification', _U('left_instance'))
end
if #Instance.players > 1 then
TriggerEvent('esx:showNotification', _U('left_instance'))
end
if RegisteredInstanceTypes[Instance.type].exit ~= nil then
RegisteredInstanceTypes[Instance.type].exit(Instance)
end
if RegisteredInstanceTypes[Instance.type].exit ~= nil then
RegisteredInstanceTypes[Instance.type].exit(Instance)
end
TriggerServerEvent('instance:leave', Instance.host)
end
TriggerServerEvent('instance:leave', Instance.host)
end
InsideInstance = false
InsideInstance = false
end
function InviteToInstance(type, player, data)
TriggerServerEvent('instance:invite', Instance.host, type, player, data)
TriggerServerEvent('instance:invite', Instance.host, type, player, data)
end
function RegisterInstanceType(type, enter, exit)
RegisteredInstanceTypes[type] = {
enter = enter,
exit = exit
}
RegisteredInstanceTypes[type] = {
enter = enter,
exit = exit
}
end
AddEventHandler('instance:get', function(cb)
cb(GetInstance())
cb(GetInstance())
end)
AddEventHandler('instance:create', function(type, data)
CreateInstance(type, data)
CreateInstance(type, data)
end)
AddEventHandler('instance:close', function()
CloseInstance()
CloseInstance()
end)
AddEventHandler('instance:enter', function(instance)
EnterInstance(instance)
EnterInstance(instance)
end)
AddEventHandler('instance:leave', function()
LeaveInstance()
LeaveInstance()
end)
AddEventHandler('instance:invite', function(type, player, data)
InviteToInstance(type, player, data)
InviteToInstance(type, player, data)
end)
AddEventHandler('instance:registerType', function(name, enter, exit)
RegisterInstanceType(name, enter, exit)
RegisterInstanceType(name, enter, exit)
end)
RegisterNetEvent('instance:onInstancedPlayersData')
AddEventHandler('instance:onInstancedPlayersData', function(instancedPlayers)
InstancedPlayers = instancedPlayers
InstancedPlayers = instancedPlayers
end)
RegisterNetEvent('instance:onCreate')
AddEventHandler('instance:onCreate', function(instance)
Instance = {}
Instance = {}
end)
RegisterNetEvent('instance:onEnter')
AddEventHandler('instance:onEnter', function(instance)
Instance = instance
Instance = instance
end)
RegisterNetEvent('instance:onLeave')
AddEventHandler('instance:onClose', function(instance)
Instance = {}
Instance = {}
end)
RegisterNetEvent('instance:onClose')
AddEventHandler('instance:onClose', function(instance)
Instance = {}
Instance = {}
end)
RegisterNetEvent('instance:onPlayerEntered')
AddEventHandler('instance:onPlayerEntered', function(instance, player)
Instance = instance
ESX.ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('entered_into'))
Instance = instance
local playerName = GetPlayerName(GetPlayerFromServerId(player))
ESX.ShowNotification(_('entered_into', playerName))
end)
RegisterNetEvent('instance:onPlayerLeft')
AddEventHandler('instance:onPlayerLeft', function(instance, player)
Instance = instance
ESX.ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('left_out'))
Instance = instance
local playerName = GetPlayerName(GetPlayerFromServerId(player))
ESX.ShowNotification(_('left_out', playerName))
end)
RegisterNetEvent('instance:onInvite')
AddEventHandler('instance:onInvite', function(instance, type, data)
InstanceInvite = {
type = type,
host = instance,
data = data
}
InstanceInvite = {
type = type,
host = instance,
data = data
}
Citizen.CreateThread(function()
Citizen.Wait(10000)
if InstanceInvite ~= nil then
ESX.ShowNotification(_U('invite_expired'))
InstanceInvite = nil
end
end)
Citizen.CreateThread(function()
Citizen.Wait(10000)
if InstanceInvite ~= nil then
ESX.ShowNotification(_U('invite_expired'))
InstanceInvite = nil
end
end)
end)
RegisterInstanceType('default')
-- Input invites
Citizen.CreateThread(function()
while true do
while true do
Citizen.Wait(0)
Citizen.Wait(0)
if InstanceInvite ~= nil then
ESX.ShowHelpNotification(_U('press_to_enter'))
else
Citizen.Wait(500)
end
if InstanceInvite ~= nil then
SetTextComponentFormat('STRING')
AddTextComponentString(_U('press_to_enter'))
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
end
end
end)
-- Controls
Citizen.CreateThread(function()
while true do
while true do
Citizen.Wait(10)
Citizen.Wait(10)
if InstanceInvite ~= nil and IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 150 then
if InstanceInvite ~= nil and IsControlJustReleased(0, Keys['E']) then
local playerPed = PlayerPedId()
local playerPed = GetPlayerPed(-1)
EnterInstance(InstanceInvite)
ESX.ShowNotification(_U('entered_instance'))
InstanceInvite = nil
EnterInstance(InstanceInvite)
elseif InstanceInvite == nil then
Citizen.Wait(500)
end
ESX.ShowNotification(_U('entered_instance'))
InstanceInvite = nil
GUI.Time = GetGameTimer()
end
end
end
end)
-- Instance players
Citizen.CreateThread(function()
while true do
while true do
Citizen.Wait(0)
Citizen.Wait(0)
if Instance.host ~= nil then
if Instance.host ~= nil then
local playerPed = GetPlayerPed(-1)
local playerPed = PlayerPedId()
for i=0, Config.MaxPlayers, 1 do
for i=0, Config.MaxPlayers, 1 do
local found = false
local found = false
for j=1, #Instance.players, 1 do
instancePlayer = GetPlayerFromServerId(Instance.players[j])
for j=1, #Instance.players, 1 do
if i == instancePlayer then
found = true
end
end
instancePlayer = GetPlayerFromServerId(Instance.players[j])
if not found then
local otherPlayerPed = GetPlayerPed(i)
if i == instancePlayer then
found = true
end
SetEntityLocallyInvisible(otherPlayerPed)
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
end
end
end
if not found then
else
local otherPlayerPed = GetPlayerPed(i)
local playerPed = PlayerPedId()
SetEntityLocallyInvisible(otherPlayerPed)
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
end
for i=0, Config.MaxPlayers, 1 do
end
local found = false
for j=1, #InstancedPlayers, 1 do
instancePlayer = GetPlayerFromServerId(InstancedPlayers[j])
else
if i == instancePlayer then
found = true
end
end
local playerPed = GetPlayerPed(-1)
if found then
local otherPlayerPed = GetPlayerPed(i)
for i=0, Config.MaxPlayers, 1 do
SetEntityLocallyInvisible(otherPlayerPed)
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
end
local found = false
end
for j=1, #InstancedPlayers, 1 do
end
instancePlayer = GetPlayerFromServerId(InstancedPlayers[j])
if i == instancePlayer then
found = true
end
end
if found then
local otherPlayerPed = GetPlayerPed(i)
SetEntityLocallyInvisible(otherPlayerPed)
SetEntityNoCollisionEntity(playerPed, otherPlayerPed, true)
end
end
end
end
end
end)
Citizen.CreateThread(function()
TriggerEvent('instance:loaded')
TriggerEvent('instance:loaded')
end)
-- Fix vehicles randomly spawning nearby the player inside an instance
@@ -283,11 +269,12 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(0) -- must be run every frame
if InsideInstance then
if InsideInstance then
SetVehicleDensityMultiplierThisFrame(0.0)
SetParkedVehicleDensityMultiplierThisFrame(0.0)
local pos = GetEntityCoords(GetPlayerPed(-1))
RemoveVehiclesFromGeneratorsInArea(pos.x - 900.0, pos.y - 900.0, pos.z - 900.0, pos.x + 900.0, pos.y + 900.0, pos.z + 900.0);
local pos = GetEntityCoords(PlayerPedId())
RemoveVehiclesFromGeneratorsInArea(pos.x - 900.0, pos.y - 900.0, pos.z - 900.0, pos.x + 900.0, pos.y + 900.0, pos.z + 900.0)
else
Citizen.Wait(5000)
end