Jump to content
  • 0

how to save higher value to Table rank


LearningRO

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

Hi, all i have script event emper breaker, so for 3 minutes player can break the emper repeatly
each break emper get 1 points.
my problem its how to save the higher result on my table rank 
this is my script

OnStartEmp:
	monster "quiz_01",50,49, "--ja--", 3002, 1,"Emperium War::OnEmpBreak";
	end;

OnEmpBreak:
	set .@notice$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium";
	set #count, #count+1;
 	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	announce strcharinfo(0)+" has break the Emperium!.", bc_ALL;
	sleep 2000;
	announce "Emperium will respawn in 3 seconds.", bc_ALL;
	sleep 1000;
	mapwarp "quiz_01","quiz_02",252, 377,0;
	sleep 2000;
	goto OnStartEmp;
	end;


and this is the npc ranking
 

quiz_02,261,390,3	script	Emp War Ranking	4_BOARD3,{
	query_sql("SELECT `count` FROM `breaker_ladder` WHERE `char_id` = "+ getcharid(0), .@count);
	mes "What would you like to do?";
	next;
	switch(select("~ View Top 10 Emp Breakers Weekly",(getgmlevel()> 60) ? "~ [GM MENU] Reset data":"")) {
	case 1:
			mes "Top 10 Emperium Breaker Weekly";
			if(!(.@nb = query_sql("SELECT `char_id`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@count))) {
				mes "No data found.";
				close;
			}
			for ( .@i = 0; .@i < .@nb; .@i++ ) {
				query_sql("SELECT `name` FROM `char` WHERE `char_id` = '"+.@cid[.@i]+"'",.@name$);
				mes (.@i+1) +". "+ .@name$ +" ~ "+ .@count[.@i] +" breaks.";
			}
			close;

	case 2:
		mes "Are you sure you want to delete all Emp Breaker Ladder data?";
		next;
		select("Yes");
		message strcharinfo(0), "Deleting...";
		progressbar "", 5;
		query_sql("TRUNCATE TABLE `breaker_ladder`");
		mes "Deleting complete..";
		close;
	}
	end;


So my goal its to save higher score player get since player can try this event anytime.
Ex:
First time Try for 3 minutes player get result 11 points break
second time player will get 10 points 
so if  Last Score < Higher Score
didnt update to the table rank

Edited by LearningRO
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

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

total kill count per session?

when you warp into the room, reset the initial count

@total_emperium_count = 0;

when they killed the Emperium,

@total_emperium_count++;
if (@total_emperium_count > #count) {
	#count = @total_emperium_count;
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = "+getcharid(0)+", `count` = 1 ON DUPLICATE KEY UPDATE `count` = "+#count);
}

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

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

when you warp into the room, reset the initial count

#count = 0;

when they killed the Emperium,

#count++;
if (#count == 1)
	.@point = 11;
else if (#count == 2)
	.@point = 10;
	
query_sql("INSERT INTO `breaker_ladder` SET `char_id` = "+getcharid(0)+", `count` = 1 ON DUPLICATE KEY UPDATE `count` = `count` + "+.@point);

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

Thanks u for your help but my goal its like this Emper Breaker test but use points

 

'time = last_break_time = getnpctimer(0);
	if ( !p_break_time ) {
		p_break_time = 'time;
		dispbottom "You have set your first personal record.";
	}
	else if ( 'time < p_break_time ) {
		dispbottom "You have broken your personal record!";
		p_break_time = 'time;
	}
	//dispbottom "Your current best time is "+ (p_break_time / 1000) +"."+ (p_break_time % 1000) +"s.";
	instance_announce instance_id(), "Time : "+ ('time / 1000) +"."+ ('time % 1000) +"s.", bc_map;
	sleep2 2000;
	instance_announce instance_id(), "Warping out in 5 seconds.", bc_map;
	sleep2 5000; // 5 sec pause
	warp "SavePoint", 0, 0;
	sleep2 1000;
	instance_destroy instance_id();
	end;


Since the result for point(how much they can destroy the emper withing 3 minutes) Each Game will be different

So I need script how the read the last #count Player get and then compare with the new #count he get
if The Old one get better result will not update into the table rank

Edited by LearningRO
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

12 hours ago, Emistry said:

total kill count per session?

when you warp into the room, reset the initial count

@total_emperium_count = 0;

when they killed the Emperium,

@total_emperium_count++;
if (@total_emperium_count > #count) {
	#count = @total_emperium_count;
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = "+getcharid(0)+", `count` = 1 ON DUPLICATE KEY UPDATE `count` = "+#count);
}

 

thank you emistry ?
this is what i want 
Damn simple solution ?

 

 

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