[Release] Quit Command /quit [1.2]

Quit Command By FAXES

About
This resources allows a user to do /quit and quit FiveM, basicly the same as through the client console but in chat. This is a server resource and will allow people to run it. This is an extremely basic script and is here to make it easier for people to drag & drop into their servers.

In the Download

__resource.lua
client.lua
server.lua


Requirements
None. This is a standalone script.

Downloads:

Change-Log(s)


Usage
/quit
/disconnect (/dc since version 1.2)

Installation
Place in your resources folder, just like any other resource.

Credits
@Syntasu: for some help

4 Likes

But the client console makes the game actually quit (exit to windows), this doesn’t. It just kicks you from the server and brings you back to the serverlist, or does it actually crash/quit the game?

@FAXES If what @Vespura said is correct (I didn’t download the resource yet) you should rename the command in /leave or /disconnect (just like the client says).

If it does just bring you back to menu, you really wouldn’t be able to rejoin another server or anything either. From what I remember, there are issues with disconnecting and reconnecting to another server without restarting FiveM itself.

True and I just checked, it does bring you back to the serverlist. So this isn’t the same as the console quit command and it doesn’t actually have anything to do with “exiting” the game. So imo I’d change it to something like /disconnect or /leave as that’s what it’s really doing (just like the disconnect option in the pause menu). However @FAXES if you want to make the player actually exit the game like the real quit command you can use this native: ForceSocialClubUpdate().

Quits the game
(20 char)

Does it disconnect for you?

Ok this is very odd. Your code should only “kick” the player, not quit the game. However it DOES in fact exit the game completely. BUT not for the reason you think it does!

Explanation:
After testing I discovered something very interesting. By default, doing /quit in chat doesn’t work because it has the permission for /quit is “denied” by default for the chat resource/the player. However, if you use RegisterCommand('quit', function() end) it re-registers the command with the permission “allowed” for your resource, giving you access to it via the chat. And because it’s the same name, it basically just executes the command and both the client and your resource will try to handle the command. But, because the command is quit and that exits your game, your resource doesn’t even have time to trigger the server event.

TL;DR: Your code inside your registercommand() is never executed! So your server event isn’t executed either and thus you aren’t being kicked. If you don’t believe me, try it out and remove all the code from all your files, and just add this in the client script:

RegisterCommand('quit', function() end)

Then restart the server and type /quit in chat, your game will now exit, without any “kick” code required.

Edit: this is all just a theory, I’m not sure how this works internally but this seems like a plausible explanation to me.

1 Like

Yeah I’ll test some of stuff out. Its strange because for me fiveM closes and does not disconnect. Hmmm

Update 1

  • Fixed issue. It’s now tested with 5 people on 3 different servers and the command should QUIT FiveM. Download in OP

It does quit the game for me, like I said in my previous post; it works, but not because of the way you think it should. If you change the command to something else, you will be kicked but because it’s the same command, it handles it differently and quits the game instead.

What did you change exactly? Because it looks all the same to me. You still have the server files and you still have the code inside the quit register command, even though it’ll never be executed… :thinking:

Its the working copy from my server. So were you saying before if I just had

RegisterCommand('quit', function() end)

in the client.lua that it would still work because of the command name?

Not sure the exact reason why it works, but it does yeah.

Yeah. I’m gonna have a look at some stuff you mentioned in your Explanation post :slight_smile:

Seems as the script says access denied when I do that, so maybe it uses the server.lua somehow.

I’m trying to make a disconnect command to go in it as well, but it either does not work or it quits FiveM. This is code things:

client.lua:

RegisterCommand('dissc', function()
    TriggerServerEvent("dcserver")
end)

TriggerEvent('chat:addSuggestion', '/dc', 'quit FiveM.')
end)

Server.lua

RegisterServerEvent("dcserver")
AddEventHandler("dcserver", function()
	DropPlayer(source, "Test Message")
end)

Update 1.1

  • Added /disconnect. This will exit you to the server list, whereas /quit will quit the game.

Update 1.2

  • Changed /disconnect command to /dc
  • Added chat suggestions (comment it out if you don’t want the suggestions)

Removed Dis cord link as they are no longer allowed :stuck_out_tongue: low-key also just realised I had this release haha.

1 Like

1+ year thread bump. Omg did you just cant believed you just done what you did…

But didn’t actually know this existed so helpful. Thanks :smiley:

Deprecated method of listening for chatMessage for commands.