Jump to content
  • 0

OnLoginEvent with cool down of 24 hours?


sizenine

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

I want to give my players an item for logging online, but the item is only given once every 24+ hours... is this possible without having to assign a permanent variable and wiping it every 24 hours? And no, OnClockMinute does not work because that requires the players to login at a certain time of the day.. I want to make it so that as long as you got your items 24 hours or more ago, then when you login again, you will automatically get another one.

Edited by sizenine
Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  658
  • Reputation:   57
  • Joined:  11/20/11
  • Last Seen:  

Try to use this in the Script :

if(gettimestick(2) - lastlogin > (60 * 60 * 24)) {
getitem ItemID,ItemAmount;
}
OnPCLoginEvent:
set lastlogin,gettimetick(2);

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

You could use gettimestr to generate a date serial YYYYMMDD,

then each time they login (OnPCLoginEvent), check that date and see if it is less than today.

If it is, give them the item and set their variable to YYYYMMDD.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

You could use gettimestr to generate a date serial YYYYMMDD,

then each time they login (OnPCLoginEvent), check that date and see if it is less than today.

If it is, give them the item and set their variable to YYYYMMDD.

Wait.. but how we would be comparing two string values rather than int values.. would it know if "20120312" is less than "20120313" if they are both strings? or do i have to use some command to typecast the strings to integers?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Yes you're right, the output of gettimestr is a string. But when you store it in an integer variable it is automatically converted to an int. Maybe use the variable name:

  • #LAST_ITEMDATE (account variable)
  • or just LAST_ITEMDATE (if you want it to be per-char)

set #LAST_ITEMDATE, gettimestr("%Y%m%d", 9);

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

hm the problem now is it seems that char variables have a size limit of 10000000... cause when i try to set LAST_ITEMDATE as 20120312 (or any number greater than 10000000), it will change it to 10000000, so I can't really store the date as an integer.. unless I chop off the year.. 2012.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

I thought the max integer in the Athena Scripting Language was 2147483647 ?

hmm need to test..

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

ah, sorry i think its because i was using input to test it and due to this:

// Default value of the 'max' argument of the script command 'input'.

// When the 'max' argument isn't provided, this value is used instead.

// Defaults to INT_MAX.

//input_max_value: 2147483647

input_max_value: 10000000

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