COMANDS
#1

Hi guys i want to do cmd /admins /asay can one tell me how
Reply
#2

PHP код:
#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(playeridname,sizeof(name));//defining new name[MAX_PLAYER_NAME];
     
if(sscanf(params,"i[128]",Msg)) return SendClientMessage(playerid0xf8f8f8fff,"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(playerid0xf8f8f8fff,"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;

Reply
#3

Quote:
Originally Posted by RyderX
Посмотреть сообщение
PHP код:
#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(playeridname,sizeof(name));//defining new name[MAX_PLAYER_NAME];
     
if(sscanf(params,"i[128]",Msg)) return SendClientMessage(playerid0xf8f8f8fff,"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(playerid0xf8f8f8fff,"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;

msg is string not integer
Reply
#4

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
msg is string not integer
Well how it would be?
Reply
#5

Quote:
Originally Posted by RyderX
Посмотреть сообщение
Well how it would be?
look @ sscanf statement. Actually no need to use sscanf here its memory wastage as params is string. use isnull instead
Reply
#6

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
look @ sscanf statement. Actually no need to use sscanf here its memory wastage as params is string. use isnull instead
Well yes, so it should be like this:

PHP код:
CMD:asay(playeridparams[])
{
    if (
IsPlayerAdmin(playerid))
    {
    if (
isnull(params))
        return 
SendClientMessage(playerid0xf8f8f8fff"Syntax: {ff0ff0}/asay <text>");
    new 
string[128], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(stringsizeof(string),"Administrator {f00f00}%s(%i): {FFFfff}%s"nameplayeridparams);
    
SendClientMessageToAll(0xF8f8F8FFFstring);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)