Jump to content
  • 0

Array Menu in Query HELP PLEASE..


nasagnilac

Question


  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

query_sql "SELECT `accountid`, `reward_id`, `reward_amount` FROM `rewardaccountnpc`", .@show_name$, .@show_item, .@show_amount;
		for(set @i, 0; @i < getarraysize(.@show_name$); set @i, @i+1){
                }
		getitem .@show_item[@i],.@show_amount[@i];


Hi.. anyone can help me arrange this script.. I just want to make a menu  just like this post-21795-0-42358300-1383980809_thumb.jpg.... The menu will show list of items from query and the query_sql will automaticaly delete the item on menu once it was gathered.

Edited by gmprestige
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2352
  • Joined:  10/28/11
  • Last Seen:  


query_sql( "SELECT `accountid`, `reward_id`, `reward_amount` FROM `rewardaccountnpc` ",.@acc_id,.@reward_id,.@reward_amount );

.@size = getarraysize( .@acc_id );

for( .@i = 0; .@i < .@size; .@i++ )

set .@menu$,.@menu$ + .@acc_id[.@i] +" - " + .@reward_amount[.@i] + " x "getitemname( .@reward_id[.@i] ) + ":";

.@i = select( .@menu$ ) - 1;

mes "Pick : "+.@acc_id[.@i];

mes "Reward : "+.@reward_amount[.@i] + " x "getitemname( .@reward_id[.@i] );

close;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

 thanks emistry its not working on me because of .@acc_id I just edit it and works fine... here...

query_sql( "SELECT `accountid`, `reward_id`, `reward_amount` FROM `rewardaccountnpc` ",.@acc_id$,.@reward_id,.@reward_amount );
.@size = getarraysize( .@acc_id$ );
for( .@i = 0; .@i < .@size; .@i++ )
	set .@menu$,.@menu$ +" "+getitemname( .@reward_id[.@i] ) + " x " + .@reward_amount[.@i] + ":";
.@i = select( .@menu$ ) - 1;
getitem .@reward_id[.@i],.@reward_amount[.@i];
query_sql "DELETE FROM `rewardaccountnpc` WHERE `accountid`='"+.@acc_id$+"',`reward_amount`=`"+.@reward_id[.@i]+"`,`reward_id`=`"+.@reward_amount[.@i]+"`";

my problem now is... it doesn't delete the item in the sql..

 

 

here is the sql

DROP TABLE IF EXISTS `ragnarok`.`rewardaccountnpc`;
CREATE TABLE  `ragnarok`.`rewardaccountnpc` (
  `accountid` tinytext NOT NULL,
  `reward_id` int(11) NOT NULL,
  `reward_amount` int(11) NOT NULL,
  KEY `accountid` (`accountid`(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  


prontera,150,150,0    script    Sample    100,{

    query_sql( "SELECT `accountid`, `reward_id`, `reward_amount` FROM `rewardaccountnpc` ",.@acc_id,.@reward_id,.@reward_amount );

    .@size = getarraysize( .@acc_id );

    for( .@i = 0; .@i < .@size; .@i++ )

        set .@menu$,.@menu$ + .@acc_id[.@i] +" - " + .@reward_amount[.@i] + " x "+getitemname( .@reward_id[.@i] ) + ":";

    .@i = select( .@menu$ ) - 1;

    mes "Pick : "+.@acc_id[.@i];

    mes "Reward : "+.@reward_amount[.@i] + " x "+getitemname( .@reward_id[.@i] );

    getitem .@reward_id[.@i], .@reward_amount[.@i];

    query_sql "DELETE FROM `rewardaccountnpc` WHERE (`accountid` = '"+getcharid(3)+"' AND `reward_id` = '"+.@reward_id[.@i]+ "') AND `reward_amount` = '"+.@reward_amount[.@i]+"'";

    close;

}

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Drop your table, use this one instead :

CREATE TABLE IF NOT EXISTS `rewardaccountnpc` (
  `account_id` int(11) unsigned NOT NULL,
  `reward_id` int(11) unsigned NOT NULL,
  `reward_amount` int(11) unsigned NOT NULL,
  KEY `account_id` (`account_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
prontera,150,150,0	script	Sample	100,{
	query_sql( "SELECT `accountid`, `reward_id`, `reward_amount` FROM `rewardaccountnpc` ",.@acc_id,.@reward_id,.@reward_amount );
	.@size = getarraysize( .@acc_id );
	for( .@i = 0; .@i < .@size; .@i++ )
		set .@menu$,.@menu$ + .@acc_id[.@i] +" - " + .@reward_amount[.@i] + " x "+getitemname( .@reward_id[.@i] ) + ":";
	.@i = select( .@menu$ ) - 1;
	mes "Pick : "+.@acc_id[.@i];
	mes "Reward : "+.@reward_amount[.@i] + " x "+getitemname( .@reward_id[.@i] );
	getitem .@reward_id[.@i], .@reward_amount[.@i],  .@acc_id[.@i];
	query_sql "DELETE FROM `rewardaccountnpc` WHERE (`accountid` = '"+ .@acc_id[.@i]+"' AND `reward_id` = '"+.@reward_id[.@i]+ "') AND `reward_amount` = '"+.@reward_amount[.@i]+"' limit 1";
	close;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

SOLVED ... Thanks to all

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...