Get Data from MySQL in pawn for #define
#2

Yes it's very possible, everything is possible in coding!

You just need arrays instead of macros which are constants and you cannot change constants.

Here is a relative example: (note: i haven't used mysql in a while, syntax can be different in latest version)
PHP код:
#define MAX_MESSAGES 10
#define MAX_MESSAGE_SIZE 144
new myMessages[MAX_MESSAGES][MAX_MESSAGE_SIZE];
public 
OnGameModeInit() {
    new 
mySQL mysql_connect(...);
    
mysql_tquery(mySQL
        
"SELECT * FROM your_table LIMIT "#MAX_MESSAGS"", 
        
"OnMessagesLoad""\1"
    
);
}
forward OnMessageLoad();
public 
OnMessageLoad() {
    for (new 
0cache_get_row_count(); i++) {
        
cache_get_field_content(i"field_name"myMessages[i], MAX_MESSAGE_SIZE);
    }
    
// now you have all messages saved in your array "myMessages"
    // to access them, say print a message at index 5
    
printf("message 5: %s"myMessage[5]);

Reply


Messages In This Thread
Get Data from MySQL in pawn for #define - by GospodinX - 09.05.2018, 19:47
Re: Get Data from MySQL in pawn for #define - by Gammix - 09.05.2018, 20:05
Re: Get Data from MySQL in pawn for #define - by GospodinX - 09.05.2018, 21:08
Re: Get Data from MySQL in pawn for #define - by Banditul18 - 09.05.2018, 21:42
Re: Get Data from MySQL in pawn for #define - by AmigaBlizzard - 09.05.2018, 21:52
Re: Get Data from MySQL in pawn for #define - by GTLS - 10.05.2018, 04:49
Re: Get Data from MySQL in pawn for #define - by GospodinX - 10.05.2018, 08:39
Re: Get Data from MySQL in pawn for #define - by Dayrion - 10.05.2018, 08:58
Re: Get Data from MySQL in pawn for #define - by Sew_Sumi - 10.05.2018, 09:42

Forum Jump:


Users browsing this thread: 1 Guest(s)