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
+6 -4
View File
@@ -1,6 +1,8 @@
Locales['br'] = {
['left_instance'] = 'Você deixou a instância',
['invite_expired'] = 'Convite expirado',
['press_to_enter'] = 'Pressione ~INPUT_CONTEXT~ para entrar na instância',
['entered_instance'] = 'Você entrou na instância',
['left_instance'] = 'você deixou a instância',
['invite_expired'] = 'convite expirado',
['press_to_enter'] = 'pressione ~INPUT_CONTEXT~ para entrar na instância',
['entered_instance'] = 'você entrou na instância',
['entered_into'] = '%s entered the instance',
['left_out'] = '%s left the instance',
}
+2 -2
View File
@@ -3,6 +3,6 @@ Locales['en'] = {
['invite_expired'] = 'invite expired',
['press_to_enter'] = 'press ~INPUT_CONTEXT~ to enter the instance',
['entered_instance'] = 'you entered the instance',
['entered_into'] = ' entered the instance',
['left_out'] = ' left the instance',
['entered_into'] = '%s entered the instance',
['left_out'] = '%s left the instance',
}
+2 -2
View File
@@ -3,6 +3,6 @@ Locales['fr'] = {
['invite_expired'] = 'invitation expirée',
['press_to_enter'] = 'appuyez sur ~INPUT_CONTEXT~ pour entrer dans l\'instance',
['entered_instance'] = 'vous êtes entré dans l\'instance',
['entered_into'] = ' est entré dans l\'instance',
['left_out'] = ' est sorti dans l\'instance',
['entered_into'] = '%s est entré dans l\'instance',
['left_out'] = '%s est sorti dans l\'instance',
}
+2 -2
View File
@@ -3,6 +3,6 @@ Locales['sv'] = {
['invite_expired'] = 'din inbjudan har nekas',
['press_to_enter'] = 'tryck ~INPUT_CONTEXT~ för att gå in i byggnaden',
['entered_instance'] = 'du är inne i byggnaden',
['entered_into'] = 'du gick in i byggnaden',
['left_out'] = 'du har lämnat byggnaden',
['entered_into'] = '%s gick in i byggnaden',
['left_out'] = '%s har lämnat byggnaden',
}
+70 -80
View File
@@ -1,143 +1,133 @@
local Instances = {}
function GetInstancedPlayers()
local players = {}
local players = {}
for k,v in pairs(Instances) do
for i=1, #v.players, 1 do
table.insert(players, v.players[i])
end
end
return players
for k,v in pairs(Instances) do
for i=1, #v.players, 1 do
table.insert(players, v.players[i])
end
end
return players
end
function CreateInstance(type, player, data)
Instances[player] = {
type = type,
host = player,
players = {},
data = data
}
Instances[player] = {
type = type,
host = player,
players = {},
data = data
}
TriggerEvent('instance:onCreate', Instances[player])
TriggerClientEvent('instance:onCreate', player, Instances[player])
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
TriggerEvent('instance:onCreate', Instances[player])
TriggerClientEvent('instance:onCreate', player, Instances[player])
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
end
function CloseInstance(instance)
if Instances[instance] ~= nil then
if Instances[instance] ~= nil then
for i=1, #Instances[instance].players, 1 do
TriggerClientEvent('instance:onClose', Instances[instance].players[i])
end
for i=1, #Instances[instance].players, 1 do
TriggerClientEvent('instance:onClose', Instances[instance].players[i])
end
Instances[instance] = nil
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
TriggerEvent('instance:onClose', instance)
end
Instances[instance] = nil
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
TriggerEvent('instance:onClose', instance)
end
end
function AddPlayerToInstance(instance, player)
local found = false
local found = false
for i=1, #Instances[instance].players, 1 do
if Instances[instance].players[i] == player then
found = true
break
end
end
for i=1, #Instances[instance].players, 1 do
if Instances[instance].players[i] == player then
found = true
break
end
end
if not found then
table.insert(Instances[instance].players, player)
end
if not found then
table.insert(Instances[instance].players, player)
end
TriggerClientEvent('instance:onEnter', player, Instances[instance])
TriggerClientEvent('instance:onEnter', player, Instances[instance])
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
end
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
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
end
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
end
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
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)
CloseInstance(instance)
else
else
for i=1, #Instances[instance].players, 1 do
if Instances[instance].players[i] == player then
Instances[instance].players[i] = nil
end
end
for i=1, #Instances[instance].players, 1 do
if Instances[instance].players[i] == player then
Instances[instance].players[i] = nil
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
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())
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
end
end
end
end
end
function InvitePlayerToInstance(instance, type, player, data)
TriggerClientEvent('instance:onInvite', player, instance, type, data)
TriggerClientEvent('instance:onInvite', player, instance, type, data)
end
RegisterServerEvent('instance:create')
AddEventHandler('instance:create', function(type, data)
CreateInstance(type, source, data)
CreateInstance(type, source, data)
end)
RegisterServerEvent('instance:close')
AddEventHandler('instance:close', function()
CloseInstance(source)
CloseInstance(source)
end)
RegisterServerEvent('instance:enter')
AddEventHandler('instance:enter', function(instance)
AddPlayerToInstance(instance, source)
AddPlayerToInstance(instance, source)
end)
RegisterServerEvent('instance:leave')
AddEventHandler('instance:leave', function(instance)
RemovePlayerFromInstance(instance, source)
RemovePlayerFromInstance(instance, source)
end)
RegisterServerEvent('instance:invite')
AddEventHandler('instance:invite', function(instance, type, player, data)
InvitePlayerToInstance(instance, type, player, data)
InvitePlayerToInstance(instance, type, player, data)
end)