SA-MP Forums Archive
Underscore problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Underscore problem (/showthread.php?tid=265952)



Underscore problem - DeLexia - 03.07.2011

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 ' '?


Re: Underscore problem - Vince - 03.07.2011

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



Re: Underscore problem - DeLexia - 07.07.2011

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?


Re: Underscore problem - alpha500delta - 07.07.2011

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



Re: Underscore problem - DeLexia - 07.07.2011

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?


Re: Underscore problem - DeLexia - 07.07.2011

*bump* Help me please


Re: Underscore problem - Cameltoe - 07.07.2011

#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] = ' ';
    }
}



Re: Underscore problem - Harry_Sandhu - 07.07.2011

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

Sorry for the Offtopic


Re: Underscore problem - Cameltoe - 07.07.2011

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


Re: Underscore problem - Hipflop - 07.07.2011

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