To get dcmd?
#1

Isn't dcmd a plugin or something? Since I get errors when I try to make a command however I can't find the plugin in the plugin section
Reply
#2

dcmd is a defined function. So it is only 1 neat little line

Код:
#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
Reply
#3


Код:
#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
^^ add that at the top of your script.
(that will define dcmd and understand how you want your command to work)

So some basic Commands..

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(heal, 4, cmdtext);
	return 0;
}
 
dcmd_heal(playerid, params[])
{
	new
		id;
	if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
	else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else
	{
		SetPlayerHealth(id, 100.0);
		SendClientMessage(id, 0x00FF00AA, "You have been healed");
		SendClientMessage(playerid, 0x00FF00AA, "Player healed");
	}
	return 1;
}
^ this uses Scanf by ***** and its from the wiki!

Now when ur making a very basic command like Kill it should be like:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(kill, 4, cmdtext);// we put 4 because kill has 4 letters.
	return 0;
}

dcmd_order(playerid, params[])
{
	#pragma unused params //We have to put that code to note that we arnt using any params, otherwise you'll get a warning!
    SetPlayerHealth(playerid, 100.0);//Restores full health!
	return 1;
}
Hope that helped..
Reply
#4

Or get the zcmd include, it can save you even more lines!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)