Jump to content
  • 0

Rank of Donation


KingRamses

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   0
  • Joined:  03/04/15
  • Last Seen:  

Would it be possible to make a npc/system that ranks the top 10 doners of the server and give them a reward depending on their rank, also make it that it resets every week, also an npc/system that rewards you for consumption, and connect it all together

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   16
  • Joined:  09/26/16
  • Last Seen:  

depends on how Donation cash points works on your server.

There are servers who uses items like Donation stub or Cash stubs that is used to buy cash items,
while others use account-bound points like #CASHPOINTS,
some use character-bound points.
(i am not aware of how official cash points works, i only knew the old times like paytoplay, $1 = 8hours gameplay)

 

prontera,160,160,4	script	Donator Ranking	909,{
	mes "Top 10 Donators";
	set .@count, query_sql("SELECT `crn`.`value`,`c`.`name` FROM `char_reg_num` `crn` INNER JOIN `char` `c` ON `crn`.`char_id` = `c`.`char_id` WHERE `crn`.`key` = \"CashUsed\" ORDER BY `crn`.`value` DESC LIMIT 10",.@ptval,.@ptchar$);

	set .@check,0;

	for ( set .@ctr,0; .@ctr < .@count; .@ctr++ ) {
		mes (.@ctr+1)+". ^ff0000"+.@ptchar$[.@ctr]+"^000000 ~> ^ff0000"+.@ptval[.@ctr]+"pts^000000";
		if( .@ptchar$[.@ctr] == strcharinfo(0) )
			.@check = .@ctr+1;
	}

	if( !DonatorRewarded && .@check && gettime( .DayofRewarding )  )
	{
		next;
		mes "Wow! our ^ff0000" + .RankText[.@check] + "^000000 place in rank"; // .@check is the rank number of the player.
		mes "Thank you for donating, here's your reward.";
		getitem .DonateReward,.DRamount;
		set DonatorRewarded,1;
	}
	end;

OnInit:
	set .DonateReward, 969; //Reward itemid
	set .DRamount, 10; //Reward amount;
    //TODO: Different rewards with each ranker.

	set .DayofRewarding, 6; // Only give reward every saturday
	set .DayofReset, 0; // reset every Sunday 12am

	setarray .RankText$[1],"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th";
end;

OnClock0001:
	if( gettime( .DayofReset ) )
	{
		// reset list of players rewarded already.
		query_sql("DELETE FROM `char_reg_num` WHERE `key` = 'DonatorRewarded'");

		// reset donation ranking
		query_sql("DELETE FROM `char_reg_num` WHERE `key` = 'CashUsed'");

		addrid(0); // Attach all (online)players in the server
        // Delete  for Online players
		set DonatorRewarded, 0;
        set CashUsed, 0;
	}
end;
}

Then in your Cash shop, if you have OnBuyItem, add these line on success in buying an item.
set CashUsed, 1; //set how many he/she spent.

haven't tested this script yet.
you might wanna add these feature in this script:
* different reward items and amount per rank

EDIT:
yeah i forgot, this script is for Top 10 Cash spender, and give rewards to 10 most spending players every week.

EDIT:
Applied patches according to senpai Emistry's suggestion, thank you! learned something today (y)

Edited by Athan17
Link to comment
Share on other sites

  • 0

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

query_sql("DELETE FROM `char_reg_num`..............

Whenever the table involve these char_reg or acc_reg tables, the query will only affect those who are currently offline. Players who are still online during you execute this query are not affected because when they offline, the char_reg and acc_reg value get overwritten by the value stored in server.

You have to attach all online player and update the these variables.

 

You may also consider use the npc scope variable in your npc script in future. 

You wont have to reset each variables everytime you want to use them, and it help you avoid conflict in other script in case they use the same variable next time, and server wont have to save these variable data after done executing the script.

 

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   0
  • Joined:  03/04/15
  • Last Seen:  

11 hours ago, Athan17 said:

depends on how Donation cash points works on your server.

There are servers who uses items like Donation stub or Cash stubs that is used to buy cash items,
while others use account-bound points like #CASHPOINTS,
some use character-bound points.
(i am not aware of how official cash points works, i only knew the old times like paytoplay, $1 = 8hours gameplay)

 


prontera,160,160,4	script	Donator Ranking	909,{
	mes "Top 10 Donators";
	set .@count, query_sql("SELECT `crn`.`value`,`c`.`name` FROM `char_reg_num` `crn` INNER JOIN `char` `c` ON `crn`.`char_id` = `c`.`char_id` WHERE `crn`.`key` = \"CashUsed\" ORDER BY `crn`.`value` DESC LIMIT 10",.@ptval,.@ptchar$);

	set .@check,0;

	for ( set .@ctr,0; .@ctr < .@count; .@ctr++ ) {
		mes (.@ctr+1)+". ^ff0000"+.@ptchar$[.@ctr]+"^000000 ~> ^ff0000"+.@ptval[.@ctr]+"pts^000000";
		if( .@ptchar$[.@ctr] == strcharinfo(0) )
			.@check = .@ctr+1;
	}

	if( !DonatorRewarded && .@check && gettime( .DayofRewarding )  )
	{
		next;
		mes "Wow! our ^ff0000" + .RankText[.@check] + "^000000 place in rank"; // .@check is the rank number of the player.
		mes "Thank you for donating, here's your reward.";
		getitem .DonateReward,.DRamount;
		set DonatorRewarded,1;
	}
	end;

OnInit:
	set .DonateReward, 969; //Reward itemid
	set .DRamount, 10; //Reward amount;
    //TODO: Different rewards with each ranker.

	set .DayofRewarding, 6; // Only give reward every saturday
	set .DayofReset, 0; // reset every Sunday 12am

	setarray .RankText$[1],"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th";
end;

OnClock0001:
	if( gettime( .DayofReset ) )
	{
		// reset list of players rewarded already.
		query_sql("DELETE FROM `char_reg_num` WHERE `key` = 'DonatorRewarded'");

		// reset donation ranking
		query_sql("DELETE FROM `char_reg_num` WHERE `key` = 'CashUsed'");

		addrid(0); // Attach all (online)players in the server
        // Delete  for Online players
		set DonatorRewarded, 0;
        set CashUsed, 0;
	}
end;
}

Then in your Cash shop, if you have OnBuyItem, add these line on success in buying an item.
set CashUsed, 1; //set how many he/she spent.

haven't tested this script yet.
you might wanna add these feature in this script:
* different reward items and amount per rank

EDIT:
yeah i forgot, this script is for Top 10 Cash spender, and give rewards to 10 most spending players every week.

EDIT:
Applied patches according to senpai Emistry's suggestion, thank you! learned something today (y)

Where you said "add this line on success" you mean on casshop.h?

    "CASHSHOP_RESULT_SUCCESS =  0x0,     set CashUsed, 1;"

   " CASHSHOP_RESULT_SUCCESS =  0x0,

    set CashUsed, 1;"

Which one would be the correct way?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   16
  • Joined:  09/26/16
  • Last Seen:  

11 hours ago, KingRamses said:

Where you said "add this line on success" you mean on casshop.h?

    "CASHSHOP_RESULT_SUCCESS =  0x0,     set CashUsed, 1;"

   " CASHSHOP_RESULT_SUCCESS =  0x0,

    set CashUsed, 1;"

Which one would be the correct way?

base on your last question, i guess you're using the cash shop on screen button. I'm not sure how it really works, but i guess you need some source editing and set CashUsed on payment.

the script i gave you were char-bound, and it will only work on script type shops with OnBuyItem event handler. "callshop" ~> "npcshopattach"

...
upon reading builtin cashop.c, it looks like you need to edit pc.c under pc_paycash, and you need to modify the script i gave you from char-bound to account-bound since #CASHPOINTS is account-bound.
im not sure what to add, but i think this is becoming a source modify request rather than script request.

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