Hey guys, I was wondering if you could debug my script... :/ Its changing all the char_ids in the table to the same thing and updating them all...
brasilis.gat,265,74,5 script Fishing Board 857,{
mes "[Fishing Board]";
mes "Welcome to the Fishing board!";
next;
mes "[Fishing Board]";
mes "What would you like to do?";
menu "View Fishing Ranks",Ranks,"Turn in some fish",Fish;
Ranks:
query_sql "select name, score from fishladder order by score desc limit "+ getvariableofnpc(.showpage,"FISHCONF"), .@name$, .@score;
if ( !getarraysize(.@name$) ) {
next;
mes "[Fishing Board]";
mes "The ladder currently is empty";
close;
}
for ( set .@j,0; .@j < getarraysize(.@name$); set .@j, .@j + getvariableofnpc(.showpage,"FISHCONF") ) {
next;
mes "[Fishing Board]";
for ( set .@i, .@j; .@i < (getvariableofnpc(.showpage,"FISHCONF") + .@j) && .@i < getarraysize(.@name$); set .@i, .@i + 1 ) {
mes "^996600"+ (.@i+1) +": ^006699"+ .@name$[.@i] +" ^00AA00["+ .@score[.@i] +"]";
}
close;
}
Fish:
next;
mes "[Fishing Board]";
mes "What fish would you like to turn in?";
menu "Blue Fish",bFish;
bFish:
next;
mes "Checking inventory...";
sleep2 3000;
if(countitem(6096)){
set .@noitem,countitem(6096);
if ( query_sql("SELECT `score` FROM `fishladder` WHERE `char_id`="+getcharid(0), .@score) ) {
// row exists, update it
query_sql "UPDATE `fishladder` SET `score` = `score` + "+.@noitem+",`char_id` = "+getcharid(0)+"";
} else {
// else, insert new row
query_sql "INSERT INTO fishladder (char_id,`name`,score) VALUES ("+getcharid(0)+",'"+strcharinfo(0)+"',"+.@noitem+")";
}
delitem 6096,.@noitem;
next;
mes "[Fishing Board]";
mes "Fish have been retreived and score updated.";
close;} else
{ mes "[Fishing Board]";
mes "You have no fish to turn in.";
close;}
}