Item recieved notification?

Forum
Last Post
Threads / Messages

Ittermat

The awesomesauce
Member
Joined
Feb 2, 2016
Messages
311
Points
18
Location
in front of my laptop
Mysidian Dollar
21,343
Is there a way to set it up so the user gets a message when I give them an item through the ACP?

So for example.. I go to- ACP->Inventory->Give item to User

and I give them an item. Lets say I gave them some cat food?

So I'd like a message to be automatically sent to let them know this has been done... whether it says something along the lines of-

Subject: You've been given an item
From: Staff

Congratulations! you've been given a "cat food" (item image) By a staff member! No need to reply to this message! We were just letting you know it was now in your inventory! (links to inventory)

~Atrocity staff


Otherwise they have no idea they've gotten something..and its sorta frusterating...
 
Well Mys v1.3.x does not have a notification system, which is planned for Mys v1.4.0. Its not difficult to make it though, all you need is to create a PM after the insert query of creating an item for user.
 
Well when you create an item for user inventory, the script will executes an INSERT SQL query, which you can find from file /admincp/inventory.php. Or alternatively, it runs an UPDATE query if the user already has this item. The code should be on these lines:

Code:
            if(is_object($inventory)){
                $newquantity = $inventory->quantity + $mysidia->input->post("quantity");  
                $mysidia->db->update("inventory", array("quantity" => $newquantity), "itemname='{$mysidia->input->post("itemname")}' and owner='{$mysidia->input->post("owner")}'");     
            }
            else{
                $item = $mysidia->db->select("items", array("id","category"), "itemname = '{$mysidia->input->post("itemname")}'")->fetchObject();    
                $mysidia->db->insert("inventory", array("iid" => NULL, "category" => $item->category, "itemname" => $mysidia->input->post("itemname"),
                                                        "owner" => $mysidia->input->post("owner"), "quantity" => $mysidia->input->post("quantity"), "status" => 'Available'));    
            }


So what you need to do is to write another SQL query that adds a private message to the recipient of the item, right below these lines.
 
Alright, I will write the actual code for you, its not very difficult really. My way to do this is to create a PrivateMessage object and call the post() method to send and save it, which may be harder to understand for you than to write an INSERT query. But since you dont even know how to write an INSERT query, it doesnt matter, just copy/paste the code and follow the instructions.

This is the complete code:

Code:
$message = new PrivateMessage;
$message->setrecipient($mysidia->input->post("owner"));
$message->setmessage("You have received an item from Admin", "Dear {$mysidia->input->post("owner")}, you have received {$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} on Atrocity.com. Enjoy!");
$message->post();
All you need to do is to add it below the if...else statement code I showed you in an earlier post. Search for 'public function add()' in file /admincp/inventory.php, and you should find it around line 29-37.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,132
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top