A silly question about a filterscript
#1

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
Reply
#2

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;

Reply
#3

Thank you buddy,I really appreciate this!
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)