SA-MP Forums Archive
To get dcmd? - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: To get dcmd? (/showthread.php?tid=156123)



To get dcmd? - oliverrud - 21.06.2010

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


Re: To get dcmd? - ledzep - 21.06.2010

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



Re: To get dcmd? - Lorenc_ - 21.06.2010


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


Re: To get dcmd? - Niixie - 21.06.2010

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