Why doesn't this small filterscript I made work?
#1

Hi I read through the pawno manuals..

But anyways I am trying to explore with filterscripts, and I cant seem to find out why my filterscript doesn't work. It compiles without errors, it just doesn't work.



#include <a_samp>

#define FILTERSCRIPT

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("tpg");
print("--------------------------------------\n");
return 1;
}

public OnVehicleSpawn(vehicleid)
{
AddVehicleComponent(vehicleid, 1010);
return 1;
}

#endif



I have a feeling it's the "#endif" because when I compiled it earlier it said it expected token "endif". After looking at other peoples filterscripts I didn't see "#endif" in them, so I didn't understand why I needed it. I just put it in there, and that solved the error problem.
Reply
#2

I never use '#define FILTERSCRIPT' because you don't need it. You can take that and the '#if defined' part out and the '#endif' part out too. But the reason it isn't working is because I don't think OnVehicleSpawn gets called when all the cars are created under OnGameModeInit. Once you load your FS, any vehicle that respawns after that should have nos. You could just use a loop though if you wanted all cars in your script to have nos at the beginning.
Reply
#3

Thanks man that helps a lot.

EDIT:

To others that want to use this script, use this instead:

#include <a_samp>

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("tpg");
print("--------------------------------------\n");
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
AddVehicleComponent(vehicleid, 1010);
return 1;
}

Backwardsman97, im a new scripter so I don't know how to loop. Thanks anyways, I got it working flawlessly like this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)