View Full Version : Making a Trinket System
Hwona
07-03-2014, 12:59 PM
Hello everyone! I'm working on a trinket sytem that I'm going to be sharing with everyone later on, but I was wondering whether or not this code would work for the item function(I'm pretty sure it's done wrong):
function items_trinket($item, $adopt){
$mysidia = Registry::get("mysidia");
$slot1 = $this->adopt->getAdoptSlot1();
$slot2 = $this->adopt->getAdoptSlot2();
$slot3 = $this->adopt->getAdoptSlot3();
$slot4 = $this->adopt->getAdoptSlot4();
$slot5 = $this->adopt->getAdoptSlot5();
$message = “<input type=’radio’ name=’slot[ ]’ value=’slot1’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot1}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot2’ /><span class=’slot’><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot2}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot3’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot3}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot4’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot4}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot5’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot5}.png'></span><br>
<input type=’submit’ name=’choose’ value=’Give Trinket to Adoptable’ />”;
return $message;
if (!isset($_POST[‘slot’])) {
$noslot = “You have not selected a slot to place this trinket in.”
return $noslot;
}
else {
$slot = $_POST[‘slot’];
$image = $item->itemname;
$note = "The trinket has been given to this adoptable!";
$mysidia->db->update("owned_adoptables", array("lastbred" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$delitem = $item->remove();
return $note;
}
The item is supposed to give a user an option of 5 slots to put a trinket into after they selected an adopt to give the trinket to. Is there anything that needs to be fixed/added. All other files have been updated as necesary. Thanks! :D
squiggler
07-03-2014, 03:42 PM
What about that reward/toy mod that was recently posted? Isn't that the same thing? *I know nothing*
Hwona
07-03-2014, 04:45 PM
^It is, this is my edit on it. I wanted to make it so that you can choose what slot to put it in.
squiggler
07-03-2014, 09:36 PM
Ah. What would the slots be for? Just organization?
Hwona
07-03-2014, 09:46 PM
Umm, with the current system, you can have several slots, but each specific type of item can only be put in one slot. For example, when you use an item, you don't have the choice of which slot to put it in. :3
IntoRain
07-04-2014, 05:22 AM
Don't really know what you want to do, but that return message will stop your function from doing anything after it. Rest looks functional I think xD Great mods btw :3
Hwona
07-04-2014, 10:44 AM
^Thanks! Is there an alternative to the "return"... function? :3
IntoRain
07-04-2014, 02:37 PM
What did you want to do with return? xD A function returns when it ends, consider it the final result of a math problem. And it's other functions that pick up the return from other functions and work with the values
Kyttias
07-04-2014, 02:50 PM
Having a return at the end like that basically means that calling items_trinket() will result in the value of $note, and will never run again because it is no longer a function holding formula to run/posing a question, it is a function holding an answer? I think. I'm sleepy.
IntoRain
07-04-2014, 02:53 PM
A function runs as many times as you call it. Even if you return from it, if you call it again it will return again. The problem is the
return $message;
In the middle. At that moment, the function will quit and the rest of code inside that function won't run at all. This part is like it doesn't exist:
if (!isset($_POST[‘slot’])) {
$noslot = “You have not selected a slot to place this trinket in.”
return $noslot;
}
else {
$slot = $_POST[‘slot’];
$image = $item->itemname;
$note = "The trinket has been given to this adoptable!";
$mysidia->db->update("owned_adoptables", array("lastbred" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$delitem = $item->remove();
return $note;
}
Hwona
07-04-2014, 03:50 PM
^I want the code to display some radio buttons that will allow a user to actually choose to spot to put a trinket in instead of having the trinket go to the only slot the trinket type was set to go to.(Hope that made sense) The user would then click a radio button to select the slot, and then the rest of the code would put the trinket there and show this message: The trinket has been added. :3 Would adding a "comment" instead work?
Hwona
07-04-2014, 06:52 PM
Hmmm... would this code work?:
function items_trinket($item, $adopt){
$mysidia = Registry::get("mysidia");
$slot1 = $this->adopt->getAdoptSlot1();
$slot2 = $this->adopt->getAdoptSlot2();
$slot3 = $this->adopt->getAdoptSlot3();
$slot4 = $this->adopt->getAdoptSlot4();
$slot5 = $this->adopt->getAdoptSlot5();
$message = “<input type=’radio’ name=’slot[ ]’ value=’slot1’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot1}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot2’ /><span class=’slot’><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot2}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot3’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot3}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot4’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot4}.png'></span><br>
<input type=’radio’ name=’slot[ ]’ value=’slot5’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot5}.png'></span><br>
<input type=’submit’ name=’choose’ value=’Give Trinket to Adoptable’ />”;
$document->add(new Comment($message));
if (!isset($_POST[‘slot’])) {
$noslot = “You have not selected a slot to place this trinket in.”
return $noslot;
}
else {
$slot = $_POST[‘slot’];
$image = $item->itemname;
$note = "The trinket has been given to this adoptable!";
$mysidia->db->update("owned_adoptables", array("lastbred" => 0), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$delitem = $item->remove();
return $note;
}
*crosses fingers*
Hwona
07-10-2014, 05:48 PM
Ok, I tested out this code:
function items_trinket($item, $adopt){
$mysidia = Registry::get("mysidia");
$slot1 = $this->adopt->getAdoptSlot1();
$slot2 = $this->adopt->getAdoptSlot2();
$slot3 = $this->adopt->getAdoptSlot3();
$slot4 = $this->adopt->getAdoptSlot4();
$slot5 = $this->adopt->getAdoptSlot5();
$message ="<input type=’radio’ name=’slot[]’ value=’slot1’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot1}.png'></span><br>
<input type='radio’ name=’slot[]’ value=’slot2’ /><span class=’slot’><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot2}.png'></span><br>
<input type='radio’ name=’slot[]’ value=’slot3’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot3}.png'></span><br>
<input type='radio’ name=’slot[]’ value=’slot4’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot4}.png'></span><br>
<input type='radio’ name=’slot[]’ value=’slot5’ /><span class=’slot’><img src='{$mysidia->path->getAbsolute()}picuploads/trinkets/{$slot5}.png'></span><br>
<input type='submit’ name=’choose’ value=’Give Trinket to Adoptable’ />";
$document->add(new Comment($message));
if (!isset($_POST['slot'])) {
$noslot = "You have not selected a slot to place this trinket in.";
return $noslot;
}
else {
$slot = $_POST['slot'];
$image = $item->itemname;
$note = "The trinket has been given to this adoptable!";
$mysidia->db->update("owned_adoptables", array('{$slot}' => '{$image}'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$delitem = $item->remove();
return $note;
}
and got this error on a blank page when I tried to use the item:
Parse error: syntax error, unexpected end of file in /home/wallie12/public_html/functions/functions_items.php on line 391
I'm pretty certain the code above is the issue, but I don't know what's wrong. :L
Kyttias
07-10-2014, 05:55 PM
You need a closing bracket, I think. You closed the else, but not the function itself.
Hwona
07-10-2014, 06:11 PM
Thanks! The page is no longer broken, but now this message pops up:
The item function is invalid. I already modified the privateitem.php file...
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.