03.03.2017, 11:02
Hi guys i want to do cmd /admins /asay can one tell me how
#include <a_samp>
#include <zcmd>
#include <sscanf>
CMD:asay(playerid,params[])//The command
{
if(IsPlayerAdmin(playerid))//to define it only for an admin to use it
{
new string[128]; new name[MAX_PLAYER_NAME]; new Msg[128];//New we have to use them
GetPlayerName(playerid, name,sizeof(name));//defining new name[MAX_PLAYER_NAME];
if(sscanf(params,"i[128]",Msg)) return SendClientMessage(playerid, 0xf8f8f8fff,"Syntax: /asay <msg>"); //Using params to give right syntax and to let it work
format(string,sizeof(string),"Administrator {f00f00}%s: %d",name,Msg);//formatting the asay message
SendClientMessageToAll(0xf8f8f8fff,string);//sending to all in global chat
}
else
{
SendClientMessage(playerid, 0xf8f8f8fff,"YOU NEED TO BE AN ADMIN TO USE THIS COMMAND!");//Defining that if player isn't logged in rcon he can't use it.
}
return 1;
}
PHP код:
|
look @ sscanf statement. Actually no need to use sscanf here its memory wastage as params is string. use isnull instead
|
CMD:asay(playerid, params[])
{
if (IsPlayerAdmin(playerid))
{
if (isnull(params))
return SendClientMessage(playerid, 0xf8f8f8fff, "Syntax: {ff0ff0}/asay <text>");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"Administrator {f00f00}%s(%i): {FFFfff}%s", name, playerid, params);
SendClientMessageToAll(0xF8f8F8FFF, string);
}
else
{
SendClientMessage(playerid, 0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
}
return 1;
}