Add a console command "Disconnect"

Sometimes my game dont let me disconnect from the server and i need to quit fiveM to enter another(quit from the console, because the only thing that was working was the console), so I propose have a command in the console “Disconnect” so that players could disconnect without quiting the game when it is bugged!

This can be done by the owners of the server?

Idk xD, like a chat command?

THIS GOES INSIDE A SERVER SCRIPT NOT A CLIENT

RegisterCommand("disconnect", function(source, args, raw)
    local src = source
    DropPlayer(src, "Disconnected")
end, false)

Make sure you call DropPlayer on the serverside of things, otherwise you get an error x)

Oh yeah. I forgot that some people don’t know that I might aswell go ahead and edit that now XD

Disconnection shouldn’t be relied on due to servers that load many random streaming assets that can’t be properly unloaded due to game bugs, however.

1 Like

FiveM only takes like 6 seconds to start. Should just use the “quit” command in console.

Don’t forget to add a check like this:

if src ~= 0 then
-- drop client here
end

otherwise using this in the server console would throw some nice errors.

I forgot the server console can call server commands… Woops :smile:

1 Like

@MM1122 here’s a oldy that could help for what your looking for??

[Release] Quit Command /quit [1.2]