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(playeridplayerNamesizeof(playerName));
    new 
RName[MAX_PLAYER_NAME];
    for(new 
0strlen(Name(playerid)); i++) {
        if(!
strcmp(playerName[i], "_"true)) {
            
strins(RName" "strlen(RName));
        }
        else {
            
strcat(RNameplayerName[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(playeridplayerNameMAX_PLAYER_NAME);
    for(new 
cstrlen(playerName); c++) { 
        if(
playerName[c] == '_') {
            
playerName[c] = ' ';         
            
SendClientMessage(playeridMessage"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(msgsizeof(msg), "Welcome %s!"GetName(playeridfalse));
    
SendClientMessage(playerid, -1msg);
    return 
1;
}
GetName(playeridbool:with_underscore true// Notice the with_underscore parameter.
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    if(!
with_underscore)
    {
        for(new 
0MAX_PLAYER_NAMEi++)
        {
            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(playeridbool:with_underscore true// Notice the with_underscore parameter. 

    new 
name[MAX_PLAYER_NAME]; 
    
GetPlayerName(playeridnameMAX_PLAYER_NAME); 
    if(!
with_underscore
    { 
        for(new 
0MAX_PLAYER_NAMEi++) 
        { 
            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(Strsizeof(Str), red"My name IG is: "GetName(playeridfalse));
    
SendClientMessage(playeridMessageStr);
    return 
1;

Reply
#8

PHP код:
NomeRP(playerid//Author: ??? and PeterLinkson
{
    new 
Name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridNameMAX_PLAYER_NAME);
    for(new 
namename 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(playeridNameMAX_PLAYER_NAME);
    for(new 
namename 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 
iMAX_PLAYER_NAMEi++)
    {
        if(
name[i] == '_'name[i] = ' ';
    }
    return 
name;

PHP код:
RemoveUnderLine(GetName(playerid)); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)