Jump to content
MakeWebGames

Starter Pack/ Bonus


Recommended Posts

This script is to give free stuff to the new people who join the game...

So first all alter this -

 

You're unable to view this code.

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

 

 

Now make a file called bonus.php or what ever you want and add -

 

You're unable to view this code.

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

 

 

Now open up headers and add this somewhere near the jail thingy bit -

 

You're unable to view this code.

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

 

 

Luckily for me I got the V2 item system on my V1 game

Note: SQL only MCCodes. But inventory etc I re-coded.

  • Like 2
Link to comment
Share on other sites

I came up with something just like this a long time ago and I'm going to tell you what people told me since its a better idea :p.

Do this on register and here's why:

  1. No additions to the users table
  2. A player can only register once
  3. Less file edits

On the register page where they get inserted in the database you just do something like this:

You're unable to view this code.

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

Then you can send a message or an event to the player which ever you choose.

all done

**EDIT**

Also you have like 3 different queries to update one table. How about one query only for example, if you want to keep it the same way as op:

You're unable to view this code.

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

other than that its not bad and will get the job done granted it clutters the header even more ;)

Thanks for the contribution though

Edited by KyleMassacre
more detail
  • Like 1
Link to comment
Share on other sites

  • 4 years later...
On 6/9/2013 at 9:58 AM, KyleMassacre said:

Also if your using V2.0.5 you dont have to include or require global_func.php and here, ill expand a little bit for ya:

item_add($i, itemidhere, qtyhere); $message = "Just for joining ".$set["game_name"]." you were given /*place item qty/name here*/ to start you off, enjoy and play nice"; event_add($i,$message); //or $mail = $db->query("insert into mail (mail_to, mail_from, mail_time, subject, text) values ($i, '1', ".time().",Welcome,{$message})");

You're unable to view this code.

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

 

You can do a little something like that

If I remember correctly: The BELOW goes into register.php

 

You're unable to view this code.

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

Would that not be correct to send the new player a message and add multiple items?

Not used Mccodes in a long time! Found a few files stored away on a USB drive.

 

Edited by Zerex
Link to comment
Share on other sites

Userid is usually $userid but in any case just use $ir['userid']

Also, you'd want an if statement covering the whole chunk of code checking if that new player had already received it.

To reduce code runs best place would be putting it in register.php or if your game has it. emailactivation.php That way it won't be running every click for every user.

On 6/8/2013 at 6:30 PM, KyleMassacre said:

I came up with something just like this a long time ago and I'm going to tell you what people told me since its a better idea :p.

Do this on register and here's why:

  1. No additions to the users table
  2. A player can only register once
  3. Less file edits

On the register page where they get inserted in the database you just do something like this:

include_once "global_func.php"; item_add($i, itemidhere, qtyhere);//note: I don't remember the var for the userid getting added but its near by so just take a gander ;)

You're unable to view this code.

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

 

Then you can send a message or an event to the player which ever you choose.

all done

**EDIT**

Also you have like 3 different queries to update one table. How about one query only for example, if you want to keep it the same way as op:

$update = mysql_query("update users set money = money + 500, crystals = crystals + 500, donatordays = donatordays + 10, bonus = 2 where userid = $userid");

You're unable to view this code.

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

 

other than that its not bad and will get the job done granted it clutters the header even more ;)

Thanks for the contribution though

ooh mentioned here, just follow this

Link to comment
Share on other sites

On 8/23/2023 at 10:43 AM, Zerex said:

The way I posted does go on the register page.

And? I simply stated that I agreed with Kyle and Ishraq. Are your feelings hurt because I didn't call out your name for the class. Sorry about that. Here's your pat on the head and a good boy too. 

Link to comment
Share on other sites

8 minutes ago, newttster said:

And? I simply stated that I agreed with Kyle and Ishraq. Are your feelings hurt because I didn't call out your name for the class. Sorry about that. Here's your pat on the head and a good boy too. 

Okay, relax kid - Nobody said anything about feelings being hurt I was just stating a fact.

This is the exact reason forums went downhill, because people get behind a keyboard and develop a "God" complex.

Be nice, be respectful, have some manners - You'll enjoy life a lot more with a smile on it.

Edited by Zerex
Link to comment
Share on other sites

50 minutes ago, Zerex said:

Okay, relax kid - Nobody said anything about feelings being hurt I was just stating a fact.

This is the exact reason forums went downhill, because people get behind a keyboard and develop a "God" complex.

Be nice, be respectful, have some manners - You'll enjoy life a lot more with a smile on it.

You talk about being respectful, yet you call me a kid. You have no idea who I am or what I am. God complex. No. What I typed is nothing more or less than what I would have said to you face to face. If I misinterpreted your comment about your register post, I apologize. From this side of the screen, right or wrong, it looked to me like you were pouting that I didn't acknowledge your input. As for being nice, respectful and having manners ... if you look around, you'll see that I am almost always so. 

 

Link to comment
Share on other sites

Just now, newttster said:

You talk about being respectful, yet you call me a kid. You have no idea who I am or what I am. God complex. No. What I typed is nothing more or less than what I would have said to you face to face. If I misinterpreted your comment about your register post, I apologize. From this side of the screen, right or wrong, it looked to me like you were pouting that I didn't acknowledge your input. As for being nice, respectful and having manners ... if you look around, you'll see that I am almost always so. 

 

You wanted a respectful response after making a remark like I'm a little child with the pat and a good boy comment? Please, I'll show nothing but respect, but what you said warranted none.

I'm all for manners and respect, but that doesn't mean I'll be belittled by a random on the internet.

Especially when all I'm doing is contributing to help others.

Anyway, have a good one.
 

Link to comment
Share on other sites

On 8/23/2023 at 4:40 AM, Zerex said:

Edited Wednesday at 03:44 PM by Zerex

It's all good. Everyone is here to help. Let's just ease this situation. No need to quarrell or edit anything.

Any new person will come on this topic and know what to do so let's leave it at that and move on.

  • Like 1
Link to comment
Share on other sites

On 8/25/2023 at 5:44 AM, Magictallguy said:

Keep the flaming out of this topic please. A blow-up over genuine support is not how we do things here.

Ooooooh MTG is still around! 

A true legend of the forum - It's been a really really really long time. 

Link to comment
Share on other sites

7 hours ago, Markku said:

Ooooooh MTG is still around! 

A true legend of the forum - It's been a really really really long time. 

You're too kind 🙂

So, to get us back on topic, here's an update to MCCv2.
I turned the rewards into a config array at the top of the file. Be sure to update the bonus_items to the id=>quantity you want to give!
You're no longer limited to 2 items either. Set as many or as few as you wish - at least 1 required.

PHP 7.4-friendly

You're unable to view this code.

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

 

And here's the same script, updated to PHP 8.2 - which, in all honesty, merely adds the return typehinting for the basic_error() function.

You're unable to view this code.

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

 

  • Like 2
Link to comment
Share on other sites

7 hours ago, Magictallguy said:

You're too kind 🙂

So, to get us back on topic, here's an update to MCCv2.
I turned the rewards into a config array at the top of the file. Be sure to update the bonus_items to the id=>quantity you want to give!
You're no longer limited to 2 items either. Set as many or as few as you wish - at least 1 required.

PHP 7.4-friendly

<?php declare(strict_types=1); global $db, $ir, $h, $set; include __DIR__ . '/globals.php'; // bonus_items = [item id => quantity, ...] $rewards = [ 'money' => 500, 'crystals' => 500, 'donatordays' => 10, 'bonus_items' => [ 2 => 100, 4 => 100, ] ]; // If the bonus item id is not set if (empty($rewards['bonus_items'])) { basic_error('The welcome pack hasn\'t been set up. Please notify an administrator.'); } // If the bonus item is set, but doesn't exist $getItems = $db->query( 'SELECT itmid, itmname FROM items WHERE itmid IN (' . implode(', ', array_keys($rewards['bonus_items'])) . ')' ); // If there's no result at all if (!$db->num_rows($getItems)) { basic_error('The items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // Get the items into an array. [item id => name, ...] $items = []; while ($row = $db->fetch_row($getItems)) { $items[$row['itmid']] = $row['itmname']; } // If the amount of items in our array doesn't match the number of items set in the Bonus Pack if (count($items) !== count($rewards['bonus_items'])) { basic_error('Some of the items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // If the user has already claimed their Bonus Pack if ($ir['bonus'] > 1) { basic_error('You\'ve already claimed your Bonus Pack.'); } // Ok! Looks like we're clear. Grant the Bonus Pack! // Update the user $db->query( 'UPDATE users SET money = money + ' . $rewards['money'] . ', crystals = crystals + ' . $rewards['crystals'] . ', donatordays = donatordays + ' . $rewards['donatordays'] . ', bonus = 2 WHERE userid = ' . $ir['userid'] ); // Give 'em the items foreach ($rewards['bonus_items'] as $id => $quantity) { item_add($ir['userid'], $id, $quantity); } ?> Your welcome pack has been credited successfully.<br><br> You have gained 500 game money.<br> You have gained 500 crystals.<br> You have gained 10 days donators status.<br> <?php // Dynamically output the items, meaning we can change them at any time without having to update this foreach ($items as $id => $name) { echo 'x' . $rewards['bonus_items'][$id] . ' <a href="iteminfo.php?ID=' . $id . '">' . $name . '</a><br>'; } ?> The donator status given here will give you the following benefits:<br><br> <ul> <li> Red name + cross next to your name.</li> <li> Friends and Enemies List.</li> <li> 17% Energy every 5 minutes instead of 8%.</li> <li> 25% Stats gain in the donator gym.</li> <li> Unlocking of enhanced features.</li> <li> 25 street steps instead of 10 per day.</li> </ul> This is a complementary welcome pack.<br> Just a way to say thank you for joining <?php echo $set['game_name']; ?>. <?php // End $h->endpage(); /** * A simple "error and exit" function, which keeps the output styling Dragon Blade originally wrote for this script. * @param string $msg * @return void */ function basic_error(string $msg) { global $h; ?> <hr style="width: 50%;"> <h3>ERROR</h3> <?php echo $msg; ?><br><br> <hr style="width: 50%;"> <a href="index.php">&gt; Go Back</a> <hr style="width: 50%;"> <?php $h->endpage(); exit; }

You're unable to view this code.

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

 

And here's the same script, updated to PHP 8.2 - which, in all honesty, merely adds the return typehinting for the basic_error() function.

<?php declare(strict_types=1); global $db, $ir, $h, $set; include __DIR__ . '/globals.php'; // bonus_items = [item id => quantity, ...] $rewards = [ 'money' => 500, 'crystals' => 500, 'donatordays' => 10, 'bonus_items' => [ 2 => 100, 4 => 100, ] ]; // If the bonus item id is not set if (empty($rewards['bonus_items'])) { basic_error('The welcome pack hasn\'t been set up. Please notify an administrator.'); } // If the bonus item is set, but doesn't exist $getItems = $db->query( 'SELECT itmid, itmname FROM items WHERE itmid IN (' . implode(', ', array_keys($rewards['bonus_items'])) . ')' ); // If there's no result at all if (!$db->num_rows($getItems)) { basic_error('The items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // Get the items into an array. [item id => name, ...] $items = []; while ($row = $db->fetch_row($getItems)) { $items[$row['itmid']] = $row['itmname']; } // If the amount of items in our array doesn't match the number of items set in the Bonus Pack if (count($items) !== count($rewards['bonus_items'])) { basic_error('Some of the items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // If the user has already claimed their Bonus Pack if ($ir['bonus'] > 1) { basic_error('You\'ve already claimed your Bonus Pack.'); } // Ok! Looks like we're clear. Grant the Bonus Pack! // Update the user $db->query( 'UPDATE users SET money = money + ' . $rewards['money'] . ', crystals = crystals + ' . $rewards['crystals'] . ', donatordays = donatordays + ' . $rewards['donatordays'] . ', bonus = 2 WHERE userid = ' . $ir['userid'] ); // Give 'em the items foreach ($rewards['bonus_items'] as $id => $quantity) { item_add($ir['userid'], $id, $quantity); } ?> Your welcome pack has been credited successfully.<br><br> You have gained 500 game money.<br> You have gained 500 crystals.<br> You have gained 10 days donators status.<br> <?php // Dynamically output the items, meaning we can change them at any time without having to update this foreach ($items as $id => $name) { echo 'x' . $rewards['bonus_items'][$id] . ' <a href="iteminfo.php?ID=' . $id . '">' . $name . '</a><br>'; } ?> The donator status given here will give you the following benefits:<br><br> <ul> <li> Red name + cross next to your name.</li> <li> Friends and Enemies List.</li> <li> 17% Energy every 5 minutes instead of 8%.</li> <li> 25% Stats gain in the donator gym.</li> <li> Unlocking of enhanced features.</li> <li> 25 street steps instead of 10 per day.</li> </ul> This is a complementary welcome pack.<br> Just a way to say thank you for joining <?php echo $set['game_name']; ?>. <?php // End $h->endpage(); /** * A simple "error and exit" function, which keeps the output styling Dragon Blade originally wrote for this script. * @param string $msg * @return void */ function basic_error(string $msg): void { global $h; ?> <hr style="width: 50%;"> <h3>ERROR</h3> <?php echo $msg; ?><br><br> <hr style="width: 50%;"> <a href="index.php">&gt; Go Back</a> <hr style="width: 50%;"> <?php $h->endpage(); exit; }

You're unable to view this code.

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

 

Still as generous as ever!

May they continue, May they flourish, May they help all those in need of Mccode assistance!

In all seriousness, Great work @Magictallguy - Your contributions to this forum never cease to end. 

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