Vincent Posted August 2, 2013 Group: Members Topic Count: 130 Topics Per Day: 0.03 Content Count: 528 Reputation: 18 Joined: 09/11/12 Last Seen: March 5, 2020 Share 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 Link to comment Share on other sites More sharing options...
KeyWorld Posted August 2, 2013 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share 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 Link to comment Share on other sites More sharing options...
Emistry Posted August 2, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 3 hours ago Share 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 Link to comment Share on other sites More sharing options...
Vincent Posted August 2, 2013 Group: Members Topic Count: 130 Topics Per Day: 0.03 Content Count: 528 Reputation: 18 Joined: 09/11/12 Last Seen: March 5, 2020 Author Share 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 Link to comment Share on other sites More sharing options...
Emistry Posted August 2, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 3 hours ago Share 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 Link to comment Share on other sites More sharing options...
Vincent Posted August 2, 2013 Group: Members Topic Count: 130 Topics Per Day: 0.03 Content Count: 528 Reputation: 18 Joined: 09/11/12 Last Seen: March 5, 2020 Author Share 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 Link to comment Share on other sites More sharing options...
Vincent Posted August 2, 2013 Group: Members Topic Count: 130 Topics Per Day: 0.03 Content Count: 528 Reputation: 18 Joined: 09/11/12 Last Seen: March 5, 2020 Author Share Posted August 2, 2013 seem good. Will be tested... Quote Link to comment Share on other sites More sharing options...
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...
Link to comment
Share on other sites
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.