script cant count down

hi

this is part of my script , its in server side (server/classes/bt.lua) and its OK

LeavePlayer = function(self, _s, _i, _d)
			self:Ensure(_s, 'number')
			self:Ensure(_i, 'number')
			self:EnsureBattle(_i)
			if self:RemoveFromBattle(_i, _s) then
				EnsureClientEvent('pmc-battleroyale:game:end', _s)
				SetPlayerRoutingBucket(tostring(_s), 0)
				self._BATTLES[_i].playerCount = self._BATTLES[_i].playerCount - 1
				if self._BATTLES[_i].playerCount == 0 then
					self._BATTLES[_i] = nil
				else
					EnsureClientEvent('pmc-battleroyale:client:update:status:playerCount', self:GetPlayersInBattle(_i), self._BATTLES[_i].playerCount, _d and 'died' or 'left' or 'DC' , GetPlayerName(_s), _s)

					if self._BATTLES[_i].playerCount < Config.MinPlayersToStart then
						self._BATTLES[_i].lastNotify = 0
					end
				end
				self:DebugPrint('%s leaved game arena %s', _s, _i)

				EnsureClientEvent('chat:addMessage', -1, {
					template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(100, 0, 1006, 2.4); border-radius: 3px;"><i class="far fa-newspaper"></i> [^8a^2r^8k^2a System] <br>  {1}</div>',
					args = {"ArKa WarZone ", _U("left", GetPlayerName(_s)..(" (%s)"):format(Database:GetPlayerScore(_s).score),_i)}
				})
				TriggerEvent('DiscordBot:ToDiscord', 'warzone',	   'WarZone' , "```css\n" .. GetPlayerName(_s) .. " Left Or Died\n```",'user', source, true, false)

						
				return true
			end
			return false
		end,

but after i want call it from server side i get error

server side cant detect (self._BATTLES) or any self.(any)

OR

i have some code in server.lua

RegisterNetEvent('pmc-battleroyale:leave:game')
AddEventHandler('pmc-battleroyale:leave:game', function(gameIndex, died)
	local source = 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)

OK ? now i want to call it ( this code says :player is out or disconnected , COUNT IT DOWN
but dont work !!!

says , Attemp to call nil value CurrentGame

TriggerServerEvent('pmc-battleroyale:leave:game', CurrentGame.index)

where is my problem ?!

tnx

1 Like

No one ?! any help ?!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.