ReturnUser.
#1

Good evening.

So I use a system of numbered Unknown on my server which replaces the nickname of the player to avoid metagame.

So it looks like this:
Inconnu_14698 says: Blabla

So I for example my order /report but it works with the ids of players (0, 1, 2, 3 etc.).

So I'd like it to work with the id of the unknown, for example:

/report 14698

Thank you!
Reply
#2

you must modify ReturnUser function
Reply
#3

pawn Код:
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 pname[MAX_PLAYER_NAME];

    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
   
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, COLOR_WHITE, "Enter the full name of the user.");
            else SendClientMessage(playerid, COLOR_GREY, "No results found for the specified phrase.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Reply
#4

I know it has this function, but I do not know how to do it.

Derick if the code is changed, you can comment please?

So I understand, thank you
Reply
#5

pawn Код:
ReturnUser(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof name);
    return name;
}
??
Reply
#6

No, because it is mainly for my system Unknown numbered.

So when the player talks being unknown it does:
Inconnu_14698 says: Blabla

The number varies of course.

So the player who reported the Unknown numbered does not know the name of the player, just unknown number.

To get a result like this for example:

/report 14698 (This is the number of the Unknown (But it is variable, it may change)) Blabla.

/report 14698 blabla
Reply
#7

Does that mean every player who joins gets a new ID pressed against a constant prefix as their name?

Like -

Player_1
Player_2
Player_3

Is that it?

If you want to do that -

pawn Код:
#define CONST_PREFIX    "Inconnu_"

ReturnUserBySuffix( suffix )
{
    new name[MAX_PLAYER_NAME] = CONST_PREFIX,
           suff[7];

    valstr(suff, suffix);
    strcat(name, suff);

    new pName[MAX_PLAYER_NAME];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
          GetPlayerName(i, pName, MAX_PLAYER_NAME);
          if(!strcmp(pName, name)) return i;
     }

     return INVALID_PLAYER_ID;
}
EDIT: I am really sorry, I realise there are better ways of doing this, but I am really tired and I'll edit this and post some better code when I can
Reply
#8

pawn Код:
PlayerInfo[playerid][p_NbrInconnu] = 1000 + random(19999);
    Inconnu_infos[playerid][Inconnu_id] = PlayerInfo[playerid][p_NbrInconnu];
    memcpy(Inconnu_infos[playerid][Inconnu_Pseudo], pName[playerid], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
In my OnPlayerLogin.

So the unknown number assigned to it the connection, but it is visible or not in the chat if activated with a command.

In my /me:

pawn Код:
if(Player_use_nomoff[playerid] == 1) format(proxy_msg, sizeof(proxy_msg), "Inconnu %d %s", PlayerInfo[playerid][p_NbrInconnu], result);
        else format(proxy_msg, sizeof(proxy_msg), "%s %s", pName[playerid], result);
        proxy_sendMsg(playerid, proxy_msg);
Reply
#9

Try something like this:

pawn Код:
new UnknownID[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    UnknownID[playerid] = 14698;
    //or random numbers:
    UnknownID[playerid] = random(50000);
}

public OnPlayerText(playerid, text[])
{
    new str[144];
    format(str, sizeof (str), "Inconnu_%d: %s", UnknownID[playerid], text);
    SendPlayerMessageToAll(playerid, str);
    return 0;
}

ReturnUser(id)
{
    new pid=-1, name[24];
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(UnknownID[i] == id)
        {
            pid = i;
            break;
        }
    }
    if(pid=-1) return 0;
    GetPlayerName(pid, name, sizeof name);
    return name;
}
ReturnUser( 14698 ) should return the player name of the user with the "unknown number" 14698. Also, if there's no player online with the ID 14698, it will return 0, so check for that:

pawn Код:
if(!ReturnUser(14698)) return SendClientMessage(playerid, -1, "There's no player online with that number.");
Reply
#10

Your function will only work with Unknown.

Me, I want it to work with both, the Unknown and the players with the normal nametag.

But a friend told me that succeeds it happens in "IsNumeric" ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)