SA-MP Forums Archive
[SOLVED] Underscore - 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: [SOLVED] Underscore (/showthread.php?tid=120686)



[SOLVED] Underscore - KnooL - 12.01.2010

Is there any thing available that checks if a name has a underscore e.g. Frank_Pentangeli, and then removes it? so it would be Frank Pentangeli?

Thanks in advance.


Re: [UNSOLVED] Underscore - RyDeR` - 12.01.2010

Maybe with strfind and strdel?


Re: [UNSOLVED] Underscore - Virtual1ty - 12.01.2010

pawn Код:
stock GetPlayerNameEx(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: [UNSOLVED] Underscore - GTAguillaume - 12.01.2010

Код:
new name[MAX_PLAYER_NAME],tmp5[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME]);
tmp5 = strreplace("_"," ",name);
SetPlayerName(playerid,tmp5);
Код:
stock strreplace(trg[],newstr[],src[]) { //dutils
  new f=0;
  new s1[MAX_STRING];
  new tmp[MAX_STRING];
  format(s1,sizeof(s1),"%s",src);
  f = strfind(s1,trg);
  tmp[0]=0;
  while (f>=0) {
    strcat(tmp,ret_memcpy(s1, 0, f));
    strcat(tmp,newstr);
    format(s1,sizeof(s1),"%s",ret_memcpy(s1, f+strlen(trg), strlen(s1)-f));
    f = strfind(s1,trg);
  }
  strcat(tmp,s1);
  return tmp;
}
Код:
ret_memcpy(source[],index=0,numbytes) {
	new tmp[MAX_STRING];
	new i=0;
	tmp[0]=0;
	if (index>=strlen(source)) return tmp;
	if (numbytes+index>=strlen(source)) numbytes=strlen(source)-index;
	if (numbytes<=0) return tmp;
	for (i=index;i<numbytes+index;i++) {
		tmp[i-index]=source[i];
		if (source[i]==0) return tmp;
	}
	tmp[numbytes]=0;
	return tmp;
}
EDIT: Virtual1ty was first :b


Re: [UNSOLVED] Underscore - KnooL - 12.01.2010

NVM GOT IT FIXED WITH FORMAT(


Re: [UNSOLVED] Underscore - KnooL - 13.01.2010

Quote:
Originally Posted by Virtual1ty
pawn Код:
stock GetPlayerNameEx(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;
}
how i'd put this in onplayerconnect?


Re: [UNSOLVED] Underscore - AiVAMAN - 13.01.2010

Use GetPlayerNameEx(playerid) instead of GetPlayerName(playerid)


Re: [UNSOLVED] Underscore - Sergei - 13.01.2010

pawn Код:
stock GetPlayerNameEx(playerid)
{
    new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid,pname,sizeof(pname));
    new i = strfind(pname,"_",true);
    if(i != (-1)) pname[i] = ' ';
    return pname;
}



Re: [UNSOLVED] Underscore - KnooL - 13.01.2010

Still no answer on my question on how to change the player's name in OnPlayerConnect

Thanks in advance.


Re: [UNSOLVED] Underscore - Kurence - 13.01.2010

no it can't be done because in nicknames can't be " " (space)