split or for?
#1

Hi. I deleting "_" from nick, and I question what is more optimal for the server. I mean load.

First way:

Код:
new name[MAX_PLAYER_NAME];
new name_split[3][MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid,name,sizeof(name));
split(name,name_split,'_');
format(string,sizeof(string),"Hi %s %s",name_split[0],name_split[1]);
SendClientMessage(playerid,some_color,string);
second way:

Код:
stock SomeFunction(name[])
{
  for(new i = 0; name[i] != 0; i++)
  if(name[i] == '_') name[i] = ' ';
}

new name[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid,name,sizeof(name));
SomeFunction(name);
format(string,sizeof(string),"Hi %s",name);
SendClientMessage(playerid,some_color,string);
Reply


Messages In This Thread
split or for? - by ErF - 26.02.2010, 17:36
Re: split or for? - by Jefff - 26.02.2010, 17:43
Re: split or for? - by dice7 - 26.02.2010, 18:10

Forum Jump:


Users browsing this thread: 1 Guest(s)