[Tutorial] Basic Filterscript Tutorial
#1

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
Код:
#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
Код:
#include <a_samp> //This includes it into the actual game!
After that we create a "IF" statement This can be done like this
Код:
#if defined FILTERSCRIPT
Now we start to create the actual script. If you wan't a initialization message (When the script loads) use this
Код:
public OnFilterScriptInit()
{
    //Code here Tabbed out to make sure its easily understood
    return 1;
}
Example of this
Код:
public OnFilterScriptInit()
{
	print("\n----------------------------------");
	print(" .........:Tutorial's Are Cool As:...........");
	print("----------------------------------\n");
	return 1;
}
Using that we'll need a exit one.
Код:
public OnFilterScriptExit()
{
    return 1;
}
Now we can create the messages so when the player spawns it displays them.
Код:
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
}
Код:
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.

Код:
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
Код:
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
Код:
SendClientMessageToAll(COLORCODE,"TEXT");
Heres the correct example.
Код:
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.
Код:
#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)
Reply
#2

Good work. Keep it up.
Reply
#3

Quote:
Originally Posted by Socan
Посмотреть сообщение
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.
Reply
#4

Quote:
Originally Posted by RevolutionLite
Посмотреть сообщение
Ok so fist you have to define it as a filterscript
Код:
#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.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
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.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
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.
Reply
#7

Quote:
Originally Posted by RevolutionLite
Посмотреть сообщение
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.
Reply
#8

Quote:
Originally Posted by Gh05t_
Посмотреть сообщение
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.
Reply
#9

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
Reply
#10

Quote:
Originally Posted by [FSaF]Jarno
Посмотреть сообщение
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)