viewing paste autotrade | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/**
 * Perform a autotrade action
 **/
void pc_autotrade_update(struct map_session_data *sd, enum e_pc_autotrade_update_action action) {
    int i;
    
    /* either way, this goes down */
    if( action != PAUC_START ) {
        if (SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'",map->autotrade_data_db,sd->status.char_id))
            Sql_ShowDebug(map->mysql_handle);
    }
    
    switch( action ) {
        case PAUC_REMOVE:
            if (SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' LIMIT 1",map->autotrade_merchants_db,sd->status.char_id))
                Sql_ShowDebug(map->mysql_handle);
            break;
        case PAUC_START: {
            char title[MESSAGE_SIZE*2+1];
            
            SQL->EscapeStringLen(map->mysql_handle, title, sd->message, strnlen(sd->message, MESSAGE_SIZE));
 
            if (SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s` (`account_id`,`char_id`,`sex`,`title`) VALUES ('%d','%d','%d','%s')",
                                        map->autotrade_merchants_db,
                                        sd->status.account_id,
                                        sd->status.char_id,
                                        sd->status.sex,
                                        title
                                        ))
                Sql_ShowDebug(map->mysql_handle);
        }
Viewed 683 times, submitted by Guest.