Jump to content
  • 0

@pk command - Adding timer


Jayz

Question


  • Group:  Members
  • Topic Count:  59
  • Topics Per Day:  0.01
  • Content Count:  396
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

Hello i want to ask if how to add timer on @pk command if you are offline the timer will stop, and it will continue once you online, i want to put 60mins timer once the timer runount the @pk command turn to state.pk_mode = 0

int atcommand_pkmode( const int fd, struct map_session_data *sd, const char *command, const char *message ) {
 
	nullpo_retr(-1, sd);

	if (!sd->state.pk_mode) {
		sd->state.pk_mode = 1;
		clif_displaymessage(sd->fd, "You are now no longer in PK mode.");
	} else {
		sd->state.pk_mode = 0;
		clif_displaymessage(sd->fd, "Returned to normal state.");
	}

	return 0;
}

 

Edited by Jayz
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  662
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

The simplest way to do that is via a status effect. You give the status when the player uses @pk, and when the status runs out, it removes the pk mode.

int atcommand_pkmode( const int fd, struct map_session_data *sd, const char *command, const char *message ) {
 
	nullpo_retr(-1, sd);

	if (!sd->state.pk_mode) {
		sd->state.pk_mode = 1;
		sc_start(&sd->bl, &sd->bl, SC_PK_DISABLE, 100, 0, 60 * 60 * 10000);
		clif_displaymessage(sd->fd, "You are now no longer in PK mode.");
	} else {
		sd->state.pk_mode = 0;
		status_change_end(&sd->bl, SC_PK_DISABLE);
		clif_displaymessage(sd->fd, "Returned to normal state.");
	}

	return 0;
}

 

And define the SC_PK_DISABLE status:

diff --git a/db/re/status.yml b/db/re/status.yml
index 96693fdce..40693394c 100644
--- a/db/re/status.yml
+++ b/db/re/status.yml
@@ -8166,3 +8166,9 @@ Body:
       NoClearbuff: true
     End:
       Sub_Weaponproperty: true
+  - Status: Pk_Disable
+    #Icon: EFST_PK_DISABLE
+    Flags:
+      NoDispell: true
+      NoBanishingBuster: true
+      NoClearance: true
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp
index 25ce19a67..ddbd1c466 100644
--- a/src/map/script_constants.hpp
+++ b/src/map/script_constants.hpp
@@ -1844,6 +1844,7 @@
 	export_constant(SC_M_LIFEPOTION);
 	export_constant(SC_S_MANAPOTION);
 	export_constant(SC_SUB_WEAPONPROPERTY);
+	export_constant(SC_PK_DISABLE);
 
 #ifdef RENEWAL
 	export_constant(SC_EXTREMITYFIST2);
diff --git a/src/map/status.cpp b/src/map/status.cpp
index 42005bdae..4b6f462fb 100644
--- a/src/map/status.cpp
+++ b/src/map/status.cpp
@@ -13351,6 +13351,11 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 				pc_delabyssball( *sd, sd->abyssball );
 			}
 			break;
+		case SC_PK_DISABLE:
+			if (sd) {
+				sd->state.pk_mode = 0;
+			}
+			break;
 	}
 
 	// Reset the options as needed
diff --git a/src/map/status.hpp b/src/map/status.hpp
index f103cd018..f2b79e058 100644
--- a/src/map/status.hpp
+++ b/src/map/status.hpp
@@ -1230,7 +1230,7 @@ enum sc_type : int16 {
 	SC_S_MANAPOTION,
 
 	SC_SUB_WEAPONPROPERTY,
-
+	SC_PK_DISABLE,
 #ifdef RENEWAL
 	SC_EXTREMITYFIST2, //! NOTE: This SC should be right before SC_MAX, so it doesn't disturb if RENEWAL is disabled
 #endif

(Also... shouldn't this message "You are now no longer in PK mode." be "You are now in PK mode." instead?)

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  59
  • Topics Per Day:  0.01
  • Content Count:  396
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

On 10/12/2022 at 12:23 AM, Tokei said:

The simplest way to do that is via a status effect. You give the status when the player uses @pk, and when the status runs out, it removes the pk mode.

int atcommand_pkmode( const int fd, struct map_session_data *sd, const char *command, const char *message ) {
 
	nullpo_retr(-1, sd);

	if (!sd->state.pk_mode) {
		sd->state.pk_mode = 1;
		sc_start(&sd->bl, &sd->bl, SC_PK_DISABLE, 100, 0, 60 * 60 * 10000);
		clif_displaymessage(sd->fd, "You are now no longer in PK mode.");
	} else {
		sd->state.pk_mode = 0;
		status_change_end(&sd->bl, SC_PK_DISABLE);
		clif_displaymessage(sd->fd, "Returned to normal state.");
	}

	return 0;
}

 

And define the SC_PK_DISABLE status:

diff --git a/db/re/status.yml b/db/re/status.yml
index 96693fdce..40693394c 100644
--- a/db/re/status.yml
+++ b/db/re/status.yml
@@ -8166,3 +8166,9 @@ Body:
       NoClearbuff: true
     End:
       Sub_Weaponproperty: true
+  - Status: Pk_Disable
+    #Icon: EFST_PK_DISABLE
+    Flags:
+      NoDispell: true
+      NoBanishingBuster: true
+      NoClearance: true
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp
index 25ce19a67..ddbd1c466 100644
--- a/src/map/script_constants.hpp
+++ b/src/map/script_constants.hpp
@@ -1844,6 +1844,7 @@
 	export_constant(SC_M_LIFEPOTION);
 	export_constant(SC_S_MANAPOTION);
 	export_constant(SC_SUB_WEAPONPROPERTY);
+	export_constant(SC_PK_DISABLE);
 
 #ifdef RENEWAL
 	export_constant(SC_EXTREMITYFIST2);
diff --git a/src/map/status.cpp b/src/map/status.cpp
index 42005bdae..4b6f462fb 100644
--- a/src/map/status.cpp
+++ b/src/map/status.cpp
@@ -13351,6 +13351,11 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 				pc_delabyssball( *sd, sd->abyssball );
 			}
 			break;
+		case SC_PK_DISABLE:
+			if (sd) {
+				sd->state.pk_mode = 0;
+			}
+			break;
 	}
 
 	// Reset the options as needed
diff --git a/src/map/status.hpp b/src/map/status.hpp
index f103cd018..f2b79e058 100644
--- a/src/map/status.hpp
+++ b/src/map/status.hpp
@@ -1230,7 +1230,7 @@ enum sc_type : int16 {
 	SC_S_MANAPOTION,
 
 	SC_SUB_WEAPONPROPERTY,
-
+	SC_PK_DISABLE,
 #ifdef RENEWAL
 	SC_EXTREMITYFIST2, //! NOTE: This SC should be right before SC_MAX, so it doesn't disturb if RENEWAL is disabled
 #endif

(Also... shouldn't this message "You are now no longer in PK mode." be "You are now in PK mode." instead?)

Thank you very much,

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