Jump to content
MakeWebGames

[V2] Reward the active. - Punish the inactive.


Recommended Posts

Posted

This is a bunch of different mods that you can choose from. You don't have to use them all.

Note: Do a back-up first!! I'm a mySQL/php total n00bie! Heck, I've had the script for only a week and havn't even created my first town!! Though I've tested everything except the Supporter days part.

Punish inactive players...

1. Players don't get bank interest if they have gone X days with out loging in. Once they log in again, they start geting the bank interest again. (A nice anti-inflation tool.)

2. Days remaining in the education course doesn't count down if you don't log in during the day.

3. Players don't get paid for working at the job for days they don't log in! (Welcome to the real world, how may I help you!!!)

4. Players don't get street steps if they have gone X days with out loging in. (Not needed if it get's reset each day.)

Reward active players/supporters....

1. Players get X crystals and/or cash if they loged in with in the last day.

2. If a donor doesn't log in, he doesn't lose a donor/supporter day.

Run query

ALTER TABLE `users` ADD `daysinactive` int(11) NOT NULL default 0;

In authenticate.php replace

$db->query("UPDATE users SET lastip_login='$IP',last_login=unix_timestamp() WHERE userid={$mem['userid']}");

with

$db->query("UPDATE users SET lastip_login='$IP',last_login=unix_timestamp() WHERE userid={$mem['userid']}");

$db->query("UPDATE users SET daysinactive=0 WHERE userid={$mem['userid']}");

In cron_day.php replace

$db->query("DELETE FROM fedjail WHERE fed_days=0");

with

$db->query("DELETE FROM fedjail WHERE fed_days=0");

$db->query("UPDATE users SET daysinactive=daysinactive+1");

Now for the mods...

Players only get bank interest if they have loged in with in the last X days.

In cron_day.php replace

$db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0");

$db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>0");

with

$db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) WHERE bankmoney>0 AND daysinactive < 5");

$db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) WHERE cybermoney>0 AND daysinactive < 5");

Change 5 to the number of days you want players to be inactive before they stop getting bank interest.

And if you wanna let other players get the money after XX days, also add...

$db->query("UPDATE users SET money=bankmoney+cybermoney+money AND daysinactive > 30");

$db->query("UPDATE users SET cybermoney=0 where daysinactive > 30");

$db->query("UPDATE users SET bankmoney=0 where daysinactive > 30");

Change 30 to the number of days you want players to be inactive before they get their money taken out of the bank so other players can attack them for the cash.

Got inactive players with a ton of cash and want to generate some excitement with an announce of the time you'll do this?? In cron_minute.php add...

$db->query("UPDATE users SET hp=maxhp WHERE daysinactive > 30");

$db->query("UPDATE users SET hospital=0 WHERE daysinactive > 30");

and all the players that haven't loged in with in 30 days will be in the hospital for just one minute and get out with all HP back. (If they ever log in, they will go back to normal, since 'daysinactive' will reset back to zero.)

Only get credit for taking an education course if players have loged in during the day.

In cron_day.php replace

$db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0");

with

$db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0 AND daysinactive < 1");

Players only get paid for showing up to work if they have loged in during the day.

In cron_hour.php replace

$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET u.money=u.money+jr.jrPAY, u.exp=u.exp+(jr.jrPAY/20)

WHERE u.job > 0 AND u.jobrank > 0");

$db->query("UPDATE userstats us LEFT JOIN users u ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET us.strength=(us.strength+1)+jr.jrSTRG-1,us.labour=(us.labour+1)+jr.jrLABOURG-1,us.IQ=(us.IQ+1)+jr.jrIQG-1 WHERE u.job > 0 AND u.jobrank > 0");

with

$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET u.money=u.money+jr.jrPAY, u.exp=u.exp+(jr.jrPAY/20)

WHERE u.job > 0 AND u.jobrank > 0 AND daysinactive < 1");

$db->query("UPDATE userstats us LEFT JOIN users u ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET us.strength=(us.strength+1)+jr.jrSTRG-1,us.labour=(us.labour+1)+jr.jrLABOURG-1,us.IQ=(us.IQ+1)+jr.jrIQG-1 WHERE u.job > 0 AND u.jobrank > 0 AND daysinactive < 1");

Don't give out Street turns to players that havn't loged in in X days.

If they keep their steps at the end of the day instead of being reset to say 100, replace

$db->query("UPDATE users SET turns=turns+100");

with

$db->query("UPDATE users SET turns=turns+100 where daysinactive < 5");

$db->query("UPDATE users SET turns=100 where daysinactive > 5");

$db->query("UPDATE users SET turns=turns where turns > 1000");

With 100 being the number of steps you give out each day, and 5 being how many days you want the players to be inactive to not get steps.

Reward active players.

In cron_day.php add

$db->query("UPDATE users SET money=money+(level*1000) WHERE daysinactive < 5");

And change 1000 to how much cash you want to hand out per level and 5 to the max inactive days for a player to get it.

And/or a crystal mass payment...

Gain one crystal per day per level up to Level XX....

$db->query("UPDATE users SET crystals=crystals+(level*1) WHERE daysinactive < 5 AND level < 100");

Edit 100 to how many crystals they should get max a day.

Level 100 or above, gain 100 crystals a day....

$db->query("UPDATE users SET crystals=crystals+100 WHERE daysinactive < 5 AND level > 99");

Edit 100 to how many crystals they should get max a day and the level where the daily payout stops. In both codes, make sure 100 is changed to the same number and the 99 is one number below the other number.

Of course players will have to come on to keep other players from taking the crystals and cash.

Supporter courtesy.

Want to show courtesy for players that fork over cash but some times have a day where they don't log on to benefit from it? For donor days...

In cron_day.php replace...

$db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0");

with

$db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0 AND daysinactive < 1");

Supporter days, in cron_day.php replace...

$db->query("UPDATE users SET supporterdays=supporterdays-1 WHERE supporterdays > 0");

with

$db->query("UPDATE users SET supporterdays=supporterdays-1 WHERE supporterdays > 0 AND daysinactive < 1");

Then, if they don't log on, they won't lose the donor/supporter days on days they don't log on and benefit from getting more energy. Of course if they get benefits like a higher bank interest rate, you don't wanna do one or both of these.

Got any other mods that give players something each day?? Study the code and you can easily do this for those mods.

AND daysinactive < 5

is less than five days and

AND daysinactive > 5

is more than five days.

:-o You didn't actually read all that, did you!!! tldr; :-o

Posted

Re: [V2] Reward the active. - Punish the inactive.

instead of adding the daysinactive field to the users table, and modifying your authenticate.php

couldn't you use the already excisting laston field?

for example 5 days

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

does anyone know any downsides to using this method instead?

Posted

Re: [V2] Reward the active. - Punish the inactive.

Remember, I'm a mySQL/php total n00bie. With this method, any one can figure it out, including us n00bies. While only you php/mySQL pros can figure out the timestamp stuff!

Posted

Re: [V2] Reward the active. - Punish the inactive.

Unix timestamp is seconds since january 1st, 1970....... really all you need to know to determine 1 day ago, or 50 days ago, is the number of seconds in a day, multiplied by however many days you need...

fbiss, I don't see why it wouldn't work, it's used in other applications similar to that.

Posted

Re: [V2] Reward the active. - Punish the inactive.

 

That method would work fine fbiss, but these are good mods, I will probably be using a couple of them

I didn't say they wheren't good mods, because they are. :-)

I was just showing a differnt way to do this for those who didnt want to add another field to users. I have had the no interest after 5 days on my beta game for a couple weeks now using the unix timestamp, so i know it works.

I was just wondering if anybody had any experiences where using the timestamp was a bad idea. I'm wondering if doing the extra calculation will slow the cron down at all if you have a large user base.

Posted

Re: [V2] Reward the active. - Punish the inactive.

If some one knows how to make this work, please post the code!! Something like..

if ($Inactive for five days) {

Create this event mySQL query.

}

$db->query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,The Admin sent you a note. It says: Today you did not get bank interest. If you are inactive for X days, you won't start geting it until you log on again. Same goes for Street turns. Plus, on days you don't log in, you won't get paid for your job, or get credit for showing up to school. Also, you might of noticed you gain some money/crystals at the end of the day. You also won't get those if you havn't loged in in X days. On the plus side, if you're a doner, you won't lose a doner day on days you don't log in) WHERE daysinactive = 5");

This would be a nice way to let them know and hopefully get them to be more active.

Posted

Re: [V2] Reward the active. - Punish the inactive.

 

If some one knows how to make this work, please post the code!! Something like..

Well it should be something similar to this outline

(In cron_day.php)

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

If someone finds something wrong with the event code its because I haven't bothered to learn about event coding yet. All I did was structure the code to the right format.

Posted

Re: [V2] Reward the active. - Punish the inactive.

Simple as this, No extra fields required. :)

function genTime($timeP);

{

$time = 15*60/15;

$time = $time-$timeP;

$time = time()-$time;

return $time;

}

$time = genTime(15000); //5 Days.. I think.

$lastActive = mysql_query("SELECT COUNT(*) AS `cnt` FROM `users` WHERE `lastaction` > '$time' AND `userid` = '{$_SESSION['userid']}'");

$lastActive = mysql_fetch_array($lastActive);

$lastActive = $lastActive['cnt'];

if($lastActive)

{

print "You have been online within the last 5 days.";

} else {

print "You haven't been online within the last 5 days";

}

Posted

Re: [V2] Reward the active. - Punish the inactive.

For those who posted that they didnt understand the unix_timestamp..

for V2:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

for V1:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

The -432000 is how many seconds are in 5 days

1440 (minutes in a day) x 60 (seconds in a minute) x 5 (Days) = 432000 seconds

Posted

Re: [V2] Reward the active. - Punish the inactive.

I like this, I added one like this to my game but not as much was places on it, I will over write it with this one :-D

Thanks

  • 2 months later...
Posted

Re: [V2] Reward the active. - Punish the inactive.

what would be the code that i should use if i want to delete all the players who are inactive for 45 days, using unix_timestamp(). do help me with this.

Posted

Re: [V2] Reward the active. - Punish the inactive.

why the heck would you wanna delete players....

maybe inactive but they'll always come back sometimes..

i go on Torn city like 1 - 2 times a month

Posted

Re: [V2] Reward the active. - Punish the inactive.

but a month is only 30 days, i have it set to delete accounts that are left for more then 50 days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

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

×
×
  • Create New...