Advertisement
Guest User

OnlineGamingTime

a guest
Jan 19th, 2015
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. //
  2. //
  3. // Author Goddameit
  4. // Version 2015/01/20
  5. // Web http://goo.gl/0vY9GV
  6. //
  7. // http://hercules.ws/board/topic/8277-online-gaming-time/
  8. //
  9. prontera,150,180,4 script OnlineGamingTime 100,{
  10. .@tick = 0;
  11. query_sql "UPDATE `onlinetime` SET `total_sec` = `total_sec` + TIMESTAMPDIFF(SECOND, `start_time`, NOW()), `start_time` = NOW() WHERE `account_id` = "+getcharid(3);
  12. query_sql "SELECT `total_sec` FROM `onlinetime` WHERE `account_id` = "+getcharid(3), .@tick;
  13. mes "Your online time is:";
  14. mes "[ "+callfunc("Time2Str", gettimetick(2)+.@tick)+" ]";
  15. close;
  16. OnPCLoginEvent:
  17. .@bool = 0;
  18. query_sql "SELECT `account_id` FROM `onlinetime` WHERE `account_id` = "+getcharid(3), .@bool;
  19. if( .@bool )
  20. query_sql "UPDATE `onlinetime` SET `start_time` = NOW() WHERE `account_id` = "+getcharid(3);
  21. else
  22. query_sql "INSERT INTO `onlinetime` VALUES("+getcharid(3)+", NOW(), 0)";
  23. end;
  24. OnPCLogoutEvent:
  25. query_sql "UPDATE `onlinetime` SET `total_sec` = `total_sec` + TIMESTAMPDIFF(SECOND, `start_time`, NOW()), `start_time` = NOW() WHERE `account_id` = "+getcharid(3);
  26. end;
  27. OnInit:
  28. OnTimer60000:
  29. debugmes "[OnlineTime]: Auto-Backup player date.";
  30. query_sql "INSERT INTO `onlinetime` SELECT `account_id`, NOW(), 0 FROM `char` WHERE `online` = 1 AND `account_id` NOT IN (SELECT `account_id` FROM `onlinetime`)";
  31. query_sql "UPDATE `onlinetime` SET `total_sec` = `total_sec` + TIMESTAMPDIFF(SECOND, `start_time`, NOW()), `start_time` = NOW() WHERE `account_id` IN (SELECT `account_id` FROM `char` WHERE `online` = 1)";
  32. initnpctimer;
  33. end;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement