No name...
#1

Hey, i have this commnat for /txt and when somebody /txt BLABLABLA need to show:
ADMIN: Nickname : BLABLABLA
But the nickname is not there :@

pawn Код:
if(strcmp(cmd, "/txt", true) == 0) // By CuervO_NegrO
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /txt [text]");

            format(string, sizeof(string), "* ADMIN %s: %s ",sendername,(result));
            SendClientMessageToAll(0x2587CEFF, string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
        }
        return 1;
    }
Reply
#2


pawn Код:
if(strcmp(cmd, "/txt", true) == 0) // By CuervO_NegrO
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            new sendername[MAX_PLAYER_NAME]; // <<<
            GetPlayerName(playerid, sendername, MAX_PLAYER_NAME); // <<<
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /txt [text]");

            format(string, sizeof(string), "* ADMIN %s: %s ",sendername,(result));
            SendClientMessageToAll(0x2587CEFF, string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
        }
        return 1;
    }
?

Greetz,
LetsOWN
Reply
#3

Try this

As ****** Said
Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, that's nearly as bad as using "MAX_PLAYER_NAME + 1" (i.e. an array one bigger than it needs to be by definition).
pawn Код:
if(strcmp(cmd, "/txt", true) == 0) // By CuervO_NegrO
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            new name[34]; // <<<
            GetPlayerName(playerid, sendername, sizeof(name)); // <<<
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /txt [text]");

            format(string, sizeof(string), "* ADMIN %s: %s ",name,(result));
            SendClientMessageToAll(0x2587CEFF, string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
        }
        return 1;
    }
Reply
#4

Heh, you can still redefine it at your own
pawn Код:
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 30 // ? or more
And also usefull thing..
pawn Код:
enum
       plyr
{
Name[MAX_PLAYER_NAME],
// anything else?
}
new Player[MAX_PLAYERS][plyr];

public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
return 1;
}
With this baby you dont have to GetPlayerName over and over again..

Greetz,
LetsOWN
Reply
#5

Ok tnx i think i understand this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)