Jump to content
  • 0

OnLoginEvent with cool down of 24 hours?


Question

Posted (edited)

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

7 answers to this question

Recommended Posts

Posted

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
Posted

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?

Posted

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);

Posted

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.

Posted

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...