phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Searching for a Mod -- WinCash Mod, perhaps?
2 members found this topic helpful

 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Apr 13, 2009 2:03 am 
Post subject: Searching for a Mod -- WinCash Mod, perhaps?

There's a Mod out there I am very interested in, yet I'm unable to find it.

I have no idea what the name of it is, but I assume it has something to do with "WinCash".

The Mod is some kind of an add-on or Mod for one of the Cash Mods (unsure) that seems to simply add cash when you change pages (though not every time; only certain instances). It is also quite old, though I'm not sure what version it may be for.

I found a site employing it (and that is what raised the interest), and I found what appears to be a part of the code:

Code:

<!-- BEGIN switch_enable_wincash_popup -->
<script language="Javascript" type="text/javascript">
<!--
   if ( {F_WINCASH_POPUP} )
   {
      window.open('{U_WINCASH_POPUP}', 'WinCash', 'HEIGHT=225,resizable=no,WIDTH=400');;
   }
//-->
</script>
<!-- END switch_enable_wincash_popup -->


However, I'm only guessing that that is a part of this Mod. On the site I found this on, there was no pop up when you achieved the cash. Not sure if there's an ability to turn that feature off or not; just making some guesses here.


Does anyone know what Mod this may be (and where to find it) or a Mod that does the same things (and where to find it)?

Thank you if you can help me!
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Mon Apr 13, 2009 1:26 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

I once knew of a site which had it, but that site is gone now. I think there is one still online which has that MOD, but I am not totally sure.

In any case, it's a simple thing to do, so there's no point in wasting a bunch of time looking for an old MOD when one can make it again himself.

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Apr 13, 2009 5:53 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

I'm no Php writer, though. I wouldn't even know where to begin.

I'd rather find an old Mod and attempt to update that, rather than wasting a lot of time working on something in which I'd have no idea what in the blue blazes I'm doing. XD
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Mon Apr 13, 2009 6:49 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

I looked for it too, and could not find it. I also looked for Random Cash MOD, since that might have been a name of one.

In any case, if you're trying to make the kind of site which I think you're trying to make, then learning PHP will be beneficial.

Here is where to start:

1.) You want random credits, and also you want these to be given out randomly. The best thing to use here is the function mt_rand(). MT stands for Mersenne twister, which is the algorithm used to generate random numbers.

mt_rand() accepts two arguments, a minimum and a maximum. So if we use something like this:

Code:
$number = mt_rand(1,3);

Then $number will contain either a one, a two, or a three. We can, of course, use some larger numbers to determine how much cash to award.

Good so far!

2.) Now we need to determine where to place this code. At first, you would probably want to put it in page_header.php, since that file shows the common header placed on all phpBB pages.

But, maybe there is a better place! You don't want people getting cash all the time! And you don't want people to abuse your site for it, either.

So the best place to put this code is in sessions.php, right in the code which updates a user's session at least once a minute.

Code:

               if ( $userdata['user_id'] != ANONYMOUS )
               {
                  $sql = "UPDATE " . USERS_TABLE . "
                     SET user_session_time = $current_time, user_session_page = $thispage_id
                     WHERE user_id = " . $userdata['user_id'];
                  if ( !$db->sql_query($sql) )
                  {
                     message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
                  }
               }

Right inside this block, we will insert the code, since we only want logged-in users to get cash!

3.) Now that we give out cash at least once a minute and only to logged-in users, we might want to put some extra odds in there. How about making a 1 in 4 chance of earning cash?

So we use the mt_rand() function like this:
Code:

if (mt_rand(1,4) == 1)
{
   echo('Cash will be given out on a 1 in 4 chance.');
}


4.) Now that we have set the odds and chances for receiving cash, we can use mt_rand() again to determine how much cash to give. Let's give the user a random amount from 10 to 15. Our code now looks like this:

Code:

if (mt_rand(1,4) == 1)
{
      // Give the user some cash from 10 to 15
      $cash_earned = mt_rand(10,15);
}


So far, so good.

5.) Now that we've given the user a random amount of cash, we need to update the database. Fortunately, we can use the same query which is in sessions.php (I posted it in step 2)

Our code will now look like this:

Code:

$cash_update = '';
if (mt_rand(1,4) == 1)
{
         // Give the user some cash from 10 to 15
         $cash_earned = mt_rand(10,15);

   $cash_update = ', user_cash = user_cash + ' . $cash_earned;
}

What this does is declare a variable, $cash_update, which will hold a piece of the SQL query which updates the phpbb_users database table. The variable is initially blank, but if the user does win some cash, it gets set with the amount earned.

6.) Edit the SQL query which updates the users table. This step is easy. We merely take a line from the existing query, and add our $cash_update variable to the end of that line:

Code:

SET user_session_time = $current_time, user_session_page = $thispage_id $cash_update



7.) The final product. Here is what the final code will look like in sessions.php:
Code:

               if ( $userdata['user_id'] != ANONYMOUS )
               {
                  $cash_update = '';
                  if (mt_rand(1,4) == 1)
                  {
                        // Give the user some cash from 10 to 15
                        $cash_earned = mt_rand(10,15);

                     $cash_update = ', user_cash = user_cash + ' . $cash_earned;
                  }

                  $sql = "UPDATE " . USERS_TABLE . "
                     SET user_session_time = $current_time, user_session_page = $thispage_id $cash_update
                     WHERE user_id = " . $userdata['user_id'];
                  if ( !$db->sql_query($sql) )
                  {
                     message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
                  }
               }


And that's how to make a MOD. Hopefully you will be able to use this to your advantage!

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Apr 13, 2009 7:05 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

I think I get! So random number decides whether or not they will actually get something, then it decides how much they get, then it updates the database holding their cash files?


So I want to up the chances of winning, I could just change it to something like this:

if (mt_rand(1,2) == 1)

And that would yield basically a 50% chance of winning something?


And if I want to change the amount earned, I just update the $cash_earned section to have different minimum and maximums?


But I have another question. I have multiple currencies set up, so would I simply change user_cash to be something, like, user_gold or user_example?

Or would I need to update more things as well?
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Mon Apr 13, 2009 7:43 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

Acaria wrote:

Or would I need to update more things as well?

No, I think you've got it. Everything you've said is correct.

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Apr 13, 2009 7:49 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

Thank you, DogCow! You're awesome!

Hopefully this will be my first real step towards learning how to code my own Php! icon_biggrin.gif
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Tue Apr 14, 2009 9:44 am 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

Acaria, I've made a fairly big mistake which I realized while eating breakfast this morning.

The code I've written will overwrite the user's cash and reset it to whatever the earnings are, instead of adding it! icon_eek.gif

Here is what the line should look like--

Instead of
Code:
$cash_update = ', user_cash = ' . $cash_earned;

it should be:
Code:
$cash_update = ', user_cash = user_cash + ' . $cash_earned;


Sorry! This mistake was not intentional! icon_redface.gif

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Tue Apr 14, 2009 8:06 pm 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

Oh, that makes sense. Thank you for telling me, DogCow! icon_biggrin.gif
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Wed Apr 15, 2009 9:44 am 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

I was worried that you had tried to use this and then messed up your site! icon_eek.gif It's safe to use now, though.
_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Tue Apr 21, 2009 1:58 am 
Post subject: Re: Searching for a Mod -- WinCash Mod, perhaps?

Luckily I'm quite slow when it comes to adding codes, so I hadn't added it yet. XD

Again, though, thank you very much! icon_biggrin.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 4 Hours
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0548 seconds using 16 queries. (SQL 0.0091 Parse 0.0009 Other 0.0448)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo