04.06.2013, 21:21
Hello, SA-MP forums.
I'm hoping there's some way I can cancel a script from loading while it's in OnFilterscriptInit(). I have tried returning 0, but events still trigger, which is the root of my problem.
I want to stop the script from loading in OnFilterscriptInit() if there is no .ini file so that it doesn't call OnDialogResponse, and therefore doesn't crash the server.
Setting a bool:loaded variable and skipping the CallRemoteFunction call is one solution, but it would still load the filterscript, which is what I'm trying to prevent. I was also thinking of doing this:
By exploiting a bug, that would execute "rcon unloadfs [scriptName]", which would unload the FS. But that's a very very bad practice to do, depending on bugs to solve a scripting problem. In addition, the FS would HAVE to be the first one loaded, which I don't want.
Any ideas on how I can get the FS to cancel loading?
I'm hoping there's some way I can cancel a script from loading while it's in OnFilterscriptInit(). I have tried returning 0, but events still trigger, which is the root of my problem.
Код:
new iniString[30];
public OnFilterScriptInit() {
if (!fexist(INI_FILE)) {
print("The .ini file does not exist! Please create it.");
//Returning 0 does not help, the filterscript still loads, ODR still triggers and crashes the server.
//Since the .ini file doesn't load, the "iniString" is empty.
}
}
//Later...
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
if (!CallRemoteFunction(iniString, "i", playerid)) { //Server crashes here because it couldn't load "iniString", which is usually in the (now nonexistant) .ini file
return 0;
}
//Stuff..
}
Setting a bool:loaded variable and skipping the CallRemoteFunction call is one solution, but it would still load the filterscript, which is what I'm trying to prevent. I was also thinking of doing this:
Код:
new scriptName[50], command[63];
GetServerVarAsString("filterscripts", scriptName, sizeof(scriptname));
format(command, sizeof(command), "rcon unloadfs %s", scriptName);
SendRconCommand(command);
Any ideas on how I can get the FS to cancel loading?

