SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 19/11/2012, 08:07 PM   #1
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default 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)
RevolutionLite is offline   Reply With Quote
Old 19/11/2012, 08:09 PM   #2
Socan
Huge Clucker
 
Socan's Avatar
 
Join Date: May 2012
Location: Australia
Posts: 223
Reputation: 23
Default Re: Basic Filterscript Tutorial

Good work. Keep it up.
__________________
SHUT UP AND ENJOY THE MUSIC
╭∩╮(︶︿︶)╭∩╮


Socan is offline   Reply With Quote
Old 19/11/2012, 08:10 PM   #3
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by Socan View Post
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.
RevolutionLite is offline   Reply With Quote
Old 19/11/2012, 08:15 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,089
Reputation: 2655
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by RevolutionLite View Post
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.
__________________
Vince is offline   Reply With Quote
Old 19/11/2012, 08:18 PM   #5
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by Vince View Post
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 is offline   Reply With Quote
Old 19/11/2012, 10:17 PM   #6
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by ****** View Post
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.
RevolutionLite is offline   Reply With Quote
Old 19/11/2012, 10:39 PM   #7
Gh05t_
Big Clucker
 
Gh05t_'s Avatar
 
Join Date: Dec 2011
Posts: 192
Reputation: 140
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by RevolutionLite View Post
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.
Gh05t_ is offline   Reply With Quote
Old 20/11/2012, 03:30 PM   #8
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by Gh05t_ View Post
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.
RevolutionLite is offline   Reply With Quote
Old 07/12/2012, 08:24 PM   #9
[FSaF]Jarno
Huge Clucker
 
[FSaF]Jarno's Avatar
 
Join Date: May 2011
Location: Oulu, Finland
Posts: 339
Reputation: 25
Default 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
[FSaF]Jarno is offline   Reply With Quote
Old 07/12/2012, 09:53 PM   #10
RevolutionLite
Little Clucker
 
Join Date: Nov 2012
Location: Born and raised, on a playground is where i spent most of my days
Posts: 37
Reputation: 3
Default Re: Basic Filterscript Tutorial

Quote:
Originally Posted by [FSaF]Jarno View Post
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
RevolutionLite is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] Basic MySQL Tutorial Faraday Help Archive 43 03/06/2011 01:55 PM
[Tutorial] Simple basic tutorial with name & vehicleid DarkClone Tutorials 11 20/03/2011 08:25 AM
[FilterScript] Basic Registration Filterscript case 1337: Filterscripts 7 14/01/2011 11:09 AM
[FilterScript] [FS]Basic Fuel Filterscript Pixels^ Filterscripts 21 08/04/2010 11:00 AM


All times are GMT. The time now is 12:47 AM.


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