Jump to content
  • 0

Change weekly to monthly


Question

Posted (edited)

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

2 answers to this question

Recommended Posts

  • 0
Posted

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. 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...