How to remove the "_" from the names?
#1

As the title says....
Reply
#2

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;
}
Reply
#3

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
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;
}
I used it before but still the "_" shows up and I don't get any error!
Reply
#4

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;
}
Reply
#5

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 "_"
Reply
#6

try The_'s one with SetPlayerName
Reply
#7

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;
}
Reply
#8

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;
}
Reply
#9

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;
}
Reply
#10

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.
Reply
#11

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
Reply
#12

We have to return a string, returning a boolean type will be very much useless in this case.
Reply
#13

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.
Reply
#14

@Jm_Millers: Maybe, but in this case it's just fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)