Admin chat won't allow spaces
#1

Ok so i made a simple admin chat and it works but if a player types with spaces it dosn't show the words after the spaces here is my code.

pawn Код:
COMMAND:ac(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] > 1)
    {
        new message[200];
        if(sscanf(params, "s[32]", message))
        {
            new string1[252];
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pname,sizeof(pname));
            format(string1,sizeof(string1),"Server Admin %s: %s", pname, message);
            SendMessageToAdmins(COLOR_GREEN,string1);
        }
        else return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /ac [message]");
    }
    else return SendClientMessage(playerid, COLOR_YELLOW, "You are not an admin");
    return 1;
}
Reply
#2

s[32]

should be

s[200]
Reply
#3

Yeah and you shouldn't make your string so big. When you have a lot of command functions etc. it will start to get a bit slower, the max clientmessage is 144 long, your reason and the other string are 400+ together. But yes, Sniper Kitty pointed out the problem.
Reply
#4

pawn Код:
COMMAND:ac(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] < 1)  return SendClientMessage(playerid, COLOR_YELLOW, "You are not an admin");
    new message[128];
    if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /ac [message]");
    new pname[MAX_PLAYER_NAME],str[sizeof message];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(str,sizeof(str),"Server Admin %s: %s", pname, message);
    SendMessageToAdmins(COLOR_GREEN,str);
    return 1;
}
Reply
#5

ok i changed s[32] to s[200] and still dosn't show words after spaces
Reply
#6

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
pawn Код:
COMMAND:ac(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] < 1)  return SendClientMessage(playerid, COLOR_YELLOW, "You are not an admin");
    new message[128];
    if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /ac [message]");
    new pname[MAX_PLAYER_NAME],str[sizeof message];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(str,sizeof(str),"Server Admin %s: %s", pname, message);
    SendMessageToAdmins(COLOR_GREEN,str);
    return 1;
}
when i do that one it just says /ac message
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)