Help me, please /a chat
#1

So, I'm trying to make an admin chat, basically admins can speak with eachother using the command /a [text]
But, I got this command:
pawn Code:
CMD:a(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME], result[128], string[128];
    if(!(PlayerInfo[playerid][pAdmin] >= 1)) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
    if(sscanf(params,"s[128]", result)) return SCM(playerid, COLOR_GOLD,"USAGE: /a [chat]");
    else
    {
        format(string, sizeof(string),"*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, result);
        SendAdminMessage(COLOR_GOLD, string);
    }
    return 1;
}
Every time I type for example: /a hello, or anything, I'm getting always this message: "USAGE: /a [chat]", any help, please?
Reply
#2

pawn Code:
CMD:a(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME];
    if(!PlayerInfo[playerid][pAdmin] >= 1) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
    if(isnull(params)) return SCM(playerid,COLOR_GOLD,"USAGE: /a [chat]");
    GetPlayerName(playerid,sendername,sizeof(sendername));
    format(string,160,"*%d Admin %s: %s",PlayerInfo[playerid][pAdmin],sendername,params);
    SendAdminMessage(COLOR_GOLD, string);
    return 1;
}
Reply
#3

Damn thanks, noticed that I got the same problem on this command:
pawn Code:
CMD:kick(playerid, params[])
{
    new id, sendername[MAX_PLAYER_NAME], string[128], reason[128];
    if(!PlayerInfo[playerid][pAdmin] >= 1) return SCM(playerid, COLOR_GREY,"  you are not authorized to use this command");
    if(sscanf(params,"us[128]",id, reason)) return SCM(playerid, COLOR_WHITE,"USAGE: /kick [playerid/partofname] [reason]");
    if(id == INVALID_PLAYER_ID) return SCM(playerid, COLOR_WHITE,"Player is not connected");
    else
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s", id, sendername, reason);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        Kick(id);
    }
    return 1;
}
But I think I can't check if is null because there are 2 parameters? How to make here?
Reply
#4

sscanf have isnull in-build code.

pawn Code:
CMD:kick(playerid,params[])
{
    new id,name1[MAX_PLAYER_NAME]name2[MAX_PLAYER_NAME];
    if(!PlayerInfo[playerid][pAdmin] >= 1) return SCM(playerid, COLOR_GREY,"  you are not authorized to use this command");
    if(sscanf(params,"us[128]",id,params)) return SCM(playerid, COLOR_WHITE,"USAGE: /kick [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_WHITE,"Player is not connected");
    GetPlayerName(playerid,name1,sizeof(name1));
    GetPlayerName(id,name2,sizeof(name2));
    format(params,129, "AdmCmd: %s was kicked by %s, reason: %s",name2,name1,params);
    SendClientMessageToAll(COLOR_LIGHTRED,params);
    Kick(id);
    return 1;
}
Reply
#5

^^ thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)