[Tutorial] Full usage of dcmd!
#1

Hey guys! I am new here, but I already know how to use dcmd. In this case, I am going to make my first tutorial. I'll be posting many tutorials in *******, but for now, I hope you enjoy!

What's dcmd?:

dcmd is one of the fastest executing "plugin". The fastest one is zcmd, but dcmd is more professional and doesn't needs downloads. Now, dcmd has a better usage with sscanf. You can download sscanf here:
http://www.sendspace.com/file/4liijz

Now, extract the files, and take the sscanf2 include file, and put it into ...pawno/includes. And the other sscanf file into Plugins folder. Now, open server.cfg and add a line.

Code:
plugins sscanf
That's all for this "chapter"

Defines

Now, for the define, you only need a line!

pawn Code:
#include <a_samp>
#include <sscanf2>

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define COLOR_PINK              0xFFC0CBFF
#define COLOR_RED               0xFF0000FF
#define COLOR_GREEN             0x008000FF
#define COLOR_DARKBLUE          0x00008BFF
#define COLOR_CADETBLUE         0x5F9EA0FF
#define COLOR_LIGHTBLUE         0xADD8E6FF
#define COLOR_YELLOW            0xECD400F6
#define COLOR_LIGHTGREEN        0x90EE90FF
#define COLOR_PEACHPUFF         0xFFDAB9FF
#define LIGHTBLUE2              0xF6BB0AA
#define COLOR_GREY              0x808080FF
#define COLOR_ORANGE            0xFFA500FF
#define COLOR_BISQUE            0xFFE4C4FF
#define COLOR_BLANCHEDALMOND    0xFFEBCDFF
Now, let me explain that.

pawn Code:
#include <a_samp>
#include <sscanf2>
These are the two includes that you need. a_samp and sscanf2 (these MUST be in includes folder as an .ini file)

pawn Code:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
The dcmd include line. That's all for the dcmd define

pawn Code:
#define COLOR_PINK              0xFFC0CBFF
#define COLOR_RED               0xFF0000FF
#define COLOR_GREEN             0x008000FF
#define COLOR_DARKBLUE          0x00008BFF
#define COLOR_CADETBLUE         0x5F9EA0FF
#define COLOR_LIGHTBLUE         0xADD8E6FF
#define COLOR_YELLOW            0xECD400F6
#define COLOR_LIGHTGREEN        0x90EE90FF
#define COLOR_PEACHPUFF         0xFFDAB9FF
#define LIGHTBLUE2              0xF6BB0AA
#define COLOR_GREY              0x808080FF
#define COLOR_ORANGE            0xFFA500FF
#define COLOR_BISQUE            0xFFE4C4FF
#define COLOR_BLANCHEDALMOND    0xFFEBCDFF
Color defines. Very helpful!

How to use dcmd

Now, using dcmd is a little "busy". Follow me to a normal /pay cmd.

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(pay, 3, cmdtext); // this is the format that you will need to use. number 3 is for the characters of the word pay, "p" "a" "y"
    return 1;
}

dcmd_pay(playerid, params[])
{
    new targetid, value;
    if(sscanf(params, "ui", targetid, value)) return SendClientMessage(playerid, COLOR_RED, "ERROR: /pay [playerid] [amount]");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
    else if(value > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "You can't afford that much");
    else
    {
        GivePlayerMoney(targetid, value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You received %i from %u");
        GivePlayerMoney(playerid, 0- value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You transfered %i to %u");
    }
    return 1;
} // these are all the basics. if(sscanf... is the useage of sscanf. check it out!
Now, there is a problem. Many new users make mistakes in using multi cmds with dcmd. Why? Because dcmd it's different from zcmd and it needs some defines (like forward or dcmd())first. Now, let me make a multi command.
We will try the command pay and sethealth(admin cmd):

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(pay, 3, cmdtext); // this is the format that you will need to use. number 3 is for the characters of the word pay, "p" "a" "y"
    return 1;
}

dcmd_pay(playerid, params[])
{
    new targetid, value;
    if(sscanf(params, "ui", targetid, value)) return SendClientMessage(playerid, COLOR_RED, "ERROR: /pay [playerid] [amount]");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
    else if(value > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "You can't afford that much");
    else
    {
        GivePlayerMoney(targetid, value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You received %i from %u");
        GivePlayerMoney(playerid, 0- value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You transfered %i to %u");
    }
    return 1;
} // these are all the basics. if(sscanf... is the useage of sscanf. check it out!
This was the first cmd: pay. Now, for the second cmd sethealth we will add another line like this:

pawn Code:
dcmd(sethealth, 8, cmdtext); // this is a sethealth include. sethealth has 8 characters, so we put an 8
Where we will put this line? Close to the last one (define line). just like this:

pawn Code:
dcmd(pay, 3, cmdtext); // this is the format that you will need to use. number 3 is for the characters of the word pay, "p" "a" "y"
dcmd(sethealth, 8, cmdtext); // this is a sethealth include. sethealth has 8 characters, so we put an 8
Okay, so now we will make a sethealth cmd (admin only):

pawn Code:
dcmd_sethealth(playerid, params[])
{
    new targetid, value;
    if(sscanf(params, "ui", targetid, value)) return SendClientMessage(playerid, COLOR_RED, "ERROR: /sethealth [playerid] [amount]");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
    else if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "You have no access to that command");
    else
    {
        SetPlayerHealth(targetid, value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You succesfuly healed %u");
    }
    return 1;
}
Now, if you don't understand this command, just post here OR (better) PM me! Let's end this:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(pay, 3, cmdtext); // this is the format that you will need to use. number 3 is for the characters of the word pay, "p" "a" "y"
    dcmd(sethealth, 8, cmdtext); // this is a sethealth include. sethealth has 8 characters, so we put an 8
    return 1;
}

dcmd_pay(playerid, params[])
{
    new targetid, value;
    if(sscanf(params, "ui", targetid, value)) return SendClientMessage(playerid, COLOR_RED, "ERROR: /pay [playerid] [amount]");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
    else if(value > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "You can't afford that much");
    else
    {
        GivePlayerMoney(targetid, value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You received %i from %u");
        GivePlayerMoney(playerid, 0- value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You transfered %i to %u");
    }
    return 1;
} // these are all the basics. if(sscanf... is the useage of sscanf. check it out!

dcmd_sethealth(playerid, params[])
{
    new targetid, value;
    if(sscanf(params, "ui", targetid, value)) return SendClientMessage(playerid, COLOR_RED, "ERROR: /sethealth [playerid] [amount]");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
    else if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "You have no access to that command");
    else
    {
        SetPlayerHealth(targetid, value);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You succesfuly healed %u");
    }
    return 1;
}
This is our full command. Best wishes from Don!

P.s.: Any questions? Anything that I should post? PM me!
Reply
#2

dcmd old but good.
Reply
#3

Just a tip, zcmd is not the fastest. YCMD is.
Reply
#4

dcmd isn't necessarily more professional. IMHO, why would you sacrifice speed for a few KB include file? Especially since you already download sscanf plugin and include.
Reply
#5

Quote:
Originally Posted by Snipa
View Post
Just a tip, zcmd is not the fastest. YCMD is.
No, ZCMD is the fastest.. YCMD just has more features.
Reply
#6

Quote:
Originally Posted by ******
View Post
y_commands is actually now FASTER than ZCMD and is designed to handle huge numbers of commands
No it isn't, not completely. ZCMD is faster with a smaller number of commands only. Read that post.
Reply
#7

This is terrible, what exactly did you explain? The only thing that you really explained is WHAT dcmd is, and even then it was filled with false information. When you write tutorials, make sure you do a little bit of research before hand, check to make sure you have your facts right and are using the right terminology (so you dont confuse the newer users, which is who this is targeted for). A good idea when writing tutorials for new users, is to have a new user preview the article. If the new user completely understands the topic you explained, and can actually use what you taught him, then you did a good job.

Article Corrections
DCMD is a preprocessor macro that is used for command processing (Not a plugin. Also you should always mention WHAT its use is when explaining it). DCMD is not viewed as more professional than ZCMD (no idea where you got this), infact i'd say its the complete opposite.
Reply
#8

Quote:
Originally Posted by Kyosaur
View Post
DCMD is not viewed as more professional than ZCMD (no idea where you got this), infact i'd say its the complete opposite.
Beat me to it. Anyone who says that DCMD is better is probably someone who can't figure out how to convert commands from DCMD to ZCMD and scripted a new mode using DCMD. Usage of ZCMD is not only faster than DCMD, it's also more easier to use.
Reply
#9

umm.... wow. so many posts

btw this is my FIRST tutorial, and I have not finished it yet. It was midnight, about 00:30 so I left it in the middle of my work. Greetings! I am going to finish it...

and I just don't care about YCMD ZCMD or anything. I was using ZCMD 'till now, but some guys recommended me dcmd for a couple of reasons. So, who wants to LEARN dcmd like me, post here!!
Reply
#10

Quote:
Originally Posted by Rivera
View Post
umm.... wow. so many posts

btw this is my FIRST tutorial, and I have not finished it yet. It was midnight, about 00:30 so I left it in the middle of my work. Greetings! I am going to finish it...

and I just don't care about YCMD ZCMD or anything. I was using ZCMD 'till now, but some guys recommended me dcmd for a couple of reasons. So, who wants to LEARN dcmd like me, post here!!
You should've finished it and THEN posted it, silly :P. I hope you listen to my advice in my previous posts, i think it'll help you with future tutorials.

You should care, in this world the fastest is the best, and thats for a very good reason. I dont know why you listened to these "guys" as it sounds like they dont know what they're talking about (i'd really like to hear their reasoning tbh). ZCMD is not only faster in terms of execution, but its also fatser/easier in terms of coding (You dont have to put anything in OnPlayerCommandText like dcmd). Providing a tutorial for dcmd is fine, but i think you should consider also making one for the current standard, ZCMD (There are a lot...but there are also a lot of dcmd tutorials).
Reply
#11

'kk. My next tutorial will be about zcmd, and I will make a great one!
Reply
#12

Quote:

'kk. My next tutorial will be about zcmd, and I will make a great one!

https://sampforum.blast.hk/showthread.php?tid=91354
Reply
#13

Nice tutorial 10/10 from me.
Reply
#14

Hmmm... not explaining much

2/10
Reply
#15

Quote:

dcmd is one of the fastest executing "plugin". The fastest one is zcmd, but dcmd is more professiona

I actually lol'd at this. (Sorry)

But I rofl'd at
Quote:

Nice tutorial 10/10 from me.

Reply
#16

thanks tutorial it will help me also anyone ..
Reply
#17

Thank you so much now i understand well, cause of numbers need of words must
Reply
#18

omg wtf are you really going to use dcmd what is total garbage
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)