[AJUDA]Comando /pm
#8

O melhor que tem:
pawn Код:
if(!strcmp("/pm", cmd, true) || !strcmp("/mp", cmd, true))
    {
        if(PlayerInfo[playerid][pAdmin] > 0)
        {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USE: /MP [PlayerID/Nome] [Texto]");
                return 1;
            }
            new id = ReturnUser(tmp);

            if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREY, "Jogador Nгo Conectado.");

            tmp = strrest(cmdtext,idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USE: /MP [PlayerID/Nome] [Texto]");
                return 1;
            }
           
            new Rank[25];
            if(PlayerInfo[playerid][pAdmin] == 1) Rank = "Sub-Moderador";
            if(PlayerInfo[playerid][pAdmin] == 2) Rank = "Moderador";
            if(PlayerInfo[playerid][pAdmin] == 3) Rank = "Admin 1";
            if(PlayerInfo[playerid][pAdmin] == 4) Rank = "Admin 2";
            if(PlayerInfo[playerid][pAdmin] == 5) Rank = "Admin 3";
            format(string, sizeof(string), "[MP] %s %s[%d]: %s", Rank, sendername, playerid, tmp);
            SendClientMessage(id, COLOR_GREEN, string); new nomeid[MAX_PLAYER_NAME];
            GetPlayerName(id, nomeid, sizeof(nomeid));
            format(string, sizeof(string), "[MP] %s %s[%d] %s", Rank, nomeid, id, tmp);
            SendClientMessage(playerid, COLOR_GREEN, string);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "Vocк nгo pode usar este comando.");
            return 1;
        }
    }
Caso nгo tenha:

pawn Код:
//----------------------------------------------------------

stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

//------------------------------------------------

stock strrest(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[128];
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

//----------------------------------------------------------

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21) /
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
            {
                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid;
            }
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0)
            {
                if (len == strlen(name))
                {
                    return i;
                }
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Espero ter ajudado
Reply


Messages In This Thread
[AJUDA]Comando /pm - by DPS|NeW| - 16.05.2011, 02:27
Re: [AJUDA]Comando /pm - by Pharrel - 16.05.2011, 02:34
Re: [AJUDA]Comando /pm - by DPS|NeW| - 16.05.2011, 02:52
Re: [AJUDA]Comando /pm - by DPS|NeW| - 16.05.2011, 02:56
Re: [AJUDA]Comando /pm - by demonneni - 16.05.2011, 03:37
Re: [AJUDA]Comando /pm - by Shadoww5 - 16.05.2011, 08:57
Re: [AJUDA]Comando /pm - by DPS|NeW| - 17.05.2011, 13:38
Re: [AJUDA]Comando /pm - by Dr_Pawno - 17.05.2011, 14:54

Forum Jump:


Users browsing this thread: 2 Guest(s)