سؤال

I am new to the programming world (and very excited to be a part of it). I believe What I am trying to do is very simple, however I can't find a whole lot on PAWN file programming that isn't for SA-MP. I have a '.p' file that is supposed to check an array's sandwich numbers against qualifier number arrays. As far as I understand, I can pass an array through my code to check if it matches. These are my arrays:

+ new spec_bacon_plus[] = { 30500, 30100, 30400, 33100, 30300 } 
+ new correct_spec_bacon_qual[] = { 9094400, 9013400, 9013400, 9093400, 9094400 }
+ new all_bacon_plus[] = {
    9093400, /* add(1) bacon */ 
    9013400, /* add(2) bacon */ 
    9094400, /* add(3) bacon */ 
    9095400, /* add(4) bacon */ 
    9096400, /* add(6) bacon */ 
    9097400, /* add(8) bacon */ 
}

My code is below. I am trying to check if my spec_bacon_plus happen, and if they do, does my all_bacon_plus happen? If the number in spec_bacon_plus doesn't line up with the number in correct_spec_bacon_qual, display an error. I believe that they are 'associated' with each other due to their positions. (for example, 30500 is 9094400, 30100 is 9013400, 30400 is 9013400 and so on).

                    for(k = 0; k < sizeof spec_bacon_plus; k++) {
                        if(p_plu == spec_bacon_plus[k]) { /* the sandwich we rung up is the kth bacon sandwich */
                            for(m = 0; m < sizeof all_bacon_plus; m++) { /* check if the qualifer was any of the bacons */
                                if (p_qualifier == correct_spec_bacon_qual[m] && k != m ) /* && not in the slot that we expect */ 
                                    ok = 0; /*not cool*/
                                    pos_popup_dialog("THIS BACON IS NOT OK!");
                                        ok = 1;
                                        check_spec_bacon_plu = p_plu;
                                        check_spec_bacon_qual = p_qualifier;
                                        check_spec_bacon_qual_should_be = correct_spec_bacon_qual[k];

Any ideas?

هل كانت مفيدة؟

المحلول

I figured it out...

for(k = 0; k < sizeof spec_bacon_plus; k++) {
    if(p_plu == spec_bacon_plus[k]) { /* the sandwich we rung up is the kth bacon sandwich */
        for(m = 0; m < sizeof all_bacon_plus; m++) { /* check if the qualifer was any of the bacons */
            if (p_qualifier == all_bacon_plus[m]) /* && not in the slot that we expect */ 
                for(l = 0; l < sizeof correct_spec_bacon_qual; l++) {
                    if (p_qualifier == correct_spec_bacon_qual[k])
                        pos_popup_dialog("THIS BACON IS OK!");
                    else pos_popup_dialog("THIS BACON NOT IS OK!");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top