View Single Post
  #2  
Old 11-13-2015, 05:44 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 89,103
Kyttias is on a distinguished road
Default

I did a write up on some stuff that might be helpful here. 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.

PHP Code:
$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);  

__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote