SA-MP Forums Archive
[Tutorial] [dcmd] Commands - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [dcmd] Commands (/showthread.php?tid=165229)



[dcmd] Commands - Luis_Leone - 04.08.2010

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!


Re: [dcmd] Commands - Daren_Jacobson - 04.08.2010

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.


Re: [dcmd] Commands - Hiddos - 04.08.2010

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?


Re: [dcmd] Commands - Kar - 04.08.2010

Wow You Return 1 under onplayercommandtext?


Re: [dcmd] Commands - Hiddos - 04.08.2010

@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'


Re: [dcmd] Commands - Luis- - 05.08.2010

Thanks for the feedback guys


Re: [dcmd] Commands - Hiddos - 05.08.2010

Err, why are you having dual accounts.


Re: [dcmd] Commands - Kar - 05.08.2010

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


Re: [dcmd] Commands - Hiddos - 05.08.2010

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


Re: [dcmd] Commands - Kar - 05.08.2010

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