Roleplay Name? -
Reklez - 18.03.2012
how to remove '_' from their names example my name is
it would be something like this when use in chat
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 '_'
Re: Roleplay Name? -
antonio112 - 18.03.2012
pawn Код:
stock pNameEx(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof Name);
strreplace(Name, '_', ' ');
return Name;
}
Re: Roleplay Name? -
ReneG - 18.03.2012
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;
}
Re: Roleplay Name? - Nicholas. - 18.03.2012
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;
}
Re: Roleplay Name? -
Reklez - 18.03.2012
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?
Re: Roleplay Name? -
ReneG - 18.03.2012
ClearAnimations(playerid);
Search the wiki. It has all the functions you need.
Re: Roleplay Name? -
Reklez - 18.03.2012
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;
}
Re: Roleplay Name? - Nicholas. - 18.03.2012
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;
}
Re: Roleplay Name? -
Reklez - 18.03.2012
thank you
Код:
Nicholas
VincentDunn
Antonio
rep all of you
Re: Roleplay Name? -
Skribblez - 18.03.2012
I was looking for this, thanks.