07.07.2012, 20:29
Hello eveybody! I have curiuos question. Which of 2 methods bellow of using strings uses less memory and gives better performance:
Thank you for yours answers.
Код:
//First method. I think that this method is worse than second, because there are some string. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case 477: { if(response) { new string[113],name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(string,sizeof(string),"Hello! Your name is %s. Your wanted level is %d stars. You have %d dollars.",name,GetPlayerWantedLevel(playerid),GetPlayerMoney(playerid)); SendClientMessage(playerid,-1,string); } } case 1025: { if(response) { new string[128],name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(string,sizeof(string),"Hello! Your name is %s. Your wanted level is %d stars. You have %d $. Have a nice day! :)",name,GetPlayerWantedLevel(playerid),GetPlayerMoney(playerid)); SendClientMessage(playerid,-1,string); } } } return 0; } //================================================================================== //Second method. I think that this method is better than first, because it uses only one string. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { new string[128],name[MAX_PLAYER_NAME]; switch(dialogid) { case 477: { if(response) { GetPlayerName(playerid,name,sizeof(name)); format(string,sizeof(string),"Hello! Your name is %s. Your wanted level is %d stars. You have %d dollars.",name,GetPlayerWantedLevel(playerid),GetPlayerMoney(playerid)); SendClientMessage(playerid,-1,string); } } case 1025: { if(response) { GetPlayerName(playerid,name,sizeof(name)); format(string,sizeof(string),"Hello! Your name is %s. Your wanted level is %d stars. You have %d $. Have a nice day! :)",name,GetPlayerWantedLevel(playerid),GetPlayerMoney(playerid)); SendClientMessage(playerid,-1,string); } } } return 0; }