SA-MP Forums Archive
A silly question about a filterscript - 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: A silly question about a filterscript (/showthread.php?tid=513600)



A silly question about a filterscript - geohareas - 17.05.2014

Hey,

I was just wondering,how can i prevent spamming server restarts in order to load the new mappings and then I thought that I could prevent this by making a filterscript including all the maps so I could use the /rcon reloadfs to load it.

Can you give me an example of this filterscript?I am a newbie scripter,I am just testing my scripts,what callbacks may I delete from the new filterscript?(FilterScriptIn,FilterscriptExit)?

Thanks in advance


Re: A silly question about a filterscript - weedxd - 17.05.2014

Quote:
Originally Posted by geohareas
Посмотреть сообщение
Hey,

I was just wondering,how can i prevent spamming server restarts in order to load the new mappings and then I thought that I could prevent this by making a filterscript including all the maps so I could use the /rcon reloadfs to load it.

Can you give me an example of this filterscript?I am a newbie scripter,I am just testing my scripts,what callbacks may I delete from the new filterscript?(FilterScriptIn,FilterscriptExit)?

Thanks in advance
PHP код:
#include <a_samp>
public OnFilterScriptInit() {
//Objects what shold be added put here
   
return 1;
}
public 
OnPlayerConnect(playerid) {
//Objects what are being removed add them here     
 
  
return 1;




Re: A silly question about a filterscript - geohareas - 17.05.2014

Thank you buddy,I really appreciate this!


Re: A silly question about a filterscript - Threshold - 17.05.2014

Actually, it wouldn't work because objects would be destroyed as soon as the player's connected... also, the objects aren't assigned to a variable, so it wouldn't delete them properly.

The correct code would be something like:
pawn Код:
#include <a_samp>

new ServerObject[1000]; //Change '1000' to how many objects your server has. Use as much as you want if you are using a streamer.

public OnFilterScriptInit()
{
    ServerObject[0] = CreateObject(objectid, ... //This is your first object. All of your objects will go here.
    ServerObject[1] = CreateObject(objectid, ... //Second object, notice that the number after ServerObjects increases every line.
    ServerObject[2] = CreateObject(objectid, ... //Because we used '1000' above, the maximum this number can be is 999, 1 less than 1000.

//Continued...

    ServerObject[999] = CreateObject(objectid, ... //This is the highest number you can reach with normal CreateObject lines, but CreateDynamicObject with a streamer will allow you to have as much as you want.
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < sizeof(ServerObject); i++) DestroyObject(ServerObject[i]);
    //This will destroy all objects that were created above. This prevents objects from double-spawning when you reload the filterscript multiple times. Which can result in an eventual server crash.
    return 1;
}