PDA

View Full Version : Receiving an Item on a Specific Page?


Sibyl
11-12-2015, 12:58 PM
How can I make it so that my users can receive a specific item for going onto a certain page? And, better yet, make it so they can only receive said item once? ;~;

I'd love to do an exploration type system, but I'm uncertain of how to make it rewarding without the user having to be redirected to a shop so they can buy the item themselves, or make it so that there is a promo code. The problem with promo codes is that the user must leave the page to go enter the code, and they could share the codes with the other users. ;~~~;

If anyone knows even a makeshift way, that'd be wonderful ;v; thank you all very much.

Kyttias
11-13-2015, 05:44 AM
I did a write up on some stuff that might be helpful here (http://www.mysidiaadoptables.com/forum/showthread.php?t=4812). Which, if you can follow it, should be more than enough to help you give a user an item -- and if you combine it with the item check later down the page, you should have what you need.

This would be especially good for super important quest items - does the user have a Fancy Lamp? If so, do nothing. If not, give them one.


$item = "Fancy Lamp";
$hasitem = $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner='{$mysidia->user->username}'")->fetchColumn();
if($hasitem){
$document->add(new Comment("You have already obtained this {$item}!"));
} else {
$document->add(new Comment("It looks like you could use this {$item}!"));
$qty = 1;
$newitem = new StockItem($item);
$newitem->append($qty, $mysidia->user->username);
}