Underscore problem
#1

I have an underscore problem in my server, can anyone help me with that?
It's like 'Adam_Cole kicks the ball'. I want to change it to 'Adam Cole kicks the ball'
Can anyone help me with replacing the '_' to ' '?
Reply
#2

pawn Код:
stock Replace(name[])
{
    for(new i, len = strlen(name); i < len; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
}
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
pawn Код:
stock Replace(name[])
{
    for(new i, len = strlen(name); i < len; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
}
How and where to put it?
Reply
#4

Somewhere in your script (not in a callback or command). Then use it like

pawn Код:
public OnPlayerText(playerid, text[])
{
    Replace(text);//Replaces all your chat underscores with spaces.
    return 1;
}
Reply
#5

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Somewhere in your script (not in a callback or command). Then use it like

pawn Код:
public OnPlayerText(playerid, text[])
{
    Replace(text);//Replaces all your chat underscores with spaces.
    return 1;
}
How to put it?
Reply
#6

*bump* Help me please
Reply
#7

#1 Read me

#2
I would use Vince's snippet, and call it under OnPlayerConnect if possible

pawn Код:
public OnPlayerConnect(playerid)
{
     SetPlayerName(playerid, ConvertName(GetName));
     return 1;
}

stock GetName(playerid)
{
     new pName[25];
     GetPlayerName(playerid, sizeof(pName), pName);
     return pName;
}

stock ConvertName(name[])
{
    for(new i, len = strlen(name); i < len; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
}
Reply
#8

OFFTOPIC: Cameltoe i read at your Signature that You script for people and Design the Web.I want a Scripter.

Sorry for the Offtopic
Reply
#9

Quote:
Originally Posted by Harry_Sandhu
Посмотреть сообщение
OFFTOPIC: Cameltoe i read at your Signature that You script for people and Design the Web.I want a Scripter.

Sorry for the Offtopic
You're better off sending me an pm, or mailing me at : simentobias@gmail.com
Reply
#10

pawn Код:
stock playername(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    for(new name = 0; name < MAX_PLAYER_NAME; name++)
    {
        if(Name[name] == '_')
        {
            Name[name] = ' ';
        }
    }
    return Name;
}
Put that code wherever you want.

If you want to use the name without the "_" use playername(playerid) in stead of
GetPlayerName(bla, bla, bla);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)