Cant drop a player from the server C#

Using this code

            await Delay(10);
            deferral.update("Checking steamid...");
            var steamid = player.Identifiers["steam"];
            Console.WriteLine(steamid);
            if (steamid == null || steamid.Trim() == "")
            {
                deferral.done("You are not connected to Steam.");
                Console.WriteLine("Couldnt get player steamid, disconnecting");
                player.Drop("You are not connected to Steam.");
                CancelEvent();
                return;
            }
           

It should drop the player to the main menu if they doenst have steam open, the problem is that player.Drop and CancelEvent are not working (or i dont know how to use it)

when you call deferral.done("You are not connected to steam"); it will automatically drop the player so you don’t need to use player.Drop(); or CancelEvent();

Here is a sample in lua

    if not id then
		deferrals.done("Unable to find " .. Settings.identifierUsed .. "ID, please relaunch FiveM with steam open or restart FiveM & steam if steam is already open")
	else
		deferrals.done()		
	end

this will kick the player if the steam id is not present and will let him in if it is.

You could also make use of the setKickReason for example:

setKickReason("Sorry your steam id is not found")

this will kick the player directly
Check this

1 Like