Jump to content
  • 0

How to change the format of this to use date..


Meister

Question


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

I have currently this code..

 

OnInit: bindatcmd("dailyreward",strnpcinfo(0)+"::OnAtCmd"); end;
OnAtCmd:
if (#dailyreward > gettimetick(2)) {
     message strcharinfo(0),"You must wait 24 hours before receiving more items.";
     end;
}
// getitem x,y;
set #dailyreward, gettimetick(2)+86400;
end;

 

It uses 24 hours cooldown for the daily reward. How to set it to check the date? example. If today is tuesday and he claims the reward, when the server date changes to wednesday, he can already get the reward. As long as you can use the command once per day..

 

How to do activate this command once per day only? Not via 24 hours cooldown.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

try this

OnAtCmd:
if ( #dailyreward != gettime(8) ){
     message strcharinfo(0),"You wait another day.";
}else{
	// getitem x,y;
	set #dailyreward,gettime(8);
}
end;

 

refer gettime

 

or else...you can try use gettimestr

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

OnInit: bindatcmd("dailyreward",strnpcinfo(0)+"::OnAtCmd"); end;
OnAtCmd:
set .@today, atoi(gettimestr("%Y%m%d", 9)); 

if (#dailyreward == .@today ) {
     message strcharinfo(0),"You should try tomorrow to receive more items.";
     end;
}
// getitem x,y;
set #dailyreward, .@today;
end;
It should do the job :)

It set #dailyreward to the date, example today: 20130412.

Edit: hehe, Emistry is faster :)

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Thank you guys! Follow-up how to remove #dailyreward on global_reg_value? to reset everything?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

shutdown server and try run this query in your SQL Machine..

backup ur database just in case anything happen...

DELETE FROM `global_reg_value` WHERE `str` LIKE '#dailyreward';
  • Upvote 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...