fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Restarting current resource within itself results in server crash

Open mythicalbro opened this issue 2 years ago • 2 comments

const currentResourceName = GetCurrentResourceName();

RegisterCommand(`restart:${currentResourceName}`, () => {
  // Works
  //   ExecuteCommand(`restart ${currentResourceName}`);

  // Crashes
  setImmediate(() => ExecuteCommand(`restart ${currentResourceName}`));
});

// Crashes
// setTimeout(() => ExecuteCommand(`restart ${currentResourceName}`), 1e3);

mythicalbro avatar Apr 24 '22 08:04 mythicalbro

This isn't fixable for obvious reasons and there's already logic preventing this for the intended natives such as STOP_RESOURCE.

The best we can do is just prevent a stop/start of a currently-executing resource, but you haven't provided much.. details.

blattersturm avatar Apr 24 '22 11:04 blattersturm

Alright, so I have to add the command to separate resource to fix that. The reason why I need separate command for restarting specific resource is because only players with specific ace permission should be able to restart this specific resource. I don't want to give players permission for restart command as they could restart any resource which should not be restarted.

mythicalbro avatar Apr 24 '22 13:04 mythicalbro