Removing "_" in a name. -
milanosie - 24.06.2012
Been a while since I was in need of help, but I can't seem to figure this one out.
How do I remove the "_" in a name.
For example
pawn Код:
if(IsPlayerInAnyVehicle(playerid) && ison911[playerid] != 1 && isoncall[playerid] == false && h >= 10 && Pmaskon[playerid] == mask_off && carwindow[GetPlayerVehicleID(playerid)] == 0)
{
format(string, sizeof(string), "[%s][Windows Closed] %s : %s", acc,name, text);
LocalChat(5.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
printf("[LOCAL CHAT] %s, %s", name, text);
}
Let's say my name is Pieter_Awesome.
How can I show it as Pieter Awesome instead of Pieter_Awesome?
I only know it has something to do with strfind, but can't seem to figure out what.
Re: Removing "_" in a name. -
Joey^ - 24.06.2012
pawn Код:
stock GetNameEx(iPlayer) { // Made by Joey^
new
sPName[MAX_PLAYER_NAME],
iUSPos;
GetPlayerName(iPlayer, sPName, MAX_PLAYER_NAME);
iUSPos = strfind(sPName, "_");
strdel(sPName, iUSPos, (iUSPos + 1)), strins(sPName, " ", iUSPos, MAX_PLAYER_NAME);
return sPName;
}
Use that function to get the player's name without the underscore.
Example:
pawn Код:
if(IsPlayerInAnyVehicle(playerid) && ison911[playerid] != 1 && isoncall[playerid] == false && h >= 10 && Pmaskon[playerid] == mask_off && carwindow[GetPlayerVehicleID(playerid)] == 0)
{
format(string, sizeof(string), "[%s][Windows Closed] %s : %s", acc, GetNameEx(playerid), text);
LocalChat(5.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
printf("[LOCAL CHAT] %s, %s", name, text);
}
Re: Removing "_" in a name. -
Vince - 24.06.2012
pawn Код:
name[strfind(name, "_")] = ' ';
If you allow names without underscores it might generate out of bounds errors.
Re: Removing "_" in a name. -
milanosie - 24.06.2012
Will test it out,
EDIT: Works, danke, tag, gracias, thanks, dank u, merci
Re: Removing "_" in a name. -
Lorenzo* - 10.07.2012
is there way i can remove it complete by defining it as Ё Ё for all of the script or if so can i just remove it in the onplayerchat so on