plugins sscanf
#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
#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
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!
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!
dcmd(sethealth, 8, cmdtext); // this is a sethealth include. sethealth has 8 characters, so we put an 8
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
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;
}
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;
}
y_commands is actually now FASTER than ZCMD and is designed to handle huge numbers of commands
|
DCMD is not viewed as more professional than ZCMD (no idea where you got this), infact i'd say its the complete opposite.
|
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!! |
'kk. My next tutorial will be about zcmd, and I will make a great one! |
dcmd is one of the fastest executing "plugin". The fastest one is zcmd, but dcmd is more professiona |
Nice tutorial 10/10 from me. |