SA-MP Forums Archive
GetLoadedFilterscriptsCount - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GetLoadedFilterscriptsCount (/showthread.php?tid=651336)



GetLoadedFilterscriptsCount - 2Col - 18.03.2018

I need a function which counts loaded filterscripts. Is there any way to check if filterscript loads/unloads successfully?

OnFilterScriptInit doesn't get called in gamemode.
GetConsoleVarAsString doesn't work as it should.
Also I don't want to do something like this:
Gamemode:
Код:
new gLoadedFilterscripsCount;

forward IncreaseLoadedFilterscriptCount();
public IncreaseLoadedFilterscriptCount()
	gLoadedFilterscripsCount += 1;

forward DecreaseLoadedFilterscriptCount();
public DecreaseLoadedFilterscriptCount()
	gLoadedFilterscripsCount -= 1;

forward GetLoadedFilterscriptsCount();
public GetLoadedFilterscriptsCount()
	return gLoadedFilterscripsCount;
Every filterscript:
Код:
public OnFilterScriptInit()
{
	CallRemoteFunction("IncreaseLoadedFilterscriptCount", "");
	return 1;
}

public OnFilterScriptExit()
{
	CallRemoteFunction("DecreaseLoadedFilterscriptCount", "");
	return 1;
}
Any other ideas? Thanks in advance.


Re: GetLoadedFilterscriptsCount - NaS - 18.03.2018

Without any additional code or plugin it won't be possible (since the console variable only holds the first FS), YSF however has a function which lets you get all loaded Filterscripts (and count them).


Re: GetLoadedFilterscriptsCount - 2Col - 18.03.2018

Quote:
Originally Posted by NaS
Посмотреть сообщение
Without any additional code or plugin it won't be possible (since the console variable only holds the first FS), YSF however has a function which lets you get all loaded Filterscripts (and count them).
Do you have any experience with YSF? Is it stable?


Re: GetLoadedFilterscriptsCount - NaS - 18.03.2018

Quote:
Originally Posted by 2Col
Посмотреть сообщение
Do you have any experience with YSF? Is it stable?
From my experience yes, especially if you only use functions like the one I mentioned (or some other per-player functions). But be aware that it is a memory hacking Plugin, so it probably won't work with new SAMP Versions until it's getting updated.

I personally wouldn't use it only for one function as I'm sure you can achieve it another way, but that's up to you.

You could for example put the example code you have above into an include and include it in every FS. Not a nice solution, but you won't have any dependancies.


Re: GetLoadedFilterscriptsCount - 2Col - 18.03.2018

Quote:
Originally Posted by NaS
Посмотреть сообщение
From my experience yes, especially if you only use functions like the one I mentioned (or some other per-player functions). But be aware that it is a memory hacking Plugin, so it probably won't work with new SAMP Versions until it's getting updated.

I personally wouldn't use it only for one function as I'm sure you can achieve it another way, but that's up to you.

You could for example put the example code you have above into an include and include it in every FS. Not a nice solution, but you won't have any dependancies.
I completely agree with you. I think I'll use YSF for now. Thanks for your help. Let me know if you have any other ideas.