Jump to content
  • 0

Help me i have problem


Mechomorph XD

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

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 by Mechomorph XD
Link to comment
Share on other sites

11 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

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 by deathscythe13
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

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 by Mechomorph XD
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

set .@house, query_sql("SELECT guild_id FROM `house` WHERE 1",.@check);

what's the line mean?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

.@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 by deathscythe13
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

NOT work, error too :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

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:

screenfokragnarok003.jpg

Edited by deathscythe13
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

i received gravity error or my client have problem

cuz i use custom map

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   1
  • Joined:  03/06/12
  • Last Seen:  

IT work, i know about problem already :)

thank a lot, deathscythe13

Edited by Mechomorph XD
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...