[英]Passing an array variable through an associated array in PAWN (.p files)
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
. 我相信我想做的事情很简单,但是我在非
SA-MP
PAWN文件编程中找不到很多东西。 I have a '.p' file that is supposed to check an array's sandwich numbers against qualifier number arrays. 我有一个“ .p”文件,该文件应根据限定符数字数组检查数组的三明治数字。 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?
我正在尝试检查是否发生了我的spec_bacon_plus,如果发生了,我的all_bacon_plus是否发生了? If the number in spec_bacon_plus doesn't line up with the number in correct_spec_bacon_qual, display an error.
如果spec_bacon_plus中的数字与correct_spec_bacon_qual中的数字不一致,则显示错误。 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).
(例如30500是9094400,30100是9013400,30400是9013400,依此类推)。
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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.