Can someone make this stronger?
#1

Hello,

I'm still learning DCMD a bit, and I want to know how to make dcmd command stronger.
With stronger I mean, that you can type a playerid, something like 102 or something.
In this command:

Код:
dcmd_cplayerlabel(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 3)
	{
 		if(params[0] == 0 || params[1] == 0)
	    {
	        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cplayerlabel [playerid] [text] | Attaches a label to a player");
	        return 1;
		}
		new otherplayer = strval(params[0]);
		new str1[256];

		format(str1, sizeof(str1), "There's a label attached to you by an admin. Label: %s", params[1]);

		if(otherplayer == INVALID_PLAYER_ID)
		{
		    SendClientMessage(playerid, COLOR_GREY, "  Bad playerid.");
			return 1;
		}

		PlayerLabel[otherplayer] = Create3DTextLabel(params[1], COLOR_YELLOW, 30.0, 40.0, 50.0, 40.0, 0);
		Attach3DTextLabelToPlayer(PlayerLabel[otherplayer], otherplayer, 0.0, 0.0, 0.7);
		SendClientMessage(otherplayer, COLOR_NICEBLUE, str1);
		SendClientMessage(playerid, COLOR_NICEBLUE, "You attached a label to a player, it will disappear when he / she dies or disconnects.");
	}
	return 1;
}
If I type a invalid playerid, it doesn't say Bad playerid but says that I have attached a
label to it. And if I do (im playerid 0) /cplayerlabel 00 blabla, it says Theres a blabla atachd. Label: 0 blabla,
why the 0 there?

Can someone retype this command but then stronger so I can learn it?

Thank you!
Reply
#2

You must use sscanf / strtok or another function if You want to use more than 1 argument
Reply
#3

I have a better idae, you just read THAT PAGE

And by the way the wiki contains much other useful tutorials and information
Reply
#4

Well yes what Jefff said, if im not wrong what you want is to split your string so it will affect to another player, i suggest you to use sscanf plugin from ******, and look for a tutorial around if you dont understand it, its easy once you know how it works.
Reply
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
I have a better idae, you just read THAT PAGE

And by the way the wiki contains much other useful tutorials and information
Hmm.. I think you can explain me what the "u" is, can I put something else
there too, like "a" or something?

if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"")

Thanks.

Does someone know a good Sscanf tutorial here btw?
Reply
#6

Use ZCMD instead, it's faster then dcmd, and not any harder.
Only thing you really have to do is replace dcmd_ with CMD: once you included ZCMD.inc
Reply
#7

Quote:
Originally Posted by Ihsan-Cingisiz
Посмотреть сообщение
Hmm.. I think you can explain me what the "u" is, can I put something else
there too, like "a" or something?

if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"")

Thanks.

Does someone know a good Sscanf tutorial here btw?
Look at the plugin's thread for a list of the params for sscanf, "u" is for usernames/playerids.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)