I have a two misunderstanding.
#1

FIRST: which of these two variants is better and better to avoid the occurrence of errors?
1:
PHP код:
enum {
   
DIALOG_REGISTER,
   
DIALOG_LOGIN,
   
DIALOG_SELECT,
...
}; 
OR
2:
PHP код:
 #define DIALOG_REGISTER   1
  #define DIALOG_LOGIN   2
  #define DIALOG_SELECT   3
... 
I want to choose between these two variants to store ids from dialogs.


SECOND:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
IsPlayerConnected(playerid))
    {
        new 
sendername[MAX_PLAYER_NAME], string[1500];
        
mysql_escape_string(inputtextinputtextMAX_STRING);
        
//-------------------------------------------------------- 
if I use the mysql_escape_string function at the beginning it will work, I do not want to put it every time I put something in the database, and I do not even want to change all the mysq_format add-on% e, there are too many.

PS: i used ******Translate.
Reply
#2

I personally prefer an enum for dialog IDs, simply because you do not need to keep counting on and on. Also, if you add dialogs in between you'd either need to take an ID that doesn't belong there (a new one), or change all other IDs.
Other than that I don't think there's anything wrong with either solution, except that an enum is way more convenient. Also you can change all IDs at once if there are conflits by doing:

Код:
enum
{
DIALOG_REGISTER = 500,
DIALOG_LOGIN,
...
};
And the Dialog IDs will start at 500. Using defines you'd have to change all the IDs manually, or work with an offset from the start.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)