Jump to content

[PAWN] Get Started In Creating SA:MP Commands:ZCMD


Dion ibe
 Share

Recommended Posts

*Get Started In Creating SA:MP Commands:ZCMD*
Hello if you have problem here you can find it:
Introduction
This tutorial especially for beginners will help to get started in creating SA:MP commands in an easy way.
I've seen some users who dont understand SA:MP wiki so I thought of helping them a bit,trying my best to help them.
For making commands in an easy method,Im using ZCMD include.
Contents
• Download
• Extracting
• Pawno
• Including
• Creating Command
• Finalising
Download
Inorder to start creating commands,you need Pawno
Q:What Is Pawno?
It is a kind of C Language coding application. It's being used by many multiplayer games including SA-MP.
-------------------------------------------------------------------------
To run Pawno there are some files which is needed so first lets start downloading SA:MP Windows Server package.
The latest version is 3e,so lets download 3e server package.
SA:MP 0.3e Server Package|Download
 
Extracting
After downloading you'll get a (.rar) file which can be extracted using Winrar
After extracting,you'll get many files and folders.
Go to Pawno Folder-->Open pawno.exe
 
Pawno
After opening Pawno,click on New icon.
You'll get many call backs.
As I said,this tutorial is just to create commands,so Im not explaining about the callbacks.
 
Now select all(Ctrl+A) and remove all text.
 
Including
And now its time to include files which is needed to run your script.
Here we need 2 includes.
1) a_samp
2) zcmd
a_samp: a_samp is an include which must be included in every SA:MP scripts.
Without it,no scripts will be working.
zcmd:Zcmd isnt needed in every script,but here we need it inorder to create commands in an easy way and also to execute more faster.
Before including,you must define Filterscript inorder to make this as a filterscript.
Lets define filterscript
Code:
#define FILTERSCRIPT
Now lets first learn how to include.
Before including,you must make sure that you've those includes in Pawno-->Include.
Or else while compiling,you'll get fatal errors and output wont come.
a_samp is available in server package itself.
 
 
After downloading zcmd include,copy the include file and paste it on Pawno-->Include folder.
Now lets start including.
In Pawno language,we're using #include function to include files.
Here's an example:
Code:
#include <including file>
You must also use < > symbols.
NOTE:Before including,you msut define FILTERSCRIPT
 
Lets include our files which are needed to run our script.
NOTE:Always include a_samp before any other includes
Code:
#include <a_samp> //Included a_samp.
#include <zcmd> //Included zcmd.
// and then text after that will disable that line.
i.e: That line wont be based on scripting.
We have now successfully included files.
Creating Command
Here we're using zcmd,so lets create command in zcmd style which is more easy.
Zcmd way:
Code:
CMD:example(playerid,params[])
{
   //Your function here
   return 1;
}
Here cmd means command.
Example stands for the command we're making.
You can change it to what to what type of command you need.
return 1 stands for returning the function we've used and } for closing the bracket which we 've opened before under CMD:example(playerid,params[])
For making commands,you've to use some functions also.
There are many functions in SA:MP,you can get those from herehttp://wiki.sa-mp.com/wiki/Category:Scripting_Functions
Here,lets make a simple command which sends a message to player.
For messaging to player,we're using this function
Code:
SendClientMessage(playerid,color,"message");
Here SendClientMessage is the function which sends a message.
playerid stands for the player who is using that command.
color Stands for the color of the message which should be displayed.
You can get color codes from here:
 
Note:Those are html codes so it contains # symbol.Leave that # and use the code only.
 
message This stands for the message which will be displayed.
NOTE:While messaging a text,you must use " before text and after that text.
Here's an example
 
Code:
SendClientMessage(playerid,0xFF00000,"I used color red here");
Finalising
Here's the command which we're making
Code:
CMD:welcome(playerid,params[])
{
   SendClientMessage(playerid,0xFF0000,"Welcome Command.");
   return 1;
}
Here the command is /welcome.
Now press F5 button and your script will be compiled.
A box will come with your output,if there's no errors/warnings,then you gained success.
If this is a filterscript,the whole script should look like this
Code:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>


CMD:welcome(playerid,params[])
{
   SendClientMessage(playerid,0xFF0000,"Welcome Command.");
   return 1;
}
While compiling,they might ask for a directory where the output should be saved.
Choose a proper directory and save there.
You'll get a (.amx) file as output.
Then you can add the file in Filterscripts folder.
Now,open server.cfg which is consisted in server package.
Open it with notepad.
 
In server.cfg,you will get texts like this:
Code:
echo file config...
port 7777
announce 0
query 1
lan mode 0
rcon_password changeme
hostname SAMP 0.3e Server
gamemode0 grandlarc 1
filterscripts gl_property etc
Etc..etc
Now you must change your rcon password from changeme to any thing else.
Change your hostname to what ever.
And in filterscripts,add your filterscript also.
It must be the name of the output file.
Suppose if you're output is testing.amx,then you must add testing in filterscripts.
 
Here's an example:
Code:
filterscripts testing gl_property easyweapon
Here I've used 3 filterscripts.
After adding a filterscript,give a space and then give the name of next filterscript which you want to add.
Now close server.cfg and save it.
 
Open sampserver.exe
You'll see a box like DOS in which all stuffs will be getting loaded.
Now after all getting loaded,open samp.exe
 
But dont close any thing.
Now add this IP
:7777
 
And you'll get your server in your Favourites list.
Connect to your server and check the command which you've made.
 
Best Of Luck!
 
If you've got any doubts or didnt understand ,please tell me or post here.
Sorry if some thing is wrong/unexplained.
__________________
I don't play at any other SA-MP servers now.Only B-zone, If you see anyone with my name, that's not me. :P
 

 

 

Edited by Cdorsu
Link to comment
Share on other sites

I congrats you for doing the tutorial even I use The Progamming language Pawn it's very hard to make one and explain it.

Pentru a evita spam-ul acest topic va fi :topic_closed:.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.