Roleplay Name?
#1

how to remove '_' from their names example my name is

Код:
John_Smith
it would be something like this when use in chat

Код:
John Smith
i'm trying to make something like this

pawn Код:
stock pname(playerid)
{
     new name[MAX_PLAYER_NAME];
     GetPlayerName(playerid, name, sizeof(name));
     return name;
}
but this stock function will not remove the '_'
Reply
#2

pawn Код:
stock pNameEx(playerid)
{
        new Name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Name, sizeof Name);
        strreplace(Name, '_', ' ');
        return Name;
}
Reply
#3

This is what I use.
pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++) {
        if(string[i] == find) {
            string[i] = replace;
        }
    }
}
stock GetName(playerid)
{
    new string[MAX_PLAYER_NAME];
    GetPlayerName(playerid,string,sizeof(string));
    strreplace(string,'_',' ');
    return string;
}
Reply
#4

You need this function:

pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++) {
        if(string[i] == find) {
            string[i] = replace;
        }
    }
}
And....then.

pawn Код:
stock GetName(playerid)
{
    new string[MAX_PLAYER_NAME];
    GetPlayerName(playerid,string,sizeof(string));
    strreplace(string,'_',' ');
    return string;
}
Reply
#5

one more last question.

pawn Код:
public OnPlayerText(playerid, text[])
{
    ApplyAnimation(playerid,"PED","IDLE_chat", 4.1, 0, 0, 0, 1, 1);
    return 0;
}
how to clear the anim?
Reply
#6

ClearAnimations(playerid);




Search the wiki. It has all the functions you need.
Reply
#7

is this correct?

pawn Код:
new chattimer[MAX_PLAYERS];

public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string, sizeof(string), "%s says: %s", pNameEx(playerid), text);
    ProxDetector(30.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    ApplyAnimation(playerid,"PED","IDLE_chat", 4.1, 0, 0, 0, 1, 1);
    chattimer[playerid] = SetTimer("ClearAnim", 5000, true);
    return 0;
}

forward ClearAnim();
public ClearAnim()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
             ClearAnimations(i, 0);
             KillTimer(chattimer[i]);
        }
    }
    return 1;
}
Reply
#8

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pname[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    strreplace(pname, '_', ' ');

    format(str, sizeof(str), "%s says: %s", pname, text);
    ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    ApplyAnimation(playerid,"PED","IDLE_chat", 4.1, 0, 0, 0, 1, 1);
    chattimer[playerid] = SetTimer("ClearAnim", 5000, true);
    return 0;
}
Reply
#9

thank you

Код:
Nicholas
VincentDunn
Antonio
rep all of you
Reply
#10

I was looking for this, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)