13.03.2011, 22:02
(
Last edited by Rivera; 14/03/2011 at 09:09 AM.
)
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.
That's all for this "chapter"
Defines
Now, for the define, you only need a line!
Now, let me explain that.
These are the two includes that you need. a_samp and sscanf2 (these MUST be in includes folder as an .ini file)
The dcmd include line. That's all for the dcmd define
Color defines. Very helpful!
How to use dcmd
Now, using dcmd is a little "busy". Follow me to a normal /pay cmd.
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):
This was the first cmd: pay. Now, for the second cmd sethealth we will add another line like this:
Where we will put this line? Close to the last one (define line). just like this:
Okay, so now we will make a sethealth cmd (admin only):
Now, if you don't understand this command, just post here OR (better) PM me! Let's end this:
This is our full command. Best wishes from Don!
P.s.: Any questions? Anything that I should post? PM me!
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
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
pawn Code:
#include <a_samp>
#include <sscanf2>
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
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
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!
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!
pawn Code:
dcmd(sethealth, 8, cmdtext); // this is a sethealth include. sethealth has 8 characters, so we put an 8
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
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;
}
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;
}
P.s.: Any questions? Anything that I should post? PM me!