Vincent Posted August 2, 2013 Posted August 2, 2013 Hi, how can i fill a array out of a DB? There are 5 Colum's. Dont work: query_sql "SELECT `npc1`, `npc2`, `npc3`, `npc4`, `npc5` FROM `quest_db` WHERE `char_id` = " + getcharid(0) + " ", @array; And how can i check it with "if-command", if one of the arry's have a special number. This dont work... if ( @array[1-5] == 500 OR 100 ) do this Quote
KeyWorld Posted August 2, 2013 Posted August 2, 2013 Something like this I presume : query_sql("SELECT `npc1`, `npc2`, `npc3`, `npc4`, `npc5` FROM `quest_db` WHERE `char_id` = " + getcharid(0), .@npc1, .@npc2, .@npc3, .@npc4, .@npc5); for( set .@i,1; .@i<=5; set .@i, .@i + 1 ) { set .@var, getd(".@npc" + .@i); if( .@var != 500 && .@var != 100 ) { set .@fail, 1; break; } } if( .@fail ) { // not ok } else { // ok } Quote
Emistry Posted August 2, 2013 Posted August 2, 2013 query_sql "SELECT `npc1`, `npc2`, `npc3`, `npc4`, `npc5` FROM `quest_db` WHERE `char_id` = " + getcharid(0) + " ", .@npc1$,.@npc2$,.@npc3$,.@npc4$,.@npc5$; i dun understand the array part you mentioned.. Quote
Vincent Posted August 2, 2013 Author Posted August 2, 2013 I thing i have to save this as arry because of the 5 fileds. But i can use evey field as singel variable. But how can i check if the variables are "500" or "100"? Did the "if-command" support more than one variable as argument? Quote
Emistry Posted August 2, 2013 Posted August 2, 2013 if( .@npc1$ == 500 || .@npc1$ == 100 ){ // blablbala } just compare the value inside the array and the value u want... if you can briefly explain or tell us what you wanna do with that sql statement..perhap we can figure out another way for you.... like checking the value through SQL... Quote
Vincent Posted August 2, 2013 Author Posted August 2, 2013 There are 5 Field's (`npc1`, `npc2`, `npc3`, `npc4`, `npc5`) in the DB. I want to check if one of this fields have not 500 or 100 included. btw: 500 and 100 are only examples for the data's. Example: `500`, `500`, `500`, `500`, `100` -> ok, do if `500`, `500`, `500`, `500`, `400` -> not ok, do else Quote
Question
Vincent
Hi,
how can i fill a array out of a DB? There are 5 Colum's.
Dont work:
And how can i check it with "if-command", if one of the arry's have a special number.
This dont work...
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.