[Tutorial] [dcmd] Commands
#1

Hello today we are going to learn "Dcmd".


First we start with the #defines.

pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
After we get the Includes and Defines done we can start on the Commands.

Example,
pawn Код:
public OnPlayerCommandText
{
dcmd(kill, 4, cmdtext);
return 1;
}
You always have to do this when you make a new Command.
The 4 is the number of letters in the word "kill" has "4" letters.
And now here's the code

pawn Код:
dcmd_kill(playerid, params[])
{
    #pragma unused params
    new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s Has Died",pName);
    SendClientMessageToAll(0xFFFFFFAA,string);
    SetPlayerHealth(playerid, 0);
    return 1;
}
You are free to use this /kill command.

And that's it for the Tutorial.
If you get any Errors please post here!
Reply
#2

first, take out the part about including a_samp, as dcmd will work fine without it.
second, zcmd is better than dcmd or strcmp, plus it is simpler.
third, your example is choppy it is unclear whether you are putting the dcmd(kill, 4, cmdtext); in OnPlayerCommandText, or if you are just putting OnPlayerCommandText in your script somewhere.
Reply
#3

Could've been better, but I disagree that he should do a tut about ZCMD. As long as the damn'd shit works its fine right?
Reply
#4

Wow You Return 1 under onplayercommandtext?
Reply
#5

@Kar: Didn't even spotted that one, nice find. Returning '1' makes people think your script is bugged up, since it won't return 'Unknown Command'
Reply
#6

Thanks for the feedback guys
Reply
#7

Err, why are you having dual accounts.
Reply
#8

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Err, why are you having dual accounts.
What Does That Mean?
Reply
#9

Well, Luis_Leone and Luis_Geramia. The author is _Leone and as _Germania he says thanks
Reply
#10

wtf lmao like 4 diff emails? just for a forum? L
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)