Returning Strings
#2

You're returning 2 types of data (1 is a string when you return "Result", the other one is a boolean when you return "false"). PAWN expects you to return the same data data type. A possible fix would be:

pawn Code:
stock Load(DataType[], Stat[], For[]) {
    new Result[128]; // Gets initialized to NULL
    if(strcmp(For, "None", true) == 0) {
        #pragma unused For
    }
    if(strcmp(DataType, "serverdata", true) == 0) {
        new Query[128];
        format(Query, 128, "SELECT * FROM serverdata LIMIT 1");
        mysql_query(Query);
        mysql_store_result();
        while(mysql_fetch_row_format(Query, "|")) {
            if(strcmp(Stat, "Name", true) == 0) {
                mysql_fetch_field_row(Result, "Name");
            }
            if(strcmp(Stat, "Mode", true) == 0) {
                mysql_fetch_field_row(Result, "Mode");
            }
            if(strcmp(Stat, "Map", true) == 0) {
                mysql_fetch_field_row(Result, "Map");
            }
        }
        mysql_free_result();
    }
    return Result; // Returns either the actual result or NULL
}
I hope that made sense, code is untested but should work fine.
Reply


Messages In This Thread
Returning Strings - by TheLazySloth - 22.01.2012, 12:12
Re: Returning Strings - by Sinner - 22.01.2012, 12:27
Re: Returning Strings - by TheLazySloth - 22.01.2012, 12:31
Re: Returning Strings - by Sinner - 22.01.2012, 12:35
Re: Returning Strings - by TheLazySloth - 22.01.2012, 12:36

Forum Jump:


Users browsing this thread: 3 Guest(s)