PDA

View Full Version : Name without "_"


InsaneESN
20/05/2010, 11:57 AM
How can I remove the "_" in names? that is, when writing in chat eg Firstname_Lastname not occur, appear FirstName Lastname .. I hope you understand

Thanks

[MWR]Blood
20/05/2010, 11:58 AM
I think it's not possible, im not fully sure.

InsaneESN
20/05/2010, 12:10 PM
I have a GM with something, but do not know how to look ..

johnnyc
20/05/2010, 12:18 PM
I think it's not possible, im not fully sure.
It is possible, i saw on RP server when you do /me it doesnt show the "_"

Calgon
20/05/2010, 12:25 PM
It's done by exploding the two values in to two separate strings, or removing the "_" (underscore) from the string. I have created a function, which will do this:


stock ReturnPlayerName( playerid )
{
new
NameString[ MAX_PLAYER_NAME ],
stringPos;

GetPlayerName( playerid, NameString, MAX_PLAYER_NAME );

stringPos = strfind( NameString, "_" );

NameString[ stringPos ] = ' ';
return NameString;
}


Thanks to Norn for releasing a similar function in Carlitos Roleplay, note if there's only one underscore, this will work - if there's more, it will only remove the first instance.

Norn's code:


stock GetPlayerNameEx(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
for(new i; i < MAX_PLAYER_NAME; i++) if (string[i] == '_') string[i] = ' ';
return string;
}

InsaneESN
20/05/2010, 12:44 PM
Does not work: (

In GM that I saw (http://forum.sa-mp.com/index.php?topic=148926.0) but do not know how to look, can you please try .. thanks

RoamPT
20/05/2010, 12:45 PM
Just replace your GetPlayerName with GetPlayerNameEx

InsaneESN
20/05/2010, 12:49 PM
Replace everywhere there "GetPlayerName" ?

InsaneESN
20/05/2010, 02:53 PM
Someone help me?

Jochemd
20/05/2010, 03:41 PM
Oh please, just do what he said! Use GetPlayerNameEx in stead of GetPlayerName on placed where you get names, so yes, replace all ;-)

InsaneESN
20/05/2010, 04:42 PM
I did as you said

C:\LA-RP\gamemodes\la-rp.pwn(1686) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(1686) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(1731) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(1731) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(1760) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(1760) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(1827) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(1827) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(2098) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(2098) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(2666) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(2666) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(2869) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(2869) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(2905) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(2905) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3250) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3250) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3824) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3824) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3855) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3855) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3868) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3868) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3881) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3881) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3894) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3894) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3907) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3907) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3920) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3920) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3932) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3932) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3944) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3944) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(3979) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(3979) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(4002) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(4002) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(4003) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(4003) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(4028) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(4028) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(4573) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(4573) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(5928) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(5928) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(6300) : error 017: undefined symbol "GetPlayerNameEx"
C:\LA-RP\gamemodes\la-rp.pwn(6300) : warning 202: number of arguments does not match definition
C:\LA-RP\gamemodes\la-rp.pwn(7170) : error 017: undefined symbol "GetPlayerNameEx"

RoamPT
20/05/2010, 04:55 PM
Dear god, did you at least putted this on your script as Freddo [BINMAN] said? Guess not.


stock GetPlayerNameEx(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
for(new i; i < MAX_PLAYER_NAME; i++) if (string[i] == '_') string[i] = ' ';
return string;
}

Calgon
21/05/2010, 07:34 AM
You can't simply find+replace it, due to the 3 parameters (playerid, string, stringlen).

Replace each with the new code and remove the old code. So,


GetPlayerName( playerid, sendername, sizeof( sendername ) );


needs to become


sendername = GetPlayerNameEx( playerid );

InsaneESN
21/05/2010, 06:24 PM
So let me see what I understood, they place these in GM:

]

stock GetPlayerNameEx(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
for(new i; i < MAX_PLAYER_NAME; i++) if (string[i] == '_') string[i] = ' ';
return string;
}



And after all find the "GetPlayerName( playerid, sendername, sizeof( sendername ) );" replace with "GetPlayerNameEx( playerid, sendername, sizeof( sendername ) );" ?

Sorry if I understood well: (

DJDhan
21/05/2010, 06:33 PM
So let me see what I understood, they place these in GM:

]

stock GetPlayerNameEx(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
for(new i; i < MAX_PLAYER_NAME; i++) if (string[i] == '_') string[i] = ' ';
return string;
}



And after all find the "GetPlayerName( playerid, sendername, sizeof( sendername ) );" replace with "GetPlayerNameEx( playerid, sendername, sizeof( sendername ) );" ?

Sorry if I understood well: (


]
You can't simply find+replace it, due to the 3 parameters (playerid, string, stringlen).

Replace each with the new code and remove the old code. So,


GetPlayerName( playerid, sendername, sizeof( sendername ) );


needs to become


sendername = GetPlayerNameEx( playerid );




:roll:

InsaneESN
21/05/2010, 06:36 PM
I get ready :D .. but it's kinda hard

BLAbla93
21/05/2010, 06:46 PM
its in one of the script request threads if you look ;)

InsaneESN
21/05/2010, 07:11 PM
Thanks

InsaneESN
26/05/2010, 09:42 AM
Can someone help me? unable to solve, just gives me errors :(.. please, use the GM GTA roleplay.

Joe Staff
26/05/2010, 10:04 AM
It gives you errors becaue the parameters are different. Because you're obviously a noob, here's a version with the same parameters as GetPlayerName.

stock GetPlayerNameEx(playerid,name[],len=sizeof(name))
{
GetPlayerName(playerid,name,len);
for(new cell;cell<strlen(name);cell++)if(name[cell]=='_')name[cell]=' ';
}
Now add that and replace GetPlayerName with GetPlayerNameEx ONLY when it's being used in chat. (like a command)

This whole thing was typed on my ZuneHD :D

xMichaelx
06/12/2011, 02:03 AM
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
}

CMD:ooc(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
strreplace(sendername, '_', ' ');
format(string, sizeof(string), "(( %s: %s ))", sendername, params);
SendClientMessageToAll(COLOR_WHITE, string);
return 1;
}

Just an example