Jump to content
MakeWebGames

Lottery Mod


War_Hero

Recommended Posts

Hi all! It's been ages since I last posted on here, so I thought I'd contribute a feature I've been working on.

I searched for lottery mods already on here, and unless I didn't look properly, I couldn't see any free ones that actually allows the user to choose their own numbers.

Description:

Upon going onto lottery.php, the user will be presented with a table of checkboxes, numbered 1 to 46. The info above the table will ask them to select 6 of their own numbers or press Lucky Dip to have them randomly selected for them. This feature uses Javascript. If the user opts to select the numbers themselves, they cannot press Buy Ticket until 6 boxes have been ticked. When 6 have been ticked, all other boxes become disabled and they can buy the ticket. If a box is then unticked, the others become enabled and the Buy Ticket button becomes disabled.

The Lucky Dip randomly selects 6 numbers, ticks the correct boxes and disables them, and enables the Buy Ticket button.

A reset button is provided to clear any boxes ticked, whether manually or by the Lucky Dip.

The price of each lottery ticked can be edited via the Staff feature I have made, so no edit in the file will be needed. Also, the ticket limit can also be altered via the staff feature.

The lottery numbers are drawn (with my cron settings) every Saturday night at 20:00. If no tickets match all 6 numbers, there will be a rollover. This will continue to happen until all 6 numbers are matched. Talking of the cron, the numbers are drawn from the cron_lottery.php file.

 

Right, time for the installation...it shouldn't be too difficult:

Step 1

Run these SQLs:

You're unable to view this code.

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

 

 

Step 2

Create a new cron (however it is you do it, cPanel, Direct Admin, etc) with these values:

Minute: 0

Hour: 20

Day of Month: *

Month: *

Day of Week: 6

Command: Erm, yeah! :)

Step 3

Create a file called cron_lottery.php:

You're unable to view this code.

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

 

 

Step 4

Create a file called lottery.php:

You're unable to view this code.

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

 

 

Step 5

Create a file called staff_lottery.php:

You're unable to view this code.

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

 

 

And you're done. :)

I will (hopefully) be adding more to this feature, for free. I intend on improving the staff feature, creating a way in which users can see previous lottery results and also implement other games, such as the Dream Number, etc.

I have tested this feature, and it works. But as always, if there are any bugs, please report them here and I will fix them (or attempt to!). And please feel free to contribute any other ideas. If you have any questions about the feature, please don't hesitate to ask. :)

Link to comment
Share on other sites

Thank you all for the comments. :)

I hope you all like the feature. If/when one of you install it, please let me know if all the aspects of the mod work. It works on my end, I'd just like to ensure it will work elsewhere. :)

When inserting this > INSERT INTO lotteryDetails (50,10,0);

Getting this > #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '50,10,0)' at line 1

I am not a coder obviously.... :D

Think I figured that out on my own... All installed and one slight problem

Pick six numbers...click buy ticket...and this happens:

"You either didn't select any numbers or you didn't select 6 numbers."

It does buy tickets if you are using the "Lucky Dip" feature however. Other than that it is pretty nice! :)

Link to comment
Share on other sites

i have added this mod to my game and works perfectly fine. Just have to wait till saturday to see if the jackpot is credit to the lucky user ;). All in all, its a great mod! Thanks!

Can you clue the rest of us on how you got it working? Still the same for me

Pick six numbers...click buy ticket...and this happens:

"You either didn't select any numbers or you didn't select 6 numbers."

No change.... I even used different browsers and still no luck. :(

Link to comment
Share on other sites

i have added this mod to my game and works perfectly fine. Just have to wait till saturday to see if the jackpot is credit to the lucky user ;). All in all, its a great mod! Thanks!

Can you clue the rest of us on how you got it working? Still the same for me

Pick six numbers...click buy ticket...and this happens:

"You either didn't select any numbers or you didn't select 6 numbers."

No change.... I even used different browsers and still no luck. :(

I might be able to provide some assistance if I can see the problem first hand. Because if you have copied and pasted the code as it is, which I'm assuming you have done, then there should be no problems.

Just a quick question: when you press Lucky Dip, do all of the checkboxes become disabled and the Lucky Dip button become disabled?

Link to comment
Share on other sites

when you click lucky dip. it selects 6 numbers for you and when you click buy ticket. IT WORKS.

However, if you pick the numbers yourself, it gives that error saying "You either didn't select any numbers or you didn't select 6 numbers."

Exactly the same for me....... It looks like a great mod but I removed it. When it gets sorted I will use it for sure. :)

Copy and pasted the codes exactly. All other mods have worked except for this one so I dont think it is something I did. I even spelled language right because it is spelled wrong in your code thinking that might fix it but it did not...

Link to comment
Share on other sites

the issues with not being able to selcect your own numbers lies within the globals.php with the $val

$val = trim($val);

 

//Removes tags html/php

$val = strip_tags($val);

 

//Add inverted bars to a string

$val = addslashes($val);

Thats what the issues are i removed and tested and selecting you tickets work.

so if any one can shred some light on how to over come this?

Link to comment
Share on other sites

the issues with not being able to selcect your own numbers lies within the globals.php with the $val

$val = trim($val);

 

//Removes tags html/php

$val = strip_tags($val);

 

//Add inverted bars to a string

$val = addslashes($val);

Thats what the issues are i removed and tested and selecting you tickets work.

so if any one can shred some light on how to over come this?

Thank you for finding that out. This isn't the part with if(get_magic_quotes_gpc() == 0) { etc, is it? Because I don't have that bit of code in my own globals.php, I don't believe...

Link to comment
Share on other sites

I believe this $var code is one of those put this in your header and it will secure your site loada bollox!

Remove it and yes you will find stuff now works as its a false sense of security that does more damage than good.

Secure your code. If using mc2 then wait for 2.0.3 as its starting to look promising as a base foundation.

Link to comment
Share on other sites

I believe this $var code is one of those put this in your header and it will secure your site loada bollox!

Remove it and yes you will find stuff now works as its a false sense of security that does more damage than good.

Secure your code. If using mc2 then wait for 2.0.3 as its starting to look promising as a base foundation.

Thank you for clearing that up for me. I had a slight feeling it was one of the 'add this and you will secure your site' sort of things.

So anyone experiencing any problems with this feature, please comment out the header code with the $val and see if the lottery works. Please let me know how it goes. :)

Link to comment
Share on other sites

  • 2 weeks later...

i get these errors after i install it can anyone help me

 

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 102

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 108

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 111

Link to comment
Share on other sites

i get these errors after i install it can anyone help me

 

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 102

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 108

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 111

You haven't installed it correctly if you're receiving those errors. It seems like the tables, specifically lotteryDetails and lotteryTickets, aren't in your database. Make sure they are. I can't think of another reason as to why those errors would occur.

Link to comment
Share on other sites

Quote from MC v2.0 class file (mysql)

function fetch_row($result=0)

{

if(!$result) { $result=$this->result; }

return mysql_fetch_assoc($result);

}

Notice anything there... using mysql_fetch_assoc is the same as using $db->fetch_row i really do wish people would read things they code in.

Link to comment
Share on other sites

Quote from MC v2.0 class file (mysql)
function fetch_row($result=0)

{

if(!$result) { $result=$this->result; }

return mysql_fetch_assoc($result);

}

Notice anything there... using mysql_fetch_assoc is the same as using $db->fetch_row i really do wish people would read things they code in.

I know this. :) I just use mysql_fetch_assoc in my mods so it's easier for others to convert to V1 or Lite. I know they could probably do a simple find and replace in their editor, but it's still easier. Also, my editor changes the colour of the mysql functions, so it helps me notice if I've misspelled one. :)

Link to comment
Share on other sites

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