[Tutorial] How to make commands using Zcmd
#1

Tutorial:
How to make commands using Zcmd.


What is ZCMD?: Zcmd is a easy command processor which allows you to create commands easier.

Requirements:
  • PAWN compiler.
  • Basic PAWN knowledge.
  • ZCMD include downloaded.
Warning: You must have all of the needed requirements before taking a step further into this tutorial.

Requirement Downloads
PAWN Download (Windows) = http://files.sa-mp.com/samp03x_svr_R1-2_win32.zip
PAWN Download (Linux) = http://files.sa-mp.com/samp03xsvr_R1-2.tar.gz (doesn't include PAWNO)
ZCMD Download = http://www.solidfiles.com/d/879d1213...6d464e90c8cf9/

Tutorial Start!
Step 1.
You must open a new fresh script with PAWNO. To start a new script, go to "File", and then click "New".

Step 2.
Now, you must copy & paste the following under the default include which is #include <a_samp>...
Now, paste the following bellow the default include:
pawn Code:
#include <zcmd>
The include "a_samp" defines that the game will want to be loaded using SA-MP, and includes general things. Without a_samp it'd be impossible for the script to function. Now, including zcmd allows us to script commands using ZCMD. Let's continue.

Step 3.
You can press Ctrl + A at the same time, and then press delete to clear the whole script, but I recommend not doing that until you become advanced. So, for now, scroll down to where it says the following:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}
Now, above looks really confusing. "/mycommand" is the text that when someone types that custom, it executes the command, and a effect happens. Above return 1 you can add what you'd want the outcome to be.. Since we're doing ZCMD you're in luck, as we are doing ZCMD... Let's compare strcmp to ZCMD.

ZCMD Command:
pawn Code:
CMD:Greet(playerid, params[])
{
    SendClientMessage(playerid, COLOR_GREEN,"Hello world!");
    return 1;
}
So, basically "Greet" is the command, and if we were to type "/Greet", it'd execute the command which in this case would say "Hello World" to the client who activated the command. The reason it sends the message to the client instead of the whole server is become it says "SendClientMessage".

Step 4.
Let's make a simple "/kill" command!
First of all, load a new script as you did in the first step... After that type the following somewhere random at the bottom of your script:
pawn Code:
CMD:kill(playerid, params[])
{
What does this mean? As explained earlier, "kill" states that the command to execute the action is "/kill". Playerid makes it so that the player who executes the command will be the one effected.

Now, right after the "{" add the following:
pawn Code:
SetPlayerHealth(playerid,0);
What does this mean? SetPlayerHealth sends a command to the database requesting to set the player who executed the command's health. How will they know the number? Because right after "playerid," there is a number; that number tells the database how much to set your health to. Since this is a kill/suicide command, if I were to type "/kill", my HP would be set to 0, and I'd die.

Now after that, enter it.
Copy & Paste the following, and add it onto the line after SetPlayerHealth:
pawn Code:
return 1;
}
At the end, your kill command will look like this:
pawn Code:
CMD:kill(playerid, params[])
{
SetPlayerHealth(playerid,0);
return 1;
}
Reply
#2

Nice tut
Reply
#3

Never mind, fixed my problem
Reply
#4

nice but to know that PAWNO isn't included in the Linux package
Reply
#5

Quote:
Originally Posted by K3
View Post
Nice tut
Thank you!

Quote:
Originally Posted by JonesyFoCoTDM
View Post
Never mind, fixed my problem
Oh, well thanks for reading my tutorial!

Quote:
Originally Posted by kirollos
View Post
nice but to know that PAWNO isn't included in the Linux package
Oh; Woops! Should have viewed the package before adding the link. I'll edit the topic, and say that PAWNO isn't included in Linux package.
Reply
#6

This is a nice tutorial there is a few things you should be alittle bit more explainable about. Besides that I give you props.

1+ from me.
Reply
#7

Quote:
Originally Posted by Akira297
View Post
This is a nice tutorial there is a few things you should be alittle bit more explainable about. Besides that I give you props.

1+ from me.
Thank you very much!
Reply
#8

I Follow you're Commands....

Quote:

Now, you must copy & paste the following under the default include which is #include <a_samp>

and
Quote:

Now, paste the following bellow the default include

Then Last Is
Quote:

#include <zcmd>

This is What I saw
Quote:

:\Program Files\New Folder\pawno\Untitled.pwn( 118 ) : fatal error 100: cannot read from file: "zcmd"

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#9

Quote:
Originally Posted by KimGuan
View Post
I Follow you're Commands....



and

Then Last Is

This is What I saw
You must download the zcmd include.
Reply
#10

I Already Dowloaded It
Reply
#11

Congratulations, DJTunes. A simple one that explained everything in depth.
Reply
#12

Thank you very much.
Reply
#13

Still, strcmp is not a command processor. You should atleast explain what actually params[] returns.
Reply
#14

Thanks this helped me a lot
Reply
#15

Quote:
Originally Posted by Mckarlis
View Post
Thanks this helped me a lot
You're very welcome, mate!

Notice: I've edited the tutorial.
Reply
#16

Nice job!
Reply
#17

Quote:
Originally Posted by Hollywood123
View Post
Nice job!
Thank you very much!
Reply
#18

Quote:
Originally Posted by KimGuan
View Post
I Already Dowloaded It
It should be placed in your pawno/includes folder.

On another note, I think telling people to copy and paste bits of code isn't very helpful. If you reworded it like "Now you will need to add this bit of code to somewhere over there," Then explain why, "We are doing this to tell the game that this is actually this and not this." Then it's not saying "copy paste. copy paste. copy paste." Just a suggestion.
Reply
#19

Quote:
Originally Posted by Aerotactics
View Post
It should be placed in your pawno/includes folder.

On another note, I think telling people to copy and paste bits of code isn't very helpful. If you reworded it like "Now you will need to add this bit of code to somewhere over there," Then explain why, "We are doing this to tell the game that this is actually this and not this." Then it's not saying "copy paste. copy paste. copy paste." Just a suggestion.
It's not just copy and paste.
I put what every line means under the paste.
Reply
#20

And I Run My Server ^_^ try It..but I'm Not Sure If It's portForwarded well..Cause AFter I leave The Server,,my Server Also just Fade Away And IDK How to Fix Them so I Edit the Server.cfg again und again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)