23.04.2012, 16:09
Example, taken from wiki :
That line basically declares the command, it checks the variable cmdtext to see if you typed /heal, the number 4 is the length of the word "heal", the word "heal" (without double quotes) is both the command to type and part of the function to call.
The function dcmd_heal is the command name you entered in the dcmd line with dcmd_ put in front. It has two parameters, the first, playerid, is the player who typed the command, just like OnPlayerCommandText. The second, params[], is the string entered after the command, this is very similar to cmdtext[] but ONLY contains command parameters (or nothing if no parameters were entered, as shown in the example above).
This is all you need to know to use dcmd, most people are put off by the last remaining part, however this was purposefully left to last as you do not need to understand it at all to use it.
pawn Код:
dcmd(heal, 4, cmdtext);
The function dcmd_heal is the command name you entered in the dcmd line with dcmd_ put in front. It has two parameters, the first, playerid, is the player who typed the command, just like OnPlayerCommandText. The second, params[], is the string entered after the command, this is very similar to cmdtext[] but ONLY contains command parameters (or nothing if no parameters were entered, as shown in the example above).
This is all you need to know to use dcmd, most people are put off by the last remaining part, however this was purposefully left to last as you do not need to understand it at all to use it.