learning to make filterscript
#1

im new on scripting... so i dont know where to start... anyone can help? where can i start learning to make filterscripts?
Reply
#2

Here And more info by Thedarkjoker94

==================

Go to your server root directory and open pawn folder.
Double click on pawn.exe (Makre sure you RUN IT AS ADMIN always).
Select File menu and click New.
Delete all that CRAP.
Now include a_samp. This file contains all the basic functions and constants that you will need and also includes all the basic files like a_vehicles, a_players, a_sampdb and so on.
All the script files start with OnFilterScriptInit() function.
This is a special function known as callback.
This callback is called when a filterscript is loaded, it is only called inside the filterscript which is starting.
Callbacks are called in the script by the server when something important happens, something closely related to the name of the callback (e.g. OnPlayerSpawn is called when a player spawns). Most callbacks have playerid as a parameter to indicate the player for whom the event occurred however not all do (as some aren’t relevant to a player).
Important: When using these callbacks in a filterscript, make sure you return 1, so it’s available in other filterscripts too. When you don’t return a value or return 0, other callbacks in filterscripts loaded at a later time aren’t executed.
Returning a value doesn’t matter in OnFilterScriptInit and OnFilterScriptExit.
OnPlayerCommandText uses the opposite: 1 is indicating “command found” to all scripts, 0 will show “Unknown Command”.
More about callbacks here.
Let’s analyze this code
pawn Код:
#include <a_samp>
 
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" My First SAMP Script");
    print("--------------------------------------\n");
    return 1;
}
On the first line the a_samp file is included (I’ve talked about it).
Take a look at line 3. You have the keyword public.
What does this mean? It means your function can be run by any other bit of code, or simply it runs when you call it.
Without public this callback will never be executed because the server can’t acces it! It is not public, you can’t run it!
The code enclosed by the brackets will be executed when the function/callback is called.
print is a function that prints a message on the server console and \n adds a new line.
Copy and compile this code in Pawno. Press F6 or click the Compile/Run button (that blue arrow near the Help menu).
Before the compilation process, Pawno will ask you for saving.
Save it as tutorial1.
Now in the pawno directory you have 2 files: tutorial1.pwn (your script file) and tutorial1.amx (the compiled file).
Copy tutorial1.amx in filterscripts folder, located in the server root directory.
Open server.cfg and add your script (only the filename without extension) on the filterscripts line. It should look like this:
filterscripts base gl_actions gl_property gl_realtime gl_mapicon ls_elevator tutorial1
Start your server and you should see this message printed in the console:
————————————–
My First SAMP Script
————————————–
Reply
#3

thanks for helping
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)