SA-MP Forums Archive
Name without _ - 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: Name without _ (/showthread.php?tid=542690)



Name without _ - Baltimore - 21.10.2014

I "stores" Player's username in a variable (pName).

Username = Under firstname_lastname form.

How to ensure that when I use the variable pName, it appears to me, named in place of firstname_lastname?

Acts your code I do not see how to do it!


Re: Name without _ - Anzipane - 21.10.2014

pawn Код:
new idx = strfind(pName, "_");

if (idx != -1) // We found the '_' character, let's replace it with a space
    pName[idx] = ' ';



Re : Name without _ - Baltimore - 21.10.2014

Where I place this code?


Re: Name without _ - dominik523 - 21.10.2014

Put it somewhere in your script outside of the callbacks.
Код:
stock PlayerName(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;
}
When using PlayerName:
Код:
format(string, sizeof(string), "%s is my name.", PlayerName(playerid));