17.05.2014, 09:00
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:
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;
}