Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Share Posted May 4, 2012 (edited) set .@menu$,""; for( set .@i, 1; .@i <= 39; set .@i, .@i+1 ) { query_sql("SELECT `guild_id` FROM `house` WHERE `house_id` = '" + .@i + "'", .@check); if ( .@check ) { set .@menu$, ""+ .@menu$ +"House No. [^006633" + .@i + "^000000] - [^FF0000Reserved^000000]"; } else { set .@menu$, ""+ .@menu$ +"House No. [^006633" + .@i + "^000000] - [^006633Empty^000000]"; } set .@menu$, .@menu$ + ":"; } CREATE TABLE IF NOT EXISTS `house` ( `house_id` tinyint(11) unsigned NOT NULL default '0', `guild_id` smallint(11) unsigned NOT NULL default '0', `guild_name` varchar(30) NOT NULL default '', `htime` tinyint(11) unsigned NOT NULL default '0', `mtime` tinyint(11) unsigned NOT NULL default '0', `stime` tinyint(11) unsigned NOT NULL default '0', `day` tinyint(11) unsigned NOT NULL default '0', `mount` tinyint(11) unsigned NOT NULL default '0', `year` smallint(11) unsigned NOT NULL default '0', PRIMARY KEY (`house_id`) ) ENGINE=MyISAM; Hi all I'm doing the rental house but have problem about menu which use for loop work together but i get error when house no. 10+ was reserved how to fix it? thank you Edited May 4, 2012 by Mechomorph XD Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 (edited) your .@check i think is only querying how many houses you have from 1 to 39 >.< and nothing to check if they are reserve or not and your query is inside the loop should have been outside and why are you looping from 1 to 39 and your query has a WHERE `house_id` which is a primary key and unique so that should only return 1.. EDIT: are there values in your house already like from 1-39? how about adding another column "reserved" or something to check if that house has been reserved Edited May 4, 2012 by deathscythe13 Quote Link to comment Share on other sites More sharing options...
Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Author Share Posted May 4, 2012 (edited) i use sql update guild_id and query guild_id from db for check that house was reserved or not which in db, all columns are be zero except the house_id column (1-39) Edited May 4, 2012 by Mechomorph XD Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 ohh ok how about this: set .@menu$,""; set .@house, query_sql("SELECT guild_id FROM `house` WHERE 1",.@check); for( set .@i, 0; .@i < .@house; set .@i , .@i+ 1) { if(.@check[.@i]) set .@menu$, ""+ .@menu$ +"House No. [^006633" + .@i + "^000000] - [^FF0000Reserved^000000]"; else set .@menu$, ""+ .@menu$ +"House No. [^006633" + .@i + "^000000] - [^006633Empty^000000]"; set .@menu$, .@menu$ + ":"; } didn't test it yet, maybe in a few minutes Quote Link to comment Share on other sites More sharing options...
Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Author Share Posted May 4, 2012 set .@house, query_sql("SELECT guild_id FROM `house` WHERE 1",.@check); what's the line mean? Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 (edited) .@house means it counts all the data in the `house` table while .@check gets the guild_id of each house so if you have 39 houses your .@house = 39, i only iterate starting from 0 though but you can change it.. and .@check is an array so if .@check[0] which is the first row of your house it returns the "guild_id of the first row" you can try also in the actual sql "SELECT guild_id FROM `house` WHERE 1" if you want to test it out too , im sorry im not good at explaining >.< Edited May 4, 2012 by deathscythe13 Quote Link to comment Share on other sites More sharing options...
Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Author Share Posted May 4, 2012 NOT work, error too Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 (edited) i tried it here its working fine the menu are showing up EDIT: can you tell me what errors do you have now? here is the screenshot if you want: Edited May 4, 2012 by deathscythe13 Quote Link to comment Share on other sites More sharing options...
Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Author Share Posted May 4, 2012 i received gravity error or my client have problem cuz i use custom map Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 there's no error in your script right? >.< try putting the npc first in other places aside from custom map, if it wont error then must be the client, also when you loggedin you get error directly? or when you only talk to the npc? Quote Link to comment Share on other sites More sharing options...
Mechomorph XD Posted May 4, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 71 Reputation: 1 Joined: 03/06/12 Last Seen: January 22, 2021 Author Share Posted May 4, 2012 (edited) IT work, i know about problem already thank a lot, deathscythe13 Edited May 4, 2012 by Mechomorph XD Quote Link to comment Share on other sites More sharing options...
deathscythe13 Posted May 4, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 118 Reputation: 7 Joined: 01/25/12 Last Seen: February 11, 2023 Share Posted May 4, 2012 np Quote Link to comment Share on other sites More sharing options...
Question
Mechomorph XD
Hi all
I'm doing the rental house but have problem about menu which use for loop work together
but i get error when house no. 10+ was reserved
how to fix it?
thank you
Edited by Mechomorph XDLink to comment
Share on other sites
11 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.