/setrank command
#1

Hello all. I am asking,can someone make me a command please?

If I type /setrank [id] [rank] (rank can be anything you type)
Then infront of the palyer,the rank whould appear.
For an example:

RaptorX72(0): asd

>
/setrank 0 Owner
>

<Owner>RaptorX72(0):asd
Reply
#2

This can be done with ZCMD & SSCANF. It's recommend that you have a save system
Here's an example of your code should look like.

Код:
CMD:setrank(playerid, params[])
{
	new targetid, rank[50];
	if(sscanf(params, "us", targetid, rank)) return SendClientMessage(playerid, -1, "USAGE: /setrank [id] [rank]");
	{
	    if(!strcmp(rank, "Owner", true))
	    {
	        new s[180];
	        PlayerInfo[playerid][pOwner] = 1; // You can use some kind of saving system to save this
		}
  		if(!strcmp(rank, "AnotherRankHere", true))
	    {
	        new s[180];
	        PlayerInfo[playerid][pAnotherRankHere] = 1; // You can use some kind of saving system to save this
		}
	}
	return 1;
}
After you've edited it to your likings, you should go to OnPlayerText.

Код:
public OnPlayerText(playerid, text[])
{
	if(PlayerInfo[playerid][pOwner] == 1) // Checks to see if the rank of the user is set to "Owner"
	{
	    new s[180];
	    format(s,sizeof(s), "<OWNER> %s: %s", GetName(playerid), text)
								/* GetName is probably not defined in your script, look it up*/
		SendClientMessageToAll(-1, s);
	}
	else
	{
		new s2[180];
		format(s2,sizeof(s2),"%s: %s", GetName(playerid), text)
	}
	return 0; // It should always return 0 if you make changes in OnPlayerText
}
I'm still a newbie myself at scripting, so it could be it won't work. Also please note that I've not tested these commands at all.

I hope I helped you!
Reply
#3

Thanks! But how can I get ZCMD & SSCANF files?
Reply
#4

sscanf: https://sampforum.blast.hk/showthread.php?tid=120356
zcmd: https://sampforum.blast.hk/showthread.php?tid=91354
Reply
#5

Ok,thankyou for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)