Jump to content
  • 0

Change weekly to monthly


playgron

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   2
  • Joined:  11/19/16
  • Last Seen:  

Hello guys so im using mvp script with rank every week player will get rewards (automated) , can any of you modify the script to change the reward into monthly ? thanks.

 

OnInit:
	// set reward here ... 1st place won 10 red pot, 2nd place won 9 orange pot ... etc ...
	setarray .reward, 501, 502, 503;
	setarray .amount, 10, 9, 8;
	
	if ( !$mvp_rank_1st_sunday )
		query_sql "select curdate() - dayofweek( curdate() ) +1", $mvp_rank_1st_sunday; // TRICK !! how to save the 1st sunday once the script installed

OnSun0000:
	query_sql "select datediff( curdate(), '"+ $mvp_rank_1st_sunday +"' ) /7", .this_week_index;
	if ( .this_week_index == $mvp_rank_week_index ) end;
	.@query$  = "SELECT char_id, `name`, IF(@d=t.`mvp_kills`, @r, @r:=@i), @d:=t.`mvp_kills`, @i:=@i+1 ";
	.@query$ += "FROM `mvp_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
	.@query$ += "ORDER BY `mvp_kills` DESC LIMIT 10";
	.@nb = query_sql(.@query$, .@cid, .@name$, .@rank, .@kills, .@dummy);
	if ( .@nb ) {
		for ( .@i = 0; .@i < .@nb; ++.@i ) {
			.@reward_query$[.@i] = "( "+ .@cid[.@i] +", "+ $mvp_rank_week_index +", "+ .@rank[.@i] +" )";
			.@archive_query$[.@i] = "( "+ $mvp_rank_week_index +", "+ .@rank[.@i] +", "+ .@cid[.@i] +", '"+ escape_sql(.@name$[.@i]) +"', "+ .@kills[.@i] +" )";
		}
	//	query_sql "truncate table mvp_rank_archive"; // uncomment this line if you love to periodically clean your data
		query_sql "insert into mvp_rank_reward values "+ implode( .@reward_query$, ", " );
		query_sql "insert into mvp_rank_archive values "+ implode( .@archive_query$, ", " );
		query_sql "truncate table mvp_rank";
	}
	$mvp_rank_week_index = .this_week_index;
	end;

 

Edited by playgron
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

OnSun0000:

to

OnClock0000:
if(gettime(DT_DAYOFMONTH)!=1) end;


If it helps you, please mark it as Answer

Edited by Haruka Mayumi
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   199
  • Joined:  05/03/13
  • Last Seen:  

Increase a global var once per week.

if global var % 4 is equal to 0 give out the reward. 

But there are probably better/cleaner ways too achieve what you need. 

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