Jump to content

Question

Posted (edited)

image.png.9a94fa6d64e1a519205906c01d08165a.png

 

how to auto reset the attendance when the attendance reached the final day. thanks

 

here's my script

Quote

 

###########################################################################
# Attendance Database
###########################################################################
#
# Attendance Settings
#
###########################################################################
# - Start                   Start date.
#   End                     End date.
#   Rewards:                List of rewards for each day.
#     - Day                 Reward day.
#       ItemId              Item ID.
###########################################################################

Header:
  Type: ATTENDANCE_DB
  Version: 1

Body:
  - Start: 20240306
    End: 20240326
    Rewards:
      - Day: 1
        ItemId: 501
      - Day: 2
        ItemId: 501
      - Day: 3
        ItemId: 501
        Amount: 5
      - Day: 4
        ItemId: 501
        Amount: 5
      - Day: 5
        ItemId: 501
      - Day: 6
        ItemId: 501
      - Day: 7
        ItemId: 501
        Amount: 3
      - Day: 8
        ItemId: 501
        Amount: 5
      - Day: 9
        ItemId: 501
        Amount: 5
      - Day: 10
        ItemId: 501
      - Day: 11
        ItemId: 501
        Amount: 2
      - Day: 12
        ItemId: 501
        Amount: 3
      - Day: 13
        ItemId: 501
        Amount: 5
      - Day: 14
        ItemId: 501
        Amount: 5
      - Day: 15
        ItemId: 501
        Amount: 5
      - Day: 16
        ItemId: 501
        Amount: 5
      - Day: 17
        ItemId: 501
        Amount: 5
      - Day: 18
        ItemId: 501
        Amount: 5
      - Day: 19
        ItemId: 501
      - Day: 20
        ItemId: 501

 

 

Edited by Ohmyuniverse

6 answers to this question

Recommended Posts

  • 1
Posted
    int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));

    // Check if we have a remaining counter from a previous period
    if( counter >= 25 && !pc_attendance_rewarded_today(sd) ){
        pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );

        return 0;
    }

 

  • MVP 1
  • 0
Posted
19 hours ago, Sapito Sucio said:
    int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));

    // Check if we have a remaining counter from a previous period
    if( counter >= 25 && !pc_attendance_rewarded_today(sd) ){
        pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );

        return 0;
    }

 

where should i paste this?

 

  • 0
Posted
On 3/8/2024 at 12:16 AM, Ohmyuniverse said:

where should i paste this?

 

Search for this line in your emulator, and you will find it

int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));
  • Upvote 1
  • 0
Posted
int32 pc_attendance_counter( map_session_data* sd ){
	std::shared_ptr<s_attendance_period> period = pc_attendance_period();

	// No running attendance period
	if( period == nullptr ){
		return 0;
	}

	// Get the counter for the current period
	int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));

+    // Check if we have a remaining counter from a previous period
+    if( counter >= 20 && !pc_attendance_rewarded_today(sd) ){
+        pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );
+        return 0;
+    }
	
	// Check if we have a remaining counter from a previous period
	if( counter > 0 && pc_readreg2( sd, ATTENDANCE_DATE_VAR ) < period->start ){
		// Reset the counter to zero
		pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );

		return 0;
	}

	return 10 * counter + ( ( pc_attendance_rewarded_today(sd) ) ? 1 : 0 );
}

I think this is what @Sapito Sucio is trying to tell you to do.

Though you have to really understand that attendance forces players to login/attend. On the days you want them active.

It would be best if you just use a daily reward script for the purpose of resetting your daily rewards.

  • Love 1
  • 0
Posted
1 hour ago, PsyOps said:
int32 pc_attendance_counter( map_session_data* sd ){
	std::shared_ptr<s_attendance_period> period = pc_attendance_period();

	// No running attendance period
	if( period == nullptr ){
		return 0;
	}

	// Get the counter for the current period
	int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));

+    // Check if we have a remaining counter from a previous period
+    if( counter >= 20 && !pc_attendance_rewarded_today(sd) ){
+        pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );
+        return 0;
+    }
	
	// Check if we have a remaining counter from a previous period
	if( counter > 0 && pc_readreg2( sd, ATTENDANCE_DATE_VAR ) < period->start ){
		// Reset the counter to zero
		pc_setreg2( sd, ATTENDANCE_COUNT_VAR, 0 );

		return 0;
	}

	return 10 * counter + ( ( pc_attendance_rewarded_today(sd) ) ? 1 : 0 );
}

I think this is what @Sapito Sucio is trying to tell you to do.

Though you have to really understand that attendance forces players to login/attend. On the days you want them active.

It would be best if you just use a daily reward script for the purpose of resetting your daily rewards.

@PsyOps and @Sapito Sucio you are the best!!!

  • Like 1

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