SA-MP Forums Archive
[HELP] Remove the underscore in players names - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Remove the underscore in players names (/showthread.php?tid=171641)



[SOLVED] Remove the underscore in players names - Fredden1993 - 27.08.2010

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


Re: [HELP] Remove the underscore in players names - Hiddos - 27.08.2010

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);



Re: [HELP] Remove the underscore in players names - Fredden1993 - 27.08.2010

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?


Re: [HELP] Remove the underscore in players names - Jochemd - 27.08.2010

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


Re: [HELP] Remove the underscore in players names - Fredden1993 - 27.08.2010

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...


Re: [HELP] Remove the underscore in players names - Hiddos - 27.08.2010

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


Re: [HELP] Remove the underscore in players names - [XST]O_x - 27.08.2010

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;
}



Re: [HELP] Remove the underscore in players names - Fredden1993 - 27.08.2010

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!