Removing "_" from player names
#1

When I asked a friend of mine how to remove them, he gave me this, but it's still not working and instead of names appearing as "John Smith", they appear as "John_Smith"

pawn Код:
stock GetNameEx(playerid)
{
    new Name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid))
    {
        new i;
        GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
        while ((i = strfind(Name, "_", false, i)) != -1)
            Name[i] = ' ';
    }
    return Name;
}
Reply
#2

pawn Код:
stock no_underscore(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof playername);

    for(new i = 0; i < strlen(playername); i++)
    {
        if(playername[i] == '_')
        {
            playername[i] = ' ';
            break;
        }
    }

    return playername;
}
Reply
#3

pawn Код:
stock GetNameEx(playerid) {
    new Name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid)) {
        GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
        Name = str_replace("_", " ", Name);
    } else return -1;
    return Name;
}
See this.
Reply
#4

pawn Код:
stock RPNAME(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
Reply
#5

Are you sure you're using the custom function when getting a player name or you're still using GetPlayerName?
Reply
#6

well here is the method i created first we get the palyer name, then we check each player name and foreach player name that has "_" it will be seend as " ".

for example
pawn Код:
new string[32];
format(string, sizeof(string), "%s", RPNAME(playerid));
SendClientMessage(playerid, -1, string);

//in a command via zcmd ...
CMD:namecheck(playerid, params[])
{
  new string[32];
  format(string, sizeof(string), "%s", RPNAME(playerid));
  SendClientMessage(playerid, -1, string);
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)