Jump to content
  • 0
Sign in to follow this  
almarket23

available options cannot be selected. HELP please

Question

Hi everyone. Im trying to make a script however im having a trouble with the script that i make.
 
I want to make all the options be available. I mean as you can see only the first option is the only one that can be selected. it cannot be skipped. I want all the available options be selected by only entering the correct id number. as long as the id is available whatever id comes first i want the second or the other id can be selected as well.
 
I hope you get what i mean.
 
here is the script. please fix it for me. thanks a lot..

 

prontera,150,150,5	script	Usagi	89,{set .@n$, "[Miss Usagi]";checkstatus:query_sql("SELECT char_id,account_id,name,class,base_level,job_level FROM `char` ",@charid,@accntid$,@name$,@class$,@blevel$,@jlevel$);mes .@n$;mes "This are the Players that is already reached the max level. Please choose the player that you want to check the information.";mes "===================================";				for (.@i = 0; .@i < getarraysize(@blevel$); .@i += 1) {       				if ("99" == @blevel$[.@i]) {						mes ""+@charid[.@i]+" || "+@name$[.@i]+"";						}					}next;							input ( .@level );						for (.@i = 0; .@i < getarraysize(@charid); .@i += 1) {			if ( .@level != @charid[.@i] ) {			mes .@n$;			mes "The Character ID that you enter is not available. Please enter the correct Character ID.";			next;			switch(select("Re-enter Character ID")) { goto checkstatus;	}				}				mes .@n$;mes "Account ID: "+@accntid$[.@i]+"";mes "Character ID: "+@charid[.@i]+"";mes "Name : "+@name$[.@i]+"";mes "Class Type: "+@class$[.@i]+"";mes "Base Level: "+@blevel$[.@i]+"";mes "Job Level: "+@jlevel$[.@i]+"";close;		}}

and also if in case that there is no available player that reached lvl 99. I want this text be appeared.

 

 

"There's no Player/s reached level 99 yet."

 

Please help me. Thanks again.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

@@almarket23

 

query_sql("SELECT char_id,account_id,name,class,base_level,job_level FROM `char` ",@charid,@accntid$,@name$,@class$,@blevel$,@jlevel$);

it should be

query_sql("SELECT `char_id`,`account_id`,`name`,`class`,`base_level`,`job_level` FROM `char` ",@charid,@accntid$,@name$,@class$,@blevel$,@jlevel$);

Share this post


Link to post
Share on other sites
  • 0

Here:

prontera,150,150,5    script    Usagi    89,{set .@n$, "[Miss Usagi]";checkstatus:query_sql("SELECT char_id,account_id,name,class,base_level,job_level FROM `char` ",@charid,@accntid$,@name$,@class$,@blevel$,@jlevel$);mes .@n$;mes "This are the Players that is already reached the max level. Please choose the player that you want to check the information.";mes "===================================";    for (.@i = 0; .@i < getarraysize(@blevel$); .@i++ ) {        if ("99" == @blevel$[.@i]) {            mes ""+@charid[.@i]+" || "+@name$[.@i]+"";        }    }next;input ( .@level );for (.@i = 0; .@i < getarraysize(@charid); .@i++ )    if( .@level == @charid[.@i])        break;if ( .@i >= getarraysize(@charid) ) {    mes .@n$;    mes "The Character ID that you enter is not available. Please enter the correct Character ID.";    next;    switch(select("Re-enter Character ID")) { goto checkstatus;    }}mes .@n$;mes "Account ID: "+@accntid$[.@i]+"";mes "Character ID: "+@charid[.@i]+"";mes "Name : "+@name$[.@i]+"";mes "Class Type: "+@class$[.@i]+"";mes "Base Level: "+@blevel$[.@i]+"";mes "Job Level: "+@jlevel$[.@i]+"";close;}

You needed to go over whole array first, what you were doing is pretty much comparing first value, and if it didn't pass you'd send him to the basic menu. And I have some extra questions:

a) You know, redoing the query every time a wrong ID is entered is a nice way to refresh the list, but I'd keep it to another talk with NPC and leave the list as it was.

B) Why in the world would you get ALL players in the array and compare them to blevel 99 inside script engine when SQL query will do that way faster?

c) gotos are bad. period.

d) It'd be more safe to use the number that query returns instead of checking on array size all the time. Not that it's a problem when query is not running every wrong ID you enter, but it's still better to be safe :D The problem here when the query is refreshing is that it might return less players than before (let's say, GM changed level from 99 to 96 between queries), and that will leave garbage from previous query which getarraysize will count, but number that query_sql returns wouldn't.

Well, although the above version would work, I'd take the one that I fixed the above remarks in :D

prontera,150,150,5	script	Usagi	89,{set .@n$, "[Miss Usagi]";.@count = query_sql("SELECT `char_id`,`account_id`,`name`,`class`,`base_level`,`job_level` FROM `char` WHERE `base_level` = 99",@charid,@accntid$,@name$,@class$,@blevel$,@jlevel$);	while(1) {		mes .@n$;		mes "These are the Players who already reached the max level. Please input charID of the player that you want to check on.";		mes "===================================";		for (.@i = 0; .@i < .@count; .@i++ )			mes @charid[.@i]+" || "+@name$[.@i];		next;		input ( .@cid );		for (.@i = 0; .@i < .@count; .@i++ ) 			if( .@cid == @charid[.@i])				break;		if ( .@i >= .@count ) {			mes .@n$;			mes "The Character ID that you entered is not available. Please enter the correct Character ID.";			next;			select("Re-enter Character ID");			continue; // gotos are a nono		}		mes .@n$;		mes "Account ID: "+@accntid$[.@i];		mes "Character ID: "+@charid[.@i];		mes "Name : "+@name$[.@i];		mes "Class Type: "+jobname(@class$[.@i]);		mes "Base Level: "+@blevel$[.@i];		mes "Job Level: "+@jlevel$[.@i];		close;	}}

Share this post


Link to post
Share on other sites
  • 0

@@Garr

Thank you so much. This is exactly the thing that I want... Actually Garr the script that I showed is an example script only. The only thing that I really need is to how to select all available options if there is. Im having a problem with that. anyways thank you so much Garr you are so genius.. 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.