[Q] Countdown time via SQL

fiction

New member
Messages
154
Points
0
Age
32
Location
Santiago, Chile
Emulator
Hi, i'm wondering how can i create a countdown via SQL, this need to be trigger everytime that the user connect to the server.

I'm writting a script that boost the experience of the user for a X time configured, so, for example, if the system give 1 day of increased experience, so i need to pick up his account ID, and attach to a timer for 1 day. When the dayh has been completed, the system will restore to the default setting. I think, this is practicaly a vip system 😆

 
there is no need to use SQL, a simple vip system will do the trick, like this one (found via google):

vip system by brianL from eAthena:

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

Code:
// usage: callfunc "F_VIPstart", <ticks>;
function script F_VIPstart {
set .@ticks, getarg(0); // 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;
}
 
Hi, thank you. Yes, i have write something very similar to that, but i'm trying to understand how to do with sql.

 
script support side, ok no spoon feed

Create a table with the field that store `account_id`, `start_time`, `end_time`

the ``start_time`, `end_time` field use DATETIME field

use addtimer on the `end_time` field -> because you said want to make it configurable

the method is posted on the script above which said made by BrianL, but BrianL also made that based on my old script hahaha
stupid eathena forum down I can't show you the proof

then yeah, the only thing that changed is #VIP_expire, which this value store in SQL table

the rest like timer method should use in-game engine, use addtimer script command

PS: the promotional code script that I recently made actually has the same exact system ... but that script isn't newbie friendly to read

https://github.com/AnnieRuru/Release/blob/master/scripts/Utility/promotion code/promotion_code_1.3.txt#L23-L24

this script, is much easier than you think

honestly if you want a direct answer I can write this out within 10 minutes ....

 
script support side, ok no spoon feed

Create a table with the field that store `account_id`, `start_time`, `end_time`

the ``start_time`, `end_time` field use DATETIME field

use addtimer on the `end_time` field -> because you said want to make it configurable

the method is posted on the script above which said made by BrianL, but BrianL also made that based on my old script hahaha
stupid eathena forum down I can't show you the proof

then yeah, the only thing that changed is #VIP_expire, which this value store in SQL table

the rest like timer method should use in-game engine, use addtimer script command

PS: the promotional code script that I recently made actually has the same exact system ... but that script isn't newbie friendly to read

https://github.com/AnnieRuru/Release/blob/master/scripts/Utility/promotion code/promotion_code_1.3.txt#L23-L24

this script, is much easier than you think

honestly if you want a direct answer I can write this out within 10 minutes .... 
Give me the direct answer. that script have so much lines xD

⢀⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣤⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠑⢄⣠⠾⠁⣀⣄⡈⠙⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡀⠁⠀⠀⠈⠙⠛⠂⠈⣿⣿⣿⣿⣿⠿⡿⢿⣆⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⡾⣁⣀⠀⠴⠂⠙⣗⡀⠀⢻⣿⣿⠭⢤⣴⣦⣤⣹⠀⠀⠀⢀⢴⣶⣆
⠀⠀⢀⣾⣿⣿⣿⣷⣮⣽⣾⣿⣥⣴⣿⣿⡿⢂⠔⢚⡿⢿⣿⣦⣴⣾⠁⠸⣼⡿
⠀⢀⡞⠁⠙⠻⠿⠟⠉⠀⠛⢹⣿⣿⣿⣿⣿⣌⢤⣼⣿⣾⣿⡟⠉⠀⠀⠀⠀⠀
⠀⣾⣷⣶⠇⠀⠀⣤⣄⣀⡀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠉⠈⠉⠀⠀⢦⡈⢻⣿⣿⣿⣶⣶⣶⣶⣤⣽⡹⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠉⠲⣽⡻⢿⣿⣿⣿⣿⣿⣿⣷⣜⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣶⣮⣭⣽⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⠿⠿⠿⠛⠉

 
annie can u tell me how to put it on an item to activate
maybe it's late to reply but i hope I can help other poeple if need this

 

{
Id: 7950
AegisName: "VIP_1Day"
Name: "VIP 1 Day"
Type: "IT_USABLE"
Sell: 10
Weight: 10
Script: <"
.@aid = getcharid(CHAR_ID_ACCOUNT);
.@tmp = 86400;
addtimer .@tmp *1000, strnpcinfo(vipsystem)+"::Ontimeout";
ModExp = 200;
dispbottom "You has been promoted into a super player for 1Day!";
query_sql "INSERT INTO `vip_system` VALUES (NULL, "+ .@aid +", NOW(), DATE_ADD(NOW(), INTERVAL "+ .@tmp +" SECOND))";
">
},


about the strnpcinfo(vipsystem) you can change depend your npc name.

but maybe need function to sum the old time vip left with new time vip
if happen player click the item vip twice 
ex: player click 2 times VIP 1 Day Card it'should be 2 days 

 
Last edited by a moderator:
Back
Top