DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • June 24, 2019, 04:45:29 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: revive all dead players (script)  (Read 3949 times)
0 Members and 1 Guest are viewing this topic.
lsgworldl
Guest
« on: April 26, 2004, 09:30:58 PM »

I used this to revive dead players even if they dont log on again

 Grin
« Last Edit: April 26, 2004, 09:40:35 PM by lsgworldl » Logged
lsgworldl
Guest
« Reply #1 on: April 26, 2004, 10:27:28 PM »

has any one tried it yet?
Logged
ATJ
Guest
« Reply #2 on: April 27, 2004, 01:19:56 AM »

I am about to, ive been looking for a universal newday thingy so i can grant everyone a new day.
Logged
lsgworldl
Guest
« Reply #3 on: April 27, 2004, 01:29:53 AM »

put the file in the root of your host so ppl cant run it from logd, you can also make a cron job and have it run every x amount of time, I got the idea from PDM, where you can make players come back to live every 24 hours
Logged
lonnyl
Guest
« Reply #4 on: April 27, 2004, 06:18:25 AM »

I have been thinking about doing something like this, however I wanted it automated and only wanted it to resurect those who have not been on for a long time.  My solution was to add a field to accouts called lastres as a date field, and then add to newday

$sql = "SELECT login,laston,alive,lastres FROM accounts WHERE alive = 0";
      $result = db_query($sql);
      for ($i=0;$i<db_num_rows($result);$i++){
       $row = db_fetch_assoc($result);
        if ($row[laston] < date("Y-m-d H:i:s",strtotime("-2592000 seconds")) and $row[lastres] < date("Y-m-d")){
           $sql2 = ("UPDATE accounts SET alive=1,lastres='".date("Y-m-d")."' WHERE login = '{$row['login']}'");
         db_query($sql2);
           }
       }

this routine resurects players who have not been on for 30 days and only resurects them once every real day.  We have reward systems in for those who log in often (jobs, and some other things) this seems to compliment that by penalizing those who have not for a very long time.  Might be a bit harsh and to make it longer or shorter multiply the number of days you want it by 86400 and replace  2592000 with your new number.
Logged
Kendaer
Guest
« Reply #5 on: April 27, 2004, 07:27:06 AM »

You do realize you could do that as one SQl statement which would be more efficient?

update accounts set alive=1,lastres='" . date("Y-m-d") . "' WHERE alive=0 AND laston < '".date("Y-m-d H:i:s" strtotime("-30 days")) . "' and lastres < '". date("Y-m-d")."'

Just thinking that if you do this, you should do it in the most efficient way possible.
Logged
lonnyl
Guest
« Reply #6 on: April 27, 2004, 08:34:52 AM »

just a small  update to what I posted earlier with fair warning to the affected players.

$session['user']['lastres']="0000-00-00  00:00:00";
        $sql = "SELECT login,laston,alive,lastres,emailaddress FROM accounts WHERE alive = 0";
      $result = db_query($sql);
      for ($i=0;$i<db_num_rows($result);$i++){
       $row = db_fetch_assoc($result);
        if ($row[laston] < date("Y-m-d H:i:s",strtotime("-2592000 seconds")) and $row[lastres] < date("Y-m-d H:i:s",strtotime("-86400 seconds"))){
           if ($row[lastres]=="0000-00-00  00:00:00"){
              mail($row[emailaddress],"New LoGD Mail","You have received new mail on LoGD at http://".$_SERVER[HTTP_HOST].dirname($_SERVER[SCRIPT_NAME])."\n\n$fromline"
         ."Subject: Old Account\n"
          ."Body: You have not logged into your Legend of the Green Dragon account for over 30 days!  Your character is now being resurected every day for other players to slay!  Login again at pqcomp.com to prevent this from happening!\n"
         ."\n otherwise please disregard this message.",
         "From: ".getsetting("gameadminemail","postmaster@localhost")
         );
           }
           $sql2 = ("UPDATE accounts SET alive=1,lastres='".date("Y-m-d H:i:s")."' WHERE login = '{$row['login']}'");
         db_query($sql2);
           }
       }


be sure to change pqcomp.com to your web site.
and with this code the lastres field is now a datetime field as the date field did not seem to work very well.
« Last Edit: April 27, 2004, 08:48:57 AM by lonnyl » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
74 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search