SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Tutorials (https://forum.sa-mp.com/forumdisplay.php?f=70)
-   -   [Tutorial] Basic Filterscript Tutorial (https://forum.sa-mp.com/showthread.php?t=393781)

RevolutionLite 19/11/2012 08:07 PM

Basic Filterscript Tutorial
 
Well this is my first post and i think players may like it, I don't mind if you don't as i'm quite new to coding in "pwn".

Before doing anything.
1)Load Pawno
2)Press CTRL+N
3)Press CTRL+A
4)Press Delete
5)You're ready!

Ok so fist you have to define it as a filterscript
Code:

#define FILTERSCRIPT //This is a comment, Use it to display the information you need
So now you've defined it you have to include the a_samp
Code:

#include <a_samp> //This includes it into the actual game!
After that we create a "IF" statement This can be done like this
Code:

#if defined FILTERSCRIPT
Now we start to create the actual script. If you wan't a initialization message (When the script loads) use this
Code:

public OnFilterScriptInit()
{
    //Code here Tabbed out to make sure its easily understood
    return 1;
}

Example of this
Code:

public OnFilterScriptInit()
{
        print("\n----------------------------------");
        print(" .........:Tutorial's Are Cool As:...........");
        print("----------------------------------\n");
        return 1;
}

Using that we'll need a exit one.
Code:

public OnFilterScriptExit()
{
    return 1;
}

Now we can create the messages so when the player spawns it displays them.
Code:

public OnPlayerSpawn(playerid) //This will get there playerid on spawn
{
    SendClientMessage(playerid,colour,"message");
    return 1;
 //Thats the basic, to make it better you can actually add multipul entries
}

Code:

public OnPlayerSpawn(playerid)
{
  SendClientMessage(playerid,0xFFFFFF,"Welcome, Type /help or /commands for more info!");
  return 1;
}

Now we're going to do a command input, This will allow the player to type in a command and it's displayed.

Code:

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/info", cmdtext, true) == 0)
        {
        SendClientMessage(playerid,0xFFFFFF,"Creator: Kyle Magix ");
//Thats the base example To expand you can have lots of lines.
}

Heres the proper example
Code:

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/info", cmdtext, true) == 0)
        {
        SendClientMessage(playerid,0xFFFFFF,"Creator: Kyle Magix ");
        SendClientMessage(playerid,0xFFFFFF,"Tested By: You! ");
        SendClientMessage(playerid,0xFFFFFF,"Use /jobhelp to find out how to get a job ");
        }
}

Developing on this you can send a message to all players by using
Code:

SendClientMessageToAll(COLORCODE,"TEXT");
Heres the correct example.
Code:

SendClientMessageToAll(0xFF0000,"This is a tutorial and thanks for viewing it");
at the very end of the script you need a ending statement which can be done by this.
Code:

#endif

Thanks for viewing the tutorial, I hope i helped you. If you have any help you wan't to give me Please post it in the comments,
~Thanks
Kyle_Magix(RevolutionLite)

Socan 19/11/2012 08:09 PM

Re: Basic Filterscript Tutorial
 
Good work. Keep it up.

RevolutionLite 19/11/2012 08:10 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by Socan (Post 2231349)
Good work. Keep it up.

Thanks, I've just started so i hope i helped you. I'm going to try and learn more advanced scripting like gamemodes and ect.

Vince 19/11/2012 08:15 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by RevolutionLite (Post 2231341)
Ok so fist you have to define it as a filterscript
Code:

#define FILTERSCRIPT //This is a comment, Use it to display the information you need

Sigh, I was already expecting this when I first saw the title of this thread. Contrary to popular belief, this macro is NOT needed to code a filterscript. Some include files may rely on it but basically it can be omitted. Better to start from an empty script and to just add the callbacks that you need.

RevolutionLite 19/11/2012 08:18 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by Vince (Post 2231367)
Sigh, I was already expecting this when I first saw the title of this thread. Contrary to popular belief, this macro is NOT needed to code a filterscript. Some include files may rely on it but basically it can be omitted. Better to start from an empty script and to just add the callbacks that you need.

Ah ok well i used a tutorial to write the script i based it off, Which i found quite useful as i'm new to coding for samp. I don't think i'm good or anything at it because in retrospect i'm not. I find it hard to code as i don't understand it that easy, I've tried to code before and i can only code Some Lua, And PWN off tutorials. Basically i'm a complete noob.

RevolutionLite 19/11/2012 10:17 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by ****** (Post 2231560)
Actually, I came in to this thread purely to check that this macro WAS mentioned for exactly the reason you just said - includes rely on it unless they have been coded very well to detect one state or the other.

Anyway, a lot of this tutorial can be sumarised as:

Delete everything.
Rewrite everything you just deleted.

Why not just not delete it in the first place?

Well its just basic so i'll be doing gamemode ones and ect when i learn how but at this moment i'm pretty bad, I don't really understand the tutorials either.

Gh05t_ 19/11/2012 10:39 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by RevolutionLite (Post 2231566)
Well its just basic so i'll be doing gamemode ones and ect when i learn how but at this moment i'm pretty bad, I don't really understand the tutorials either.

WHY would you write a tutorial you know NOTHING about? You're not the first, but it seems people care about gaining recognition rather than taking the time to learn something.

RevolutionLite 20/11/2012 03:30 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by Gh05t_ (Post 2231611)
WHY would you write a tutorial you know NOTHING about? You're not the first, but it seems people care about gaining recognition rather than taking the time to learn something.

I know how to do this, As this is basic. But the harder stuff is creating a Gamemode and ect, I'm not trying to gain Recognition or anything, I just posted it. Yes i know that i don't know a lot. But i'm willing to learn.

[FSaF]Jarno 07/12/2012 08:24 PM

Re: Basic Filterscript Tutorial
 
As everyone else already said, this is probably too basic to post. Looking at your signature, i see:
[Tutorial]Basic FilterScript
[FilterScript]Basic Help And Join
[FilterScript]Clearing Chat
[FilterScript]Admin Broadcast

Basic filterscript: this one (duh)
Basic help and join: probably just sending messages to players when joining and typing /help
Clearing chat: probably just spamming the player's chat full of spaces.
Admin broadcast: i've seen that one, it's just a command to broadcast stuff to players.

The filterscripts are so basic that they should be implemented to a gamemode instead of being a seperate filterscript. There is a maximum of 16 filterscripts to use, and if every function your server has is in a different filterscript you are going to run out of filterscript slots pretty darn soon.

I suggest you first learning, and then posting. I spent something like 6 months learning, exploring and googling about scripting, and then i started to take my server seriously. It grew up to a pretty decent server, and once it was up and running at a nice speed i released 2 filterscripts, my in-game map editor and my somewhat useless ratmachines script.

My point is:
- Learn first, help second
- Don't make seperate filterscripts to have your functions in, at least combine them all to make one big filterscript.
- Don't let this criticism take you down, you might have talent in scripting, not yet tho.

-Jarno

RevolutionLite 07/12/2012 09:53 PM

Re: Basic Filterscript Tutorial
 
Quote:

Originally Posted by [FSaF]Jarno (Post 2259501)
As everyone else already said, this is probably too basic to post. Looking at your signature, i see:
[Tutorial]Basic FilterScript
[FilterScript]Basic Help And Join
[FilterScript]Clearing Chat
[FilterScript]Admin Broadcast

Basic filterscript: this one (duh)
Basic help and join: probably just sending messages to players when joining and typing /help
Clearing chat: probably just spamming the player's chat full of spaces.
Admin broadcast: i've seen that one, it's just a command to broadcast stuff to players.

The filterscripts are so basic that they should be implemented to a gamemode instead of being a seperate filterscript. There is a maximum of 16 filterscripts to use, and if every function your server has is in a different filterscript you are going to run out of filterscript slots pretty darn soon.

I suggest you first learning, and then posting. I spent something like 6 months learning, exploring and googling about scripting, and then i started to take my server seriously. It grew up to a pretty decent server, and once it was up and running at a nice speed i released 2 filterscripts, my in-game map editor and my somewhat useless ratmachines script.

My point is:
- Learn first, help second
- Don't make seperate filterscripts to have your functions in, at least combine them all to make one big filterscript.
- Don't let this criticism take you down, you might have talent in scripting, not yet tho.

-Jarno

Thanks for the feedback, If you could link me to some decent tutorials like gamemode ones that'd be really useful. Most of my commands are going to be moved into my servers gamemode file once i actually find a decent tutorial i can use and base my gamemode off, Otherwise i can't do much as i'm quite new to PAWN scripting, But i know a bit of lua (From minecraft ComputerCraft). I seriously don't let criticism get my down because i know its just to help me become better. As for when i'm older i want to be a IT technician so i'll learn coding/scripting at College and that will help me develop my knowledge even more. As i've said, I'd love for you to actually help me in this, You can PM me and i'll gladly listen. I don't mind wasting some time on scripting and ect. The broadcast command was recently updated so that it has a ClearChat command.

-Kyle


All times are GMT. The time now is 08:16 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.