Jump to content
  • 0

Showing actual remaining time


chowking

Question


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  178
  • Reputation:   16
  • Joined:  06/25/12
  • Last Seen:  

i applied malufetts mod for go warp delay

im trying to get it to show the actual remaining time before the command can be used again

 

in '@go'

if (!pc_get_group_level(sd) && DIFF_TICK(gettick(), sd->canlog_tick) < 10000) {
		sprintf(atcmd_output, msg_txt(sd, 1505), sd->canlog_tick); //Please wait %d seconds before warping.
		return 0;
	}

 

no errors and warning on recompile
but the no message shows in client when trying to warp while attacking player

i already added in map msg conf import line 1505

Edit:

had to add int since code only shows canlog_tick
here is the working code
 

if (!pc_get_group_level(sd) && DIFF_TICK(gettick(), sd->canlog_tick) < 10000) {
		int w_tick = 10 - (DIFF_TICK(gettick()+500, sd->canlog_tick) / 1000); //+500 (0.5s) will make it roundup if needed be
		sprintf(atcmd_output, msg_txt(sd, 1505), w_tick); //Please wait %d seconds before warping.
		clif_displaymessage(fd, atcmd_output);
		return 0;
	}

 

Edited by chowking
Show answer
  • Love 1
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  249
  • Reputation:   72
  • Joined:  10/20/12
  • Last Seen:  

Try to use clif_displaymessage(fd, atcmd_output); after sprintf. sprintf only saves the formatted string into atcmd_output. With clif_displaymessage you send it to the client.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

A little note, if I may.
With truncation your remaining time could be a little misleading.
Suppose for instance we have 1.8s left. with current code it will show 1s, where I think 2s would be better to show.
To fix this you could simply change your line  :
 

int w_tick = 10 - (DIFF_TICK(gettick(), sd->canlog_tick) / 1000);
to
int w_tick = 10 - (DIFF_TICK(gettick()+500, sd->canlog_tick) / 1000); //+500 (0.5s) will make it roundup if needed be

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  178
  • Reputation:   16
  • Joined:  06/25/12
  • Last Seen:  

7 hours ago, Lighta said:

A little note, if I may.
With truncation your remaining time could be a little misleading.
Suppose for instance we have 1.8s left. with current code it will show 1s, where I think 2s would be better to show.
To fix this you could simply change your line  :
 


int w_tick = 10 - (DIFF_TICK(gettick(), sd->canlog_tick) / 1000);
to
int w_tick = 10 - (DIFF_TICK(gettick()+500, sd->canlog_tick) / 1000); //+500 (0.5s) will make it roundup if needed be

Copy that thanks for pointing it out

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