How to remove the "_" from the names? -
Mrashad - 18.09.2014
As the title says....
Re: How to remove the "_" from the names? -
SilentSoul - 18.09.2014
https://sampforum.blast.hk/showthread.php?tid=207984
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;
}
Re: How to remove the "_" from the names? -
Mrashad - 19.09.2014
Quote:
Originally Posted by SilentSoul
|
I used it before but still the "_" shows up and I don't get any error!
Re: How to remove the "_" from the names? -
The__ - 19.09.2014
What I use:
pawn Код:
stock GetPlayerNameEx(playerid)
{
new string[24];
GetPlayerName(playerid,string,24);
new str[24];
strmid(str,string,0,strlen(string),24);
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if (str[i] == '_') str[i] = ' ';
}
return str;
}
Re: How to remove the "_" from the names? -
JM_Millers - 19.09.2014
pawn Код:
new nickname[2][25];
GetPlayerName(playerid, nickname[0], MAX_PLAYER_NAME);
sscanf( nickname[0], "p<_>s[24]s[24]", nickname[0], nickname[1]);
nickname[0] - All, what before "_"
nickname[1] - All, what after "_"
Re: How to remove the "_" from the names? -
Sawalha - 19.09.2014
try The_'s one with SetPlayerName
Re: How to remove the "_" from the names? -
SilentSoul - 19.09.2014
I'm pretty sure you do something wrong, it works pretty fine for me.
pawn Код:
public OnPlayerConnect(playerid)
{
new string[126];
format(string,sizeof(string),"Welcome %s",RemoveUnderScore(playerid));
SendClientMessage(playerid,-1,string);
return 1;
}
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;
}
Re: How to remove the "_" from the names? -
Beckett - 19.09.2014
pawn Код:
stock sendername(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;
}
Re: How to remove the "_" from the names? -
JM_Millers - 19.09.2014
All that is provided above - shit.
The only way you can do it nomally is:
pawn Код:
splitname(playerid, name[21])
{
GetPlayerName(playerid, name, 21);
for(new i; i < 21; i++)
{
if(name[i] == '_')
{
name[i] = 32;
}
}
return true;
}
Re: How to remove the "_" from the names? -
codectile - 19.09.2014
Quote:
Originally Posted by JM_Millers
All that is provided above - shit.
The only way you can do it nomally is:
pawn Код:
splitname(playerid, name[21]) { GetPlayerName(playerid, name, 21); for(new i; i < 21; i++) { if(name[i] == '_') { name[i] = 32; break; } } return true; }
|
@JM_Miller: Your code will only remove the very first underscore present in string/name. The above functions are much better than your's. Just stop criticizing.
Re: How to remove the "_" from the names? -
JM_Millers - 19.09.2014
Quote:
Originally Posted by codectile
The above functions are much better than your's. Just stop criticizing.
|
These functions're returning the string (it's very bad).
Quote:
@JM_Miller: Your code will only remove the very first underscore present in string/name.
|
I'll fix it
Re: How to remove the "_" from the names? -
codectile - 19.09.2014
We have to return a string, returning a boolean type will be very much useless in this case.
Re: How to remove the "_" from the names? -
JM_Millers - 19.09.2014
Quote:
Originally Posted by codectile
We have to return a string, returning a boolean type will be very much useless in this case.
|
This is the worst idea to return a string because it's very bad for stack.
Re: How to remove the "_" from the names? -
codectile - 20.09.2014
@Jm_Millers: Maybe, but in this case it's just fine.