Jump to content
  • 0

How to make this account based?


gekigengar

Question


  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

This is a script I got from the scripting forum.

-    script    login_reward    -1,{
OnPCLoginEvent:
    .@pow = 1 << 10;
    .@todays = gettime(8);
    if ( login_reward % .@pow == .@todays ) end;
    .@count += .reward_day;// reward of the day
    login_reward = ( login_reward &~ ( login_reward % .@pow ) ) + .@todays +

.@pow;// update day and count day +1 ; day/count day/check week/check month
    if ( login_reward != .@todays + .@pow ) {// login_reward was not empty
        .@count_day = ( login_reward >> 10 ) % .@pow;
        .@cond_ofthemonth = ( ( login_reward >> 30 ) % .@pow ) != (

.@count_day / 31 );
        if ( ( ( login_reward >> 20 ) % .@pow ) != ( .@count_day / 7 ) ) {
            .@count += .reward_week;
            login_reward = login_reward + pow( 2,20 );
            .@weekly_message$ = ( .@cond_ofthemonth ? ", " : " and " ) +

.reward_week +" Red Envelopes for being online a week";
        }
        if ( .@cond_ofthemonth ) {
            .@count += .reward_month;
            login_reward = login_reward + pow( 2,30 );
            .@montly_message$ = " and " + .reward_month +" Red Envelopes

for being online a month";
        }
    }
    getitem 12134, .@count;
    dispbottom "Here your daily reward ! You got "+ .reward_day +" Red

Envelopes"+ .@weekly_message$ + .@montly_message$ +".";
    end;
OnInit:
    .reward_day = 1;// reward of the day : amount of Red Envelopes
    .reward_week = 7;// reward of the week : amount of Red Envelopes
    .reward_month = 32;// reward of the month : amount of Red Envelopes
    end;
}
 

The script gives you red envelope every time you log-in, each weekly/monthly log-in gives you additional item.

 

This however gives the item if you change character.

 

How do you make this account based rather than character based?

 

And I want them to be permanent variable, since the server won't run 24/7, it will have a day of rest, hence, it is not possible to get the weekly reward because the

variable is temporary.

Edited by gekigengar
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

If the server close, does the "Number of days" still reset?

No the variable is permanent

 

Here a revision

-	script	login_reward	-1,{
OnPCLoginEvent:
	.@pow = 1 << 10;
	.@todays = gettime(8);
	if ( #login_reward % .@pow == .@todays ) end;
	.@count = .reward_day;
	#login_reward = ( #login_reward &~ ( #login_reward % .@pow ) ) + .@todays + .@pow;
	.@count_day = ( #login_reward >> 10 ) % .@pow;
	if ( .@count_day % 7  == 0 ) {
		.@count += .reward_week;
		.@weekly_message$ = ( .@cond_ofthemonth ? ", " : " and " ) + .reward_week +" golds for being online a week";
	}
	if ( .@count_day % 31 == 0 ) {
		.@count += .reward_month;
		.@montly_message$ = " and " + .reward_month +" golds for being online a month";
	}
	getitem 969, .@count;
	dispbottom "Here your daily reward ! You got "+ .reward_day +" golds"+ .@weekly_message$ + .@montly_message$ +".";
	end;
OnInit:
	.reward_day = 2;// reward of the day : amount of gold
	.reward_week = 10;// reward of the week : amount of gold
	.reward_month = 35;// reward of the month : amount of gold
	end;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Search for

login_reward

replace them with

#login_reward
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

Search for

 

login_reward

replace them with

 

#login_reward

 

If the server close, does the "Number of days" still reset?

 

I want them to still prevail even after the server is closed down.

Edited by gekigengar
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...