SA-MP Forums Archive
RP name help - 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)
+--- Thread: RP name help (/showthread.php?tid=644573)



RP name help - Arbico - 10.11.2017

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?


Re: RP name help - JustNothing - 10.11.2017

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


Re: RP name help - Arbico - 10.11.2017

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


Re: RP name help - JustNothing - 10.11.2017

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


Re: RP name help - Arbico - 10.11.2017

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



Re: RP name help - Arbico - 10.11.2017

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



Re: RP name help - Arbico - 10.11.2017

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



Re: RP name help - PeterLinkson - 10.11.2017

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



Re: RP name help - Arbico - 10.11.2017

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


Re: RP name help - n00blek - 10.11.2017

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