Admin say problem
#1

Hello everybody , i need some help for this command , there is no errors or warnings , it's just not working in game ,
When i type , for example /asay Hey , it shows /asay [text]

Here's the code

PHP код:
if(!strcmp(cmd"/asay"))
  {
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
  new 
text[128];
  if(
sscanf(params"s[128]",text)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /asay [text]");
  new 
string[128];
  new 
pName[128];
  
GetPlayerName(playerid,pName,128);
  
format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
  
SendClientMessageToAll(0xA10000AA,string);
  return 
1;

Thanks !!
Reply
#2

Use dcmd/zcmd.
Reply
#3

Tell me how?
Reply
#4

Quote:
Originally Posted by Soumi
Посмотреть сообщение
Tell me how?
Define this above your script:

Код:
#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 this somewhere in your script:
Код:
dcmd_adminsay(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{
	    if(strlen(params) == 0)
	    {
			SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /adminsay [text]");
			return 1;
		}
		new message = params[0];
		new adminname[MAX_PLAYER_NAME], str1[128];
		GetPlayerName(playerid, adminname, sizeof(adminname));
		
		format(str1, sizeof(str1), "(( [ADMIN] %s: %s ))", adminname, message);
		SendClientMessageToAll(0xFFFFFFFF, str1);
	}
	else
	{
	    SendClientMessage(playerid, 0xFFFFFFFF, "  You must be an admin to use this command.");
	}
	return 1;
}
Add this to OnPlayerCommandText:
Код:
dcmd(adminsay, 8, cmdtext);
Here you go, re-write this, learn this.
DCMD is very simple and nice, I use it too.

Enjoy your new working command!
Reply
#5

pawn Код:
if(!strcmp(cmd, "/asay"))
{
     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
     new text[128];
     if(sscanf(params, "s[128]",text)== 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]");
     new string[128];
     new pName[128];
     GetPlayerName(playerid,pName,128);
     format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
     SendClientMessageToAll(0xA10000AA,string);
     return 1;
}
Reply
#6

Thanks austin070 but when i type only /asay , it whos [ADMIN]soumi : and when i type more then 5characters , the 5 character isn't showing.. Can you help me fix this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)