Jump to content

remove player on table when quit


freudo

Recommended Posts

Hey,

I have a problem this code working player in server. But no working when player quit.

exitLobby = function(self)
		local previousLobby = getElementData(localPlayer, "player:selectedLobby")
		if previousLobby then 
			if self.lobbies[previousLobby] then 
				for k,v in ipairs(self.lobbies[previousLobby].players) do 
					if v == localPlayer then 
						table.remove(self.lobbies[previousLobby].players, k)
					end
				end
			end
		end 
		setElementData(resourceRoot, "root:lobbies", self.lobbies)
		
		setElementData(localPlayer, "player:selectedLobby", false)
		
		exports["br_notifications"]:addNotification(localization:getText(localPlayer, "lobby-leftInRoom"), "success")
		
	end

 

Link to comment
3 minutes ago, barikat said:

Hey,

I have a problem this code working player in server. But no working when player quit.


exitLobby = function(self)
		local previousLobby = getElementData(localPlayer, "player:selectedLobby")
		if previousLobby then 
			if self.lobbies[previousLobby] then 
				for k,v in ipairs(self.lobbies[previousLobby].players) do 
					if v == localPlayer then 
						table.remove(self.lobbies[previousLobby].players, k)
					end
				end
			end
		end 
		setElementData(resourceRoot, "root:lobbies", self.lobbies)
		
		setElementData(localPlayer, "player:selectedLobby", false)
		
		exports["br_notifications"]:addNotification(localization:getText(localPlayer, "lobby-leftInRoom"), "success")
		
	end

 

debug?

Link to comment

No have any errors. just no removing player when quit.

function leav()

        lobbyInstance:exitLobby()

end

addCommandHandler("leav", leav) -- this is working



function leav()

        lobbyInstance:exitLobby()

end

addEventHandler("onClientPlayerQuit", localPlayer, leav) -- no working..

 

Edited by barikat
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...