Jump to content
  • 0

Help on query sql..


Lil Troll

Question


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  276
  • Reputation:   24
  • Joined:  07/06/13
  • Last Seen:  

Hi guys can someone teach me how to properly fix these ladder. 

 

The NPC Ladder:

prontera,159,150,4	script	Fishing Ladder	723,{
	mainmenu:
	menu "Rank",FRank;
		FRank: 
			set .@frank,query_sql("SELECT `name`, `flevel`, `fexp`, `fpoints`, `fcaught` FROM `fishing_system` ORDER BY flevel DESC LIMIT 5",.@n$,.@fl,.@fe,.@fp,.@fc);
			mes "Hall Of Fame: Fishing Ladder"; 
			mes "^ff0000Name^000000:^ff5500[ FL ]^000000:^005500[ FE ]^000000:^55007f[ FP ]^000000:^55ffff[ FC ]^000000";
			for(set .@i,1; .@i <= .@frank; set .@i,.@i++) {
			mes .@i+". ["+.@n$[0]+"] ("+.@fl[0]+") ("+.@fe[0]+") ("+.@fp[0]+") ("+.@fc[0]+")"; 
			//cutin $FishingLadderRank$,3; 
			}
			next;
			menu "^005500[ Return ]^000000",mainmenu; 
			close;

Query Script:

function	script	Fishing_Exp	{ 
	callfunc "Fishing_Points";
	set .@fe,FishingNowExp;              						
		if(query_sql("SELECT `fexp` FROM `fishing_system` WHERE `name`='"+strcharinfo(0)+"'",.@fe )){
			for (.@i = 0; .@i < getarraysize($FishingEquips); .@i++) if(isequipped($FishingEquips[.@i])) {
				set FishingNowExp,FishingNowExp+$FishingEquipsExp[.@i];          
			}       
			query_sql("UPDATE `fishing_system` SET `fexp`='"+.@fe+"' WHERE `name`='"+strcharinfo(0)+"'");
		}
		else {
			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`itemID`,`itemcount`,`flevel`,`fexp` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+strcharinfo(0)+"','0','0','0','"+escape_sql(.@fe)+"' )");
		}
	if( FishingNowExp >= $FishingExpMax[ FishingLevel ] ) { 
		for ( set .@i, 1 ; .@i <= $FRankUpCutins ; set .@i, .@i + 1 ) {
			cutin $FRankUpPicNames$ + .@i, 1 ; 
			sleep2 $FLRankPerPic;                         		
			set .@fl,FishingLevel;							
		}	
			if(query_sql("SELECT `flevel` FROM `fishing_system` WHERE `name`='"+strcharinfo(0)+"'",.@fl )){	
				set FishingLevel, FishingLevel + 1 ; set FishingNowExp, 0 ;          
				dispbottom "Congratulations! Fishing Rank is promoted to ^ff0000" + $FishingLevelName$[ FishingLevel ] + "^000000" ;      
				query_sql("UPDATE `fishing_system` SET `flevel`='"+.@fl+"' WHERE `name`='"+strcharinfo(0)+"'");
			}
		else {
			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`flevel` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+strcharinfo(0)+"','0','0','"+escape_sql(.@fl)+"' )");
		}
		for (.@i = 0; .@i < getarraysize($SpecialFXLVL); .@i++) 
		specialeffect2 $SpecialFXLVL[.@i];    				
		} 
	if( FishingLevel >= 50) set FishingNowExp,FishingNowExp + 0;
return ; 
}

function	script	Fishing_Points	{
	if($FishingPointsToggle == 1) {    					
		set .@fp,#FishingPoints;              
		if(query_sql("SELECT `fpoints` FROM `fishing_system` WHERE `name`='"+strcharinfo(0)+"'",.@fp )){
			for (.@i = 0; .@i < getarraysize($FishingEquips); .@i++) if(isequipped($FishingEquips[.@i])) { 
			set #FishingPoints,#FishingPoints+$FishingEquipsPts[.@i];
			}
			set #FishingPoints,#FishingPoints+$FishingPoints[FishingLevel]; 	        	
			query_sql("UPDATE `fishing_system` SET `fpoints`='"+.@fp+"' WHERE `name`='"+strcharinfo(0)+"'");
		}
		else {
			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`itemID`,`itemcount`,`flevel`,`fexp`,`fpoints` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+strcharinfo(0)+"','0','0','0','0','"+escape_sql(.@fp)+"' )");
		} 
	}		
return; 
}

The Query:

DROP TABLE IF EXISTS `fishing_system`;
DROP TABLE IF EXISTS `fishingbox`;
CREATE TABLE IF NOT EXISTS `fishing_system` (
`account_id` int(11) unsigned NOT NULL default '0',
`char_id` int(11) unsigned NOT NULL default '0',
`name` varchar(30) NOT NULL DEFAULT '',
`itemID` INT( 11 ) NOT NULL ,
`itemcount` INT( 11 ) NOT NULL DEFAULT '0',
`flevel` INT( 11 ) NOT NULL DEFAULT '0',
`fexp` INT( 11 ) NOT NULL DEFAULT '0',
`fpoints` INT( 11 ) NOT NULL DEFAULT '0',
`fcaught` INT( 11 ) NOT NULL DEFAULT '0'
) ENGINE = MYISAM COMMENT = 'Lil Troll World of Fishing'; 

If I view the ladder on NPC, nothing shows, all have zero values including the name, but no error found.

Edited by Lil Troll
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


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

			for(set .@i,1; .@i <= .@frank; set .@i,.@i++) {
			mes .@i+". ["+.@n$[0]+"] ("+.@fl[0]+") ("+.@fe[0]+") ("+.@fp[0]+") ("+.@fc[0]+")"; 
			//cutin $FishingLadderRank$,3; 
			}

must be

			for(set .@i,0; .@i < .@frank; set .@i,.@i++) {
				mes (.@i+1) +". ["+ .@n$[.@i] +"] ("+.@fl[.@i]+") ("+.@fe[.@i]+") ("+.@fp[.@i]+") ("+.@fc[.@i]+")"; 
				//cutin $FishingLadderRank$,3; 
			}

to display all values in the arrays

 

Some comments

function	script	Fishing_Exp	{ 
	callfunc "Fishing_Points";
	set .@fe,FishingNowExp;              						
	if(query_sql("SELECT `fexp` FROM `fishing_system` WHERE `name`='"+strcharinfo(0)+"'",.@fe )) {
		set .@size, getarraysize($FishingEquips);// computation before to avoid multiple computation in the loop
		for (.@i = 0; .@i < .@size; .@i++)
			if(isequipped($FishingEquips[.@i]))// don't know if it's working as intended... but if the player equip multiple item at once, he got more exp
				set FishingNowExp,FishingNowExp+$FishingEquipsExp[.@i];
		set .@fe,FishingNowExp;// I think you forgot to update the new exp for the query
		query_sql("UPDATE `fishing_system` SET `fexp`='"+.@fe+"' WHERE `name`='"+strcharinfo(0)+"'");
	}
	else
		query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`itemID`,`itemcount`,`flevel`,`fexp` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+ escape_sql( strcharinfo(0) ) +"','0','0','0','"+ .@fe +"' )");// no need escape sql for a number.. but for the name yes	if( FishingNowExp >= $FishingExpMax[ FishingLevel ] ) { 
		for ( set .@i, 1 ; .@i <= $FRankUpCutins ; set .@i, .@i + 1 ) {
			cutin $FRankUpPicNames$ + .@i, 1 ; 
			sleep2 $FLRankPerPic;                         		
			set .@fl,FishingLevel;							
		}	
		if(query_sql("SELECT `flevel` FROM `fishing_system` WHERE `name`='"+ escape_sql( strcharinfo(0) ) +"'",.@fl )){	
			set FishingLevel, FishingLevel + 1 ;
			set FishingNowExp, 0 ;          
			dispbottom "Congratulations! Fishing Rank is promoted to ^ff0000" + $FishingLevelName$[ FishingLevel ] + "^000000" ;      
			query_sql("UPDATE `fishing_system` SET `flevel`='"+.@fl+"' WHERE `name`='"+ escape_sql( strcharinfo(0) ) +"'");
		}
		else {
			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`flevel` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+ escape_sql( strcharinfo(0) ) +"','0','0','"+ .@fl +"' )");
		}
		for (.@i = 0; .@i < getarraysize($SpecialFXLVL); .@i++) 
			specialeffect2 $SpecialFXLVL[.@i];    				
	}
	if( FishingLevel >= 50)
		set FishingNowExp,FishingNowExp + 0;// + 0 ?? what's the point?
	return ; 
}

function	script	Fishing_Points	{
	if($FishingPointsToggle == 1) {    					
		set .@fp,#FishingPoints;              
		if(query_sql("SELECT `fpoints` FROM `fishing_system` WHERE `name`='"+ escape_sql( strcharinfo(0) ) +"'",.@fp )){
			for (.@i = 0; .@i < getarraysize($FishingEquips); .@i++)
				if(isequipped($FishingEquips[.@i]))
					set #FishingPoints,#FishingPoints+$FishingEquipsPts[.@i];

			set #FishingPoints,#FishingPoints+$FishingPoints[FishingLevel];
			set .@fp,#FishingPoints;// You forgot to update the new points for the query
			query_sql("UPDATE `fishing_system` SET `fpoints`='"+.@fp+"' WHERE `name`='"+ escape_sql( strcharinfo(0) ) +"'");
		}
		else {
			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`itemID`,`itemcount`,`flevel`,`fexp`,`fpoints` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+ escape_sql( strcharinfo(0) ) +"','0','0','0','0','"+ .@fp +"' )");
		} 
	}		
	return; 
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  276
  • Reputation:   24
  • Joined:  07/06/13
  • Last Seen:  

WOw thanks for the reply Sir Capuche, I actually make the script working my self before i look at your post, but i will apply what you had teach me, thank so much, here is my working script.
 
When fishing level reach to 50, no mo exp will be given the the player. :)

if( FishingLevel >= 50)set FishingNowExp,FishingNowExp + 0;// + 0 ?? what's the point?

I just made some corrections, Yes sir used first equip computation to set how many bonuses are given if multiple equip are equipped.
Script: 
I only post the fishing points, but i manage to make all vars to work and read on query. :)

function	script	Fishing_Points	{if($@Toggle == 1 || $@Toggle == 2 || $@Toggle == 3 || $@Toggle == 4) { // Fishing Points! Can be toggled to on/off.		for (.@i = 0; .@i < getarraysize($@FishingEquips); .@i++) if(isequipped($@FishingEquips[.@i])) {  			set #FishingPoints,#FishingPoints+$@FishingEquipsPts[.@i];		}												set #FishingPoints,#FishingPoints+$@FishingPoints[FishingLevel]; 	        			if(query_sql("SELECT `fpts` FROM `fishing_system` WHERE `name` = '"+strcharinfo(0)+"'",.@fpts)){ 			set .@fpts,#FishingPoints;			query_sql("UPDATE `fishing_system` SET `fpts` = '"+.@fpts+"' WHERE `name` = '"+strcharinfo(0)+"'");		}		else {			query_sql("INSERT INTO `fishing_system` (`account_id`,`char_id`,`name`,`fpts` ) VALUES ('"+getcharid(3)+"','"+getcharid(0)+"','"+strcharinfo(0)+"','"+escape_sql(.@fpts)+"')");		} 	}				return; }

Querry: 

DROP TABLE IF EXISTS `fishing_box`;DROP TABLE IF EXISTS `fishingbox`;DROP TABLE IF EXISTS `fishing_system`;CREATE TABLE IF NOT EXISTS `fishing_system` (`account_id` int(11) unsigned NOT NULL default '0',`char_id` int(11) unsigned NOT NULL default '0',`name` varchar(30) NOT NULL DEFAULT '',`flvl` INT( 11 ) NOT NULL DEFAULT '0',`fexp` INT( 11 ) NOT NULL DEFAULT '0',`fpts` INT( 11 ) NOT NULL DEFAULT '0',`fcot` INT( 11 ) NOT NULL DEFAULT '0',`fsuc` INT( 11 ) NOT NULL DEFAULT '0',`ffail` INT( 11 ) NOT NULL DEFAULT '0',`fenc` INT( 11 ) NOT NULL DEFAULT '0',`fmom` INT( 11 ) NOT NULL DEFAULT '0',`item_id` INT( 11 ) NOT NULL DEFAULT '0',`item_count` INT( 11 ) NOT NULL DEFAULT '0') ENGINE = MYISAM COMMENT = 'Lil Troll World of Fishing';
FRank: 			set .@frank,query_sql("SELECT `name`, `flvl`, `fexp`, `fpts`, `fcot` FROM `fishing_system` ORDER BY flvl DESC LIMIT 5",.@n$,.@fl,.@fe,.@fp,.@fc);			mes "Hall Of Fame: Fishing Ladder"; 			mes "^ff0000Name^000000:^ff5500[ FL ]^000000:^005500[ FE ]^000000:^55007f[ FP ]^000000:^55ffff[ FC ]^000000";			for(set .@i,1; .@i <= .@frank; set .@i,.@i++) {			mes .@i+". ["+.@n$[0]+"] ("+.@fl[0]+") ("+.@fe[0]+") ("+.@fp[0]+") ("+.@fc[0]+")"; 			//cutin $FishingLadderRank$,3; 			}			next;			menu "^005500[ Return ]^000000",mainmenu; 			close;

The ladder above: ^ ^ ^

:D
 
Im going to use this one you made: 
 

for(set .@i,0; .@i < .@frank; set .@i,.@i++) {mes (.@i+1) +". ["+ .@n$[.@i] +"] ("+.@fl[.@i]+") ("+.@fe[.@i]+") ("+.@fp[.@i]+") ("+.@fc[.@i]+")";//cutin $FishingLadderRank$,3; }

Again sir Capuche, thanks so much i ate so much information today! :)

Sorry I misread the name.

Edited by Lil Troll
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:  

Again sir Skorm, thanks so much i ate so much information today!
It's @Capuche not @Skorm :D
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  276
  • Reputation:   24
  • Joined:  07/06/13
  • Last Seen:  

 

Again sir Skorm, thanks so much i ate so much information today!
It's @Capuche not @Skorm :D

Havnt seen that one, ohhh my, sorry sir Capuche. Thanks again. Edited the post.

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