[HELP] Remove the underscore in players names
#1

I want to remove the underscore [_] in player names when they chat ingame, for example:

Matthew_Salinas says: BlahBlah

Should be...

Matthew Salinas says: BlahBlah

And I'm using this to block players with normal nicks:

Код:
stock IsValidName(playerid)
{
    if (IsPlayerConnected(playerid))
    {
        new player[24];
        GetPlayerName(playerid,player,24);
        for(new n = 0; n < strlen(player); n++)
        {
        	if (player[n] == '_') return 1;
        	if (player[n] == ']' || player[n] == '[') return 0;
        }
    }
    return 0;
}
If you need any information, just ask.

Thanks
Reply
#2

pawn Код:
stock RemoveUnderLine(name[MAX_PLAYER_NAME])
{
  for(new i; i < MAX_PLAYER_NAME; i++)
  {
    if(name[i] == '_') name[i] = ' ';
  }
  return name;
}
Works as:
pawn Код:
playername = RemoveUnderLine(playername);
Reply
#3

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
stock RemoveUnderLine(name[MAX_PLAYER_NAME])
{
  for(new i; i < MAX_PLAYER_NAME; i++)
  {
    if(name[i] == '_') name[i] = ' ';
  }
  return name;
}
Works as:
pawn Код:
playername = RemoveUnderLine(playername);
A'ight, where should I put this function to make it work?
Reply
#4

pawn Код:
stock GetPlayerRPName( playerid, name[ ], len )
{
    GetPlayerName( playerid, name, len );
    for(new i = 0; i < len; i++ )
    {
        if ( name[ i ] == '_' )
        name[ i ] = ' ';
    }
}
Better use this in stead of the normal GetPlayerName, and voilla
Reply
#5

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
pawn Код:
stock GetPlayerRPName( playerid, name[ ], len )
{
    GetPlayerName( playerid, name, len );
    for(new i = 0; i < len; i++ )
    {
        if ( name[ i ] == '_' )
        name[ i ] = ' ';
    }
}
Better use this in stead of the normal GetPlayerName, and voilla
I'm lost, I don't how to add it in the correct way and how to use it later...
Reply
#6

Add it somewhere in your script, but not in a callback (And under your #includes)
Reply
#7

pawn Код:
stock RemoveUnderScore(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;
}

public OnPlayerText(playerid,text[])
{
    new string[128];
    format(string,sizeof(string),"%s: %s",RemoveUnderScore(playerid),text);
    SendClientMessageToAll(color,string);
    return 0;
}
Reply
#8

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
stock RemoveUnderScore(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;
}

public OnPlayerText(playerid,text[])
{
    new string[128];
    format(string,sizeof(string),"%s: %s",RemoveUnderScore(playerid),text);
    SendClientMessageToAll(color,string);
    return 0;
}
Thanks, it works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)