RP name help
#1

Hello guys, i made this function to return the player name without the "_" but it returns nothing at all

Here's the code
PHP код:
stock RPname(playerid) {
    new 
playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, playerName, sizeof(playerName));
    new 
RName[MAX_PLAYER_NAME];
    for(new 
i = 0; i < strlen(Name(playerid)); i++) {
        if(!
strcmp(playerName[i], "_", true)) {
            
strins(RName, " ", strlen(RName));
        }
        else {
            
strcat(RName, playerName[i], strlen(RName));
        }
    }
    return 
RName;
} 
What's wrong here?
Reply
#2

stock RPname(playerid) {

new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

for(new c; c < strlen(playerName); c++) if(playerName[c] == '_') playerName[c] = ' ';

return playerName;
}
Reply
#3

Quote:
Originally Posted by JustNothing
Посмотреть сообщение
stock RPname(playerid) {

new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

for(new c; c < strlen(playerName); c++) if(playerName[c] == '_') playerName[c] = ' ';

return playerName;
}
Didn't work
Reply
#4

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Didn't work
How you used it? Because I just tested it and for me it works...
Reply
#5

Quote:
Originally Posted by JustNothing
Посмотреть сообщение
How you used it? Because I just tested it and for me it works...
In a SendClientMessage when the player joins.
i even added a client message in the stock so i know if the condition is working or not, and it does send the message, but it just return null
PHP код:
stock RPname(playerid) {
    new 
playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    for(new 
c; c < strlen(playerName); c++) { 
        if(
playerName[c] == '_') {
            
playerName[c] = ' ';         
            
SendClientMessage(playerid, Message, "Condition is true");
        }
    }
    return 
playerName;
} 
Reply
#6

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
This should do the job:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
msg[36];
    
format(msg, sizeof(msg), "Welcome %s!", GetName(playerid, false));
    
SendClientMessage(playerid, -1, msg);
    return 
1;
}
GetName(playerid, bool:with_underscore = true) // Notice the with_underscore parameter.
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    if(!
with_underscore)
    {
        for(new 
i = 0; i < MAX_PLAYER_NAME; i++)
        {
            if(
name[i] == '_') name[i] = ' ';
        }
    }
    return 
name;
} 
Still, didn't fix
Here is the photo
https://imgur.com/a/4dk22

And this is my code
PHP код:
GetName(playerid, bool:with_underscore = true) // Notice the with_underscore parameter. 
{ 
    new 
name[MAX_PLAYER_NAME]; 
    
GetPlayerName(playerid, name, MAX_PLAYER_NAME); 
    if(!
with_underscore) 
    { 
        for(new 
i = 0; i < MAX_PLAYER_NAME; i++) 
        { 
            if(
name[i] == '_') name[i] = ' '; 
        } 
    } 
    return 
name; 
} 
Reply
#7

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
Show the format and SendClientMessage part.
PHP код:
public OnPlayerConnect(playerid)
{
    new 
Str[200];
    
format(Str, sizeof(Str), red"My name IG is: ", GetName(playerid, false));
    
SendClientMessage(playerid, Message, Str);
    return 
1;
} 
Reply
#8

PHP код:
NomeRP(playerid) //Author: ??? and PeterLinkson
{
    new 
Name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    for(new 
name; name < MAX_PLAYER_NAME; ++name) if(Name[name] == '_') Name[name] = ' ';
    return 
Name;
} 
Reply
#9

Quote:
Originally Posted by PeterLinkson
Посмотреть сообщение
PHP код:
NomeRP(playerid) //Author: ??? and PeterLinkson
{
    new 
Name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    for(new 
name; name < MAX_PLAYER_NAME; ++name) if(Name[name] == '_') Name[name] = ' ';
    return 
Name;
} 
Isn't working
Reply
#10

PHP код:
stock RemoveUnderLine(name[MAX_PLAYER_NAME])
{
    for(new 
i; i < MAX_PLAYER_NAME; i++)
    {
        if(
name[i] == '_') name[i] = ' ';
    }
    return 
name;
} 
PHP код:
RemoveUnderLine(GetName(playerid)); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)