[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


Messages In This Thread
How to make commands using Zcmd - by DJTunes - 26.06.2013, 03:43
Re: How to make commands using Zcmd - by K3 - 28.06.2013, 06:53
Re: How to make commands using Zcmd - by JonesyFoCoTDM - 28.06.2013, 16:23
Re: How to make commands using Zcmd - by Kirollos - 28.06.2013, 16:29
Re: How to make commands using Zcmd - by DJTunes - 02.07.2013, 00:15
Re: How to make commands using Zcmd - by Akira297 - 02.07.2013, 00:18
Re: How to make commands using Zcmd - by DJTunes - 02.07.2013, 00:27
Re: How to make commands using Zcmd - by KimGuan - 02.07.2013, 03:53
Re: How to make commands using Zcmd - by Akira297 - 02.07.2013, 03:54
Re: How to make commands using Zcmd - by KimGuan - 02.07.2013, 08:43
Re: How to make commands using Zcmd - by Twizted - 02.07.2013, 08:46
Re: How to make commands using Zcmd - by DJTunes - 03.07.2013, 01:38
Re: How to make commands using Zcmd - by BigETI - 03.07.2013, 09:58
Re: How to make commands using Zcmd - by Mckarlis - 03.07.2013, 13:05
Re: How to make commands using Zcmd - by DJTunes - 03.07.2013, 15:29
Re: How to make commands using Zcmd - by Hollywood123 - 06.07.2013, 03:39
Re: How to make commands using Zcmd - by DJTunes - 06.07.2013, 18:06
Re: How to make commands using Zcmd - by Aerotactics - 06.07.2013, 18:59
Re: How to make commands using Zcmd - by DJTunes - 07.07.2013, 03:22
Re: How to make commands using Zcmd - by KimGuan - 23.07.2013, 10:55

Forum Jump:


Users browsing this thread: 1 Guest(s)