guys , i have a warzone script for fivem , everything is ok , like enter battle , exit battle , counting and … you know everything is ok BUT
if player want to disconnect the server OR Close the game (ALT+F4) The source CANT detect that player is not in the battle and wont count as a EXITED player , still count as a live player in battle
SO , in client , i have a OnResourseStop
AddEventHandler("onResourceStop", function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(itemObj) do
ESX.Game.DeleteObject(v)
end
TriggerServerEvent('pmc-battleroyale:leave:game', source)
TriggerEvent('DiscordBot:ToDiscord', 'warzone', 'WarZone' , "```css\n" .. GetPlayerName(PlayerPedId()) .. " ALT+F4\n```",'user', source, true, false)
SetEntityAsMissionEntity(pilot, false, true)
DeleteEntity(pilot)
SetEntityAsMissionEntity(aircraft, false, true)
DeleteEntity(aircraft)
DeleteEntity(parachute)
DeleteEntity(crate)
RemovePickup(pickup)
RemoveBlip(blip)
StopSound(soundID)
ReleaseSoundId(soundID)
for i = 1, #requiredModels do
Wait(0)
SetModelAsNoLongerNeeded(GetHashKey(requiredModels[i]))
end
end
end)
I think that is saying , if anyway player left the battle , SOURCE get STOP for him
but nothing happend !!!
onResourceStop == if the resource is getting stopped. That doesn’t make sence.
Otherwise you can check if player is not in zone anymore, that he is getting stored into the db with “combatlogged” = 1 then use the AddEventHandler server side playerConnecting and check if the players table is combatlogged = 1, if yes, then let him connect, after that, wait until the session is loaded / started for him, after that place a message and teleport him out or give him a warning.
Dear
Thanks for Reply
Can you Please give me code ? u know iam not very professional on LUA
Can you please tell me exactly what i must to do ?! (GIVE ME CODE)
Thanks Bro
EDIT:
Dear i Just need a code what make (IF PLAYER LEFT OR CLOSE FIVEM ,AUTOMATIC REMOVE FROM BATTLE AND COUNT -1)
i dont want if player close the fivem and re connect to server , can play the battle
just want to remove from battle IF player CLOSE THE FIVEM , or DISSCONNECT
RegisterNetEvent('playerDropped')
AddEventHandler('playerDropped', function()
local src = tonumber(source)
if gameIndex ~= nil and tonumber(gameIndex) ~= nil and gameIndex > 0 and not Battleroyale:LeavePlayer(source, gameIndex, died) then
TriggerEvent('DiscordBot:ToDiscord', 'warzone', 'WarZone' , "```css\n" .. GetPlayerName(source) .. " ALT+F4\n```",'user', source, true, false)
end
end)