Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [Mccodes V2] Lucky Box Remake  (Read 115 times)

Peterisgb

  • Basic Member
  • *
  • Reputation Power: 20
  • Peterisgb has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
    • Email
[Mccodes V2] Lucky Box Remake
« on: January 08, 2012, 01:59:48 PM »
ok, i didnt like the orignal copy of luck box due to you can only box 5 times a day. :(

This mod allows you to open a box every 15 minutes.
Enjoy.

You might need to edit the lucky.php to suit your game abit more.

ok First make a Page called cron-15.php and place this into it
Code: [Select]
<?php
include "config.php";
global 
$_CONFIG;
define("MONO_ON"1);
require 
"class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
 
$_CONFIG['username'],
 
$_CONFIG['password'],
 
$_CONFIG['database'],
 
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$db->query("UPDATE users SET boxes_opened=0");
?>


Add the cron to your server
0/15 0 0 0 http://www.yourgame.com/cron-15.php


Next update lucky.php with the file located below.
Code: [Select]
<?php
include "globals.php";
global 
$db,$ir,$r,$c,$userid,$h,$li;
print 
"
<br />
<img src='fusion_icon.png' height='200' width='200'>
<br />
<h3>Lucky Boxes</h3><hr />"
;
if(
$_GET['open'])
{
if(
$ir['boxes_opened'] >= 1)
{
die(
"Sorry, you have already opened the box.<br />");
}


$num=rand(19);



$db->query("UPDATE users SET boxes_opened=boxes_opened+1 WHERE userid=$userid");
$db->query("UPDATE users SET totalopened=totalopened+1 WHERE userid=$userid");
$ir['money']-=0;
switch(
$num)
{

case 
1:
$tokens=rand(5,50);
print 
"You Gained {$tokens} Crystals";
$db->query("UPDATE users SET crystals=crystals+{$tokens} WHERE userid={$userid}");
break;


case 
2:
$money=rand(3303300);
print 
"You Gained \${$money}";
$db->query("UPDATE users SET money=money+{$money} WHERE userid={$userid}");
break;

case 
3:
$ex=rand(2507500);
print 
"You Gained {$ex} XP";
$db->query("UPDATE users SET exp=exp+{$ex} WHERE userid={$userid}");
break;

case 
4:
$tokens=rand(5,50);
print 
"You Gained {$tokens} Gold";
$db->query("UPDATE users SET crystals=crystals+{$tokens} WHERE userid={$userid}");
break;

case 
5:
$tokens=rand(5,50);
print 
"You Gained {$tokens} Gold";
$db->query("UPDATE users SET crystals=crystals+{$tokens} WHERE userid={$userid}");
break;

case 
6:
$money=rand(3303300);
print 
"You Gained \${$money}";
$db->query("UPDATE users SET money=money+{$money} WHERE userid={$userid}");
break;

case 
7:
$ex=rand(2507500);
print 
"You Gained {$ex} XP";
$db->query("UPDATE users SET exp=exp+{$ex} WHERE userid={$userid}");
break;

case 
8:
$money=rand(3303300);
print 
"You Gained \${$money}";
$db->query("UPDATE users SET money=money+{$money} WHERE userid={$userid}");
break;

case 
9:
$ex=rand(2507500);
print 
"You Gained {$ex} XP";
$db->query("UPDATE users SET exp=exp+{$ex} WHERE userid={$userid}");
break;



}
print 
"<hr />
<a href='explore.php'>Back to Town</a>"
;
}
else
{
print 
"A man comes up to you and whispers, <br />
\"I have magical box, I let you open one every 15 Minutes.\"<br />
 Deal or no deal?<hr />
<a href='lucky.php?open=1'>Okay, open one.</a><br />
<a href='explore.php'>No thanks.</a>"
;
}
$h->endpage();
?>


save that, add this into your database

totalopened int 11 default 0

Open your viewuser.php

Find
Code: [Select]
User Level: $userl<br />

add either before or after
Code: [Select]
Opened {$r['totalopened']} Boxes<br />

Next Open header.php
add this
Code: [Select]
if($ir['boxes_opened'] == 0)
{
$box = "<img src='box.png' title='Lucky Box' height='12' width='12' />";
}
else
{
$box = "";
}

Add this where you want this to show, i placed this under Username

<a href='lucky.php' target='_parent'><b>Achievments:</b>$d $box</a>

and finally Upload the Attached image.

and finally, let me know what you think, enjoy.
« Last Edit: January 08, 2012, 02:05:04 PM by Peterisgb »
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.