Admin say problem - 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: Admin say problem (
/showthread.php?tid=242162)
Admin say problem -
Soumi - 19.03.2011
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(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;
}
Thanks !!
Re: Admin say problem -
Biesmen - 19.03.2011
Use dcmd/zcmd.
Re : Admin say problem -
Soumi - 19.03.2011
Tell me how?
Re: Re : Admin say problem -
Ihsan-Cingisiz - 19.03.2011
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!
Re: Admin say problem -
austin070 - 19.03.2011
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;
}
Re : Admin say problem -
Soumi - 21.03.2011
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?