Jump to content
  • 0

auto reset for attendance


Ohmyuniverse

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.13
  • Content Count:  11
  • Reputation:   0
  • Joined:  03/04/24
  • Last Seen:  

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
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  171
  • Reputation:   86
  • Joined:  04/10/12
  • Last Seen:  

    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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  15
  • Reputation:   3
  • Joined:  01/29/24
  • Last Seen:  

in your script:
  - Start: 20240306
    End: 20240326

 

are dates...

just change the start date and a new event will start.

Edited by sfj209jfo-p
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.13
  • Content Count:  11
  • Reputation:   0
  • Joined:  03/04/24
  • Last Seen:  

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?

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  171
  • Reputation:   86
  • Joined:  04/10/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  150
  • Reputation:   11
  • Joined:  12/03/18
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  25
  • Reputation:   64
  • Joined:  11/21/18
  • Last Seen:  

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