Fix typo + add some events

This commit is contained in:
Jérémie N'gadi
2017-09-13 14:48:38 +02:00
parent f34ea3c42f
commit f9936dc41d
2 changed files with 13 additions and 8 deletions
+11 -7
View File
@@ -37,7 +37,7 @@ function CloseInstance()
end end
function EnterInstance(instance) function EnterInstance(instance)
TriggerServerEvent('instance:enter', instance.host) TriggerServerEvent('instance:enter', instance.host)
if RegisteredInstanceTypes[instance.type].enter ~= nil then if RegisteredInstanceTypes[instance.type].enter ~= nil then
@@ -63,8 +63,8 @@ function LeaveInstance()
end end
function InviteToInstance(type, player, pos) function InviteToInstance(type, player, data)
TriggerServerEvent('instance:invite', Instance.host, type, player, pos) TriggerServerEvent('instance:invite', Instance.host, type, player, data)
end end
function RegisterInstanceType(type, enter, exit) function RegisterInstanceType(type, enter, exit)
@@ -94,8 +94,8 @@ AddEventHandler('instance:leave', function()
LeaveInstance() LeaveInstance()
end) end)
AddEventHandler('instance:invite', function(type, player, pos) AddEventHandler('instance:invite', function(type, player, data)
InviteToInstance(type, player, pos) InviteToInstance(type, player, data)
end) end)
AddEventHandler('instance:registerType', function(name, enter, exit) AddEventHandler('instance:registerType', function(name, enter, exit)
@@ -130,13 +130,13 @@ 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)) .. _U('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)) .. _U('left_out')) ShowNotification(GetPlayerName(GetPlayerFromServerId(player)) .. _('left_out'))
end) end)
RegisterNetEvent('instance:onInvite') RegisterNetEvent('instance:onInvite')
@@ -269,3 +269,7 @@ Citizen.CreateThread(function()
end end
end) end)
Citizen.CreateThread(function()
TriggerEvent('instance:loaded')
end)
+2 -1
View File
@@ -23,6 +23,7 @@ function CreateInstance(type, player, data)
data = data data = data
} }
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())
@@ -39,7 +40,7 @@ function CloseInstance(instance)
Instances[instance] = nil Instances[instance] = nil
TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers()) TriggerClientEvent('instance:onInstancedPlayersData', -1, GetInstancedPlayers())
TriggerEvent('instance:onClose', instance)
end end
end end