Jump to content
  • 0

Timer making it 30 days?


Question

Posted (edited)

how can i make it 30 days?


function script F_VIPstart {
set .@ticks, getarg(0, "15"); // getarg(0) = ticks (seconds)
if (.@ticks <= 0) {
debugmes "F_VIPstart - tried to set a timer in the past";
end;
}
// set a variable, #VIP_expire, as the Unixtime when this expires
set #VIP_expire, gettimetick(2) + .@ticks;
// add a timer with that tick (in case they stay logged in that long)
if (.@ticks < 2147483) { // prevent overflow error
addtimer .@ticks *1000, "vip_rental::OnVIPend";
} else {
addtimer 2147483, "vip_rental::OnVIPcheck";
}
// change them to GM level 1
atcommand "@adjgroup 1 "+strcharinfo(0);
dispbottom "You now have access to VIP commands!";
return;
}

- script vip_rental -1,{
OnPCLoginEvent:
if (#VIP_expire > gettimetick(2)) {
// timer in future
dispbottom "VIP Rental : expires in " + callfunc("Time2Str",#VIP_expire);
atcommand "@adjgroup 1 "+strcharinfo(0);
}
OnVIPcheck:
if (#VIP_expire > gettimetick(2)) {
if ((#VIP_expire - gettimetick(2)) < 2147483) { // prevent overflow error
addtimer (#VIP_expire - gettimetick(2)) *1000, strnpcinfo(3)+"::OnVIPend";
} else {
addtimer 2147483, strnpcinfo(3)+"::OnVIPcheck";
}
} else if (#VIP_expire) {
// timer already expired
doevent strnpcinfo(3)+"::OnVIPend";
}
end;

OnVIPend:
// change them to GM level 0
atcommand "@adjgroup 0 "+strcharinfo(0);
set #VIP_expire, 0; // clear timer
dispbottom "Your VIP Rental has expired.";
end;
}

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.

2 answers to this question

Recommended Posts

Posted

http://www.eathena.w...ost&pid=1386316

Usage:

{ callfunc "F_VIPstart", <ticks>; }

ticks = how long their VIP will last, in seconds.

(this can be used in an item script or NPC)

Examples:

  • 1 day = 86400
  • 7 days = 604800
  • 14 days = 1209600

30 days = 2592000 seconds, so the item script would be:

{ callfunc "F_VIPstart", 2592000; }

thx a lot for this script and your help to me :D i found this code by checking all Admin Profile hehehe

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