[Tutorial] How to make /pm,/setarmor and /sethealth?
#1

i will learn you how to make alot of CMDS simple for new scripters.

First
Put #include <zcmd> into your includes

Code:
#include <zcmd>
2nd;

Do it
Code:
CMD:pm(playerid, params[])
{
3rd
Do it
Code:
new str[128], str2[128], id, adminstr[128];
   if(sscanf(params,"ds[128]", id, str2)) return SendClientMessage(playerid, red,"USAGE: /pm [id] [message]");
   if(IsPlayerConnected(id))
   {
	   if(id != playerid)
	   {
		   if(DND[id] == 0)
		   {
		   		format(str, sizeof(str),"PM to [%d]%s: %s", id, PlayerName2(id), str2);
		   		SendClientMessage(playerid, yellow, str);
		   		format(str, sizeof(str),"PM from [%d]%s: %s", playerid, PlayerName2(playerid), str2);
		   		SendClientMessage(id, yellow, str);
		   		format(adminstr, sizeof(adminstr),"PM from %s[%d] to %s[%d]: %s", PlayerName2(playerid), playerid, PlayerName2(id), id, str2);
		   		PlayerPlaySound(id,1085,0.0,0.0,0.0);
		   		MessageTo4(grey, adminstr);
		   		LastPm[id] = playerid;
		   }
		   else return SendClientMessage(playerid, red,"That player is in do not disturb mode!");
	   }
	   else return SendClientMessage(playerid, red,"You cannot PM yourself");
   }
   else return SendClientMessage(playerid, red,"Player is not connected");
   return 1;
its /pm to private message someone


another

[code]
#include <zcmd>

Code:
CMD:sethealth(playerid,params[]) {
Add it first of all


Code:
if(PlayerInfo[playerid][Level] >= 3) {
This "3" mean admin lvl 3 if you set it to 0 any player can use it


add it too into this CMD
Code:
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
	    if(isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: 

/sethealth [playerid] [amount]");
		if(strval(tmp2) < 0 || strval(tmp2) > 100 && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "ERROR: Invaild health amount");
		new player1 = strval(tmp), health = strval(tmp2), string[128];
		if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
			CMDMessageToAdmins(playerid,"SETHEALTH");
			format(string, sizeof(string), "You have set \"%s's\" health to '%d", pName(player1), health); SendClientMessage(playerid,blue,string);
			if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your health to '%d'", pName(playerid), health); SendClientMessage(player1,blue,string); }
   			return SetPlayerHealth(player1, health);
	    } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Code:
CMD:setarmour(playerid,params[]) {
	if(PlayerInfo[playerid][Level] >= 3) {	    new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
	    if(isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setarmour [playerid] [amount]");
		if(strval(tmp2) < 0 || strval(tmp2) > 100 && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "ERROR: Invaild health amount");
		new player1 = strval(tmp), armour = strval(tmp2), string[128];
		if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
			CMDMessageToAdmins(playerid,"SETARMOUR");
			format(string, sizeof(string), "You have set \"%s's\" armour to '%d", pName(player1), armour); SendClientMessage(playerid,blue,string);
			if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your armour to '%d'", pName(playerid), armour); SendClientMessage(player1,blue,string); }
   			return SetPlayerArmour(player1, armour);
	    } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
/sethealth and /setarmor for admins only !!

please REP+ Me
Reply
#2

It would be more nice if you write more information and details.

OT :
Quote:
Originally Posted by MichealScript
I will learn you
Seriously??
Reply
#3

All this copy/paste just to get a rep point ?
Reply
#4

he can copy this code and check it good in pawn and he will learn automaticaly

and me was little scripter me was learning by see the scripts in the pawn


Nope not copy but i like to say in every thread "please rep+ me"
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=65567
Reply
#6

can you explain is proplerly?
Reply
#7

Okay sorry i will edit it and explain it good
Reply
#8

Quote:
Originally Posted by doreto
View Post
All this copy/paste just to get a rep point ?
LOL, truth ..

OT : MichealScript, cant you use "I" instead of "me" sometimes?
Reply
#9

Quote:

OT : MichealScript, cant you use "I" instead of "me" sometimes?

"ME" edited it with good explain check it out
Reply
#10

Quote:
Originally Posted by MichealScript
View Post
i will learn you how to make alot of CMDS simple for new scripters.

First

Do it

2nd;

Do it

3rd
Do it
Reply
#11

i won't post tutorial again LOL because me not good in learning
Reply
#12

Ok, now I don't want to sound like I have my head up my ass and can write a better tutorial. But I seriously didn't understand what you were trying to point out in here. Should do what I do in mine, comment comment comment. Example. Here's where I sound like I have my head up my ass. Use this as a guide to better yours =]

https://sampforum.blast.hk/showthread.php?tid=517373
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)