Jump to content
MakeWebGames

Competition System


Recommended Posts

This is my fully automated competition system. It allows you to create competitions for users so they are able to compete with each other for the top 3 prizes.

Features

 

  • Create competition from the control panel - currently crimes and jail busts (names can be edited to suit your game genre).
  • Cancel competition at anytime from the control panel
  • Users can choose to enter a competition
  • Top 10 competitors list
  • Prizes for the top 3 competitors

 

SQL

You're unable to view this code.

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

 

 

competition.php

You're unable to view this code.

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

 

 

competition_control.php

You're unable to view this code.

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

 

 

competition_cron.php (Set the cron for once a day or once a week, or however long you'd like competitions to last)

You're unable to view this code.

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

 

 

In docrime.php replace line 31 with

You're unable to view this code.

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

 

 

In jailbust.php replace line 28 with

You're unable to view this code.

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

 
Link to comment
Share on other sites

I'll look more into the code later, but adding "competition_starting" into users is just wow. Where's the normalisation?

INT(11) is 4 bytes. Say I have 5,000 users, that's (if math serves me correctly) 20,000 bytes of wasted storage. Have it in it's own table, and you've saved yourself 19,996 bytes.

Edited by sniko
Link to comment
Share on other sites

I'll look more into the code later, but adding "competition_starting" into users is just wow. Where's the normalisation?

INT(11) is 4 bytes. Say I have 5,000 users, that's (if math serves me correctly) 20,000 bytes of wasted storage. Have it in it's own table, and you've saved yourself 19,996 bytes.

Fair enough, if you had 5,000 users then yes you may have around 19KB of additional storage; it's not a lot but I understand your point about the need for greater efficiency (even though in this case it is required).

 

I like the idea of this. good work. thos i think i would have to agree with Sniko, But as its free i think that if anyone is going to use it they should make it into there own table.

Might use this.

Thank you for your comments.

Edited by DidNotCompute
Link to comment
Share on other sites

I'll look more into the code later, but adding "competition_starting" into users is just wow. Where's the normalisation?

INT(11) is 4 bytes. Say I have 5,000 users, that's (if math serves me correctly) 20,000 bytes of wasted storage. Have it in it's own table, and you've saved yourself 19,996 bytes.

I just read your post again and I think you may have misinterpreted what "competition_starting" is. It is not when the competition is going to start but what value (e.g. crimes or jail busts) each user starts with; therefore, it is necessary for every user to have.

Link to comment
Share on other sites

I'll agree with @sniko here with adding it to another table. Plus if you do add it to it's own table you can expand on it some more, for example a player can choose a comp they wish to join or join multiple comps.

Granted it would make a bit more of a rewrite but that way it's a variety and it's not limiting the player

Link to comment
Share on other sites

I'll agree with @sniko here with adding it to another table. Plus if you do add it to it's own table you can expand on it some more, for example a player can choose a comp they wish to join or join multiple comps.

Granted it would make a bit more of a rewrite but that way it's a variety and it's not limiting the player

I agree that it would be useful for multiple competitions. :)

Link to comment
Share on other sites

I added this to my game and works fine except for the cron. I did curl the file and added my code behind the command line. This also happens with your lottery system mod. Any ideas how i can make it work properly..

If you don't mind can you paste exactly how you set up the cron in your cron tab/manager? And does it look like your day/hour/min/etc crons?

If you do post them feel free to remove your code that's appended to your url.

Also what version of MCC are you using, 2.0 or 2.0.5 if your using 2.0.5 you can replace the top of this cron file (looks like lines 11-37) with include "globals_nonauth.php";

Take a look at your other cron files that came stock with your game and see how it's done.

If this stuff doesn't work maybe you are receiving an error so have you looked at your error logs? Or you can try to manually direct your browser to the file with your error handler set to display some errors and see if you get any

Link to comment
Share on other sites

Did you look into my other methods/tips I was talking about? And with this cron l, theoretically you don't need the code ;) it doesn't check for it in the file lol got that [MENTION=70333]DidNotCompute[/MENTION]?

Alternatively what you can do is add the stuff from line 38? down to your already existing cron_day file

Link to comment
Share on other sites

ok this is how i have the code set up for competition_cron.php. I want it to update at server reset on a daily basis. So this is the command I put into my cron manager.

 

You're unable to view this code.

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

- - - Updated - - -

oops sorry I put in this command for the cron manager. 0 0 * * * curl http://www.firstmobsterwar.net/competition_cron.php?code=

Edited by KyleMassacre
Added code tags
Link to comment
Share on other sites

Well it's kind of hard to debug it really since I didn't install the mod nor do I really want to lol but what errors do you get?

Also when pasting some code use the code tags please, it makes life real easy for us

 

So I checked my error messages from my cron email. here is what it says..

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0

100 159 100 159 0 0 93 0 0:00:01 0:00:01 --:--:-- 229

100 159 100 159 0 0 93 0 0:00:01 0:00:01 --:--:-- 229

<br />

<b>Fatal error</b>: Call to a member function query() on a non-object in

<b>/home/firstmob/public_html/competition_cron.php</b> on line <b>9</b><br />

Link to comment
Share on other sites

I've tested both the competition and lottery system and they work fine.

The error suggests that $db is not referring to an object. Could you post your config.php file?

[MENTION=69014]Greenslip[/MENTION]

Here is my config.php file

<?php

$_CONFIG = array(

'hostname' => 'localhost',

'username' => '111111',

'password' => '111111',

'database' => '111111',

'persistent' => 0,

'driver' => 'mysql',

'code' => 'I delete this for my security'

);

?>

 

sorry not sure how to add tags on here..

Link to comment
Share on other sites

Here is my config.php file

<?php

$_CONFIG = array(

'hostname' => 'localhost',

'username' => '111111',

'password' => '111111',

'database' => '111111',

'persistent' => 0,

'driver' => 'mysql',

'code' => 'I delete this for my security'

);

?>

 

sorry not sure how to add tags on here..

The only way I can replicate the error is by not defining $db. Hmmm.

Have you ever edited the class/class_db_mysql.php file? If so, could you post it?

Link to comment
Share on other sites

The only way I can replicate the error is by not defining $db. Hmmm.

Have you ever edited the class/class_db_mysql.php file? If so, could you post it?

 

I haven't edited anything on that but here it is..

 

You're unable to view this code.

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

Link to comment
Share on other sites

I can't see why this error is occurring. What I'd suggest you do is add everything from line 22 onwards into your daily cron file.

can you post what I'm suppose to put, I'm a little confused on what your telling me. Do I post what is in the class file or what is in the competition cron file into my daily cron..

Link to comment
Share on other sites

can you post what I'm suppose to put, I'm a little confused on what your telling me. Do I post what is in the class file or what is in the competition cron file into my daily cron..

Paste all of this into your daily cron file and delete the competition_cron.php file.

 

You're unable to view this code.

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

Edited by DidNotCompute
Removed first 6 lines
Link to comment
Share on other sites

  • 2 months later...
  • 7 months later...

Hi i'm new to this coding thing, probably a reason for getting a script in the first place, due to its all done for you.

I know a little by looking at what happens when editing things etc.

I added this mod and found it works fine with no problems, however i would like to know what code i would have to add to the cron so as the winners get a event notification saying they have won xxmoney fom the xxcompetition.

However i am willing to learn so if someone deos this for me can they please break it down and kind of explain how it works so as i can posibly add events to other things.

I also added the mod lottery made by the same person and would also like an event notification added to that so if i learn from this one, i may be able to add one to the lottery.

Link to comment
Share on other sites

Hi i'm new to this coding thing, probably a reason for getting a script in the first place, due to its all done for you.

I know a little by looking at what happens when editing things etc.

I added this mod and found it works fine with no problems, however i would like to know what code i would have to add to the cron so as the winners get a event notification saying they have won xxmoney fom the xxcompetition.

However i am willing to learn so if someone deos this for me can they please break it down and kind of explain how it works so as i can posibly add events to other things.

I also added the mod lottery made by the same person and would also like an event notification added to that so if i learn from this one, i may be able to add one to the lottery.

Hello Stevie i believe he used a separate file for the cron there is 2 ways you can do it

1.

Open up your cron_day.php and go to the last line before the ?> and add this code

You're unable to view this code.

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

 

or you can create the new file as he has done and link it manually via the cronjob manager in your cpanel

Edit: if you are going to use a separate file then i found the cron on page 2

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