Replacing "_" with " " -
77ther - 08.02.2011
As subject says... I would like to replace "_" with " " in chat lines, any help?
Re: Replacing "_" with " " -
JaTochNietDan - 08.02.2011
Use the strfind function on the name of the person, for example:
pawn Код:
new name[24];
GetPlayerName(playerid,name,24);
name[strfind(name,"_")] = ' ';
After that code is executed, the name variable will now contain a space where there used to be an _.
This is only an example, you likely need to adapt it for your script.
Re: Replacing "_" with " " -
77ther - 08.02.2011
Quote:
Originally Posted by JaTochNietDan
Use the strfind function on the name of the person, for example:
pawn Код:
new name[24]; GetPlayerName(playerid,name,24); name[strfind(name,"_")] = ' ';
After that code is executed, the name variable will now contain a space where there used to be an _.
This is only an example, you likely need to adapt it for your script.
|
I might have little problems with that...
Re: Replacing "_" with " " - Unknown123 - 08.02.2011
Quote:
Originally Posted by 77ther
It's LARP edit, could you adapt it to that?
And where to put it? under ongamemodeinit or not?
|
Try to put it under:
pawn Код:
public OnPlayerText(playerid, text[])
Re: Replacing "_" with " " -
77ther - 08.02.2011
Quote:
Originally Posted by Unknown123
Try to put it under:
pawn Код:
public OnPlayerText(playerid, text[])
|
no, it should be adapted, I guess...
Re: Replacing "_" with " " -
DRIFT_HUNTER - 08.02.2011
My suggestion is to put it under OnPlayerConnect,right after you check for RP name
Why there?
1.You will use it just once and no need to edit anything
2.It will save/read player file with " " (space)
Re: Replacing "_" with " " -
77ther - 13.02.2011
Quote:
Originally Posted by DRIFT_HUNTER
My suggestion is to put it under OnPlayerConnect,right after you check for RP name
Why there?
1.You will use it just once and no need to edit anything
2.It will save/read player file with " " (space)
|
It accualy doesn't work..
EDIT:
I found this, maybe I have to do something with it?
Код:
new namestring = strfind(plname, "_", true);
Re: Replacing "_" with " " -
California - 13.02.2011
Quote:
Originally Posted by 77ther
It accualy doesn't work..
EDIT:
I found this, maybe I have to do something with it?
Код:
new namestring = strfind(plname, "_", true);
|
If their name doesn't have any underscore, it'll crash your server...
Try the code below.
pawn Код:
stock
Name( playerid )
{
new
ply_name [ 24 ]
;
GetPlayerName ( playerid , ply_name , sizeof ( ply_name ) ) ;
if ( playerid != 0xFFFF ) {
if ( strfind ( ply_name , "_" , true ) != -1 ) {
name [ strfind ( ply_name , "_" ) ] = ' ';
return ply_name;
}
}
return -1;
}
Re: Replacing "_" with " " -
Shadow™ - 13.02.2011
pawn Код:
stock GPN(playerid)
{
new string[24];
GetPlayerName(playerid,string,24);
new str[24];
strmid(str,string,0,strlen(string),24);
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if (str[i] == '_') str[i] = ' ';
}
return str;
}
Re: Replacing "_" with " " -
77ther - 13.02.2011
Quote:
Originally Posted by Shadow™
pawn Код:
stock GPN(playerid) { new string[24]; GetPlayerName(playerid,string,24); new str[24]; strmid(str,string,0,strlen(string),24); for(new i = 0; i < MAX_PLAYER_NAME; i++) { if (str[i] == '_') str[i] = ' '; } return str; }
|
I keep getting 26 errors after I put it under OnPlayerText