Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2016, 03:33 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 79,462
Dinocanid is on a distinguished road
Default Simple quests

-What we will do-
Create a simple item quest in which you get an item from an npc and give it to another npc; getting currency in return. Afterwards, this can be used to create more complex quests.

-Step 0-
Create an item to use in the quest. I recommend that it's a key item that can't be bought, traded, or consumed. This way, users can't give quest items to each other or buy them from a shop. What you name it and everything else is up to you. In order for this to work properly, you should have custom pages for your npcs. If you don't know how to make a page from scratch, go here:
http://www.mysidiaadoptables.com/for...48&postcount=2
If you don't use custom-made pages, this can only be used on pages that have a .php file and a view.php file. So no pages made in the adminCP.

-Step 1-
Where is your first npc located? In which view file? Wherever they are, go to that view file and add this under the npc's image:
PHP Code:
         $item "ItemName";
         
$hasitem $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner='{$mysidia->user->username}'")->fetchColumn();
    if(
$hasitem 0){
             
$document->add(new Comment("You're on this quest already!"));
    }
    else{
         
$document->add(new Comment("Please deliver this to Name"));
         
$document->add(new Comment("<font size='3'>You received 1 {$item}!</font>"));
         
$newitem = new StockItem($item);  
         
$newitem->append(1$mysidia->user->username);
    } 
What this does is check if the user has the quest item already. If they do, the user won't be given one. If they don't the user will be given the item to deliver. This makes sure the user only has one of the item.

-Step 2-
Go to your next npc. They should be on a different page (and view file) from the first one. Right under their image, put this code:
PHP Code:
        $item "ItemName";
        
$hasitem $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner='{$mysidia->user->username}'")->fetchColumn();
        if(
$hasitem){
        
$document->add(new Comment("<br></br>You have $hasitem {$item}! Why not hand it over?"));
        if(
$mysidia->input->post("submit")){
        
$qty 1;
        
$item = new PrivateItem($item$mysidia->user->username);
        
$amount rand(10,20);
    
$mysidia->user->changecash($amount);
        
$item->remove($qty$mysidia->user->username);
        
$document->add(new Comment('"Thanks!"'FALSE));
        
$document->add(new Comment("<br></br><font size='3'>You earned $ {$amount}!</font>"FALSE));
        return;}
        
$questForm = new FormBuilder("questform""""post");
        
$questForm->buildButton("Give item""submit""submit");
        
$document->add($questForm);
        } 
This is the part that takes the quest item from the user and gives currency in return. Where it says $amount = rand(10,20);, it gives the user a random amount of currency between 10 and 20. You can change this to whatever amount you want, or you could change it to $amount = + 10; if you wanted it to not be random (change 10 to whatever you like).

-End-
That's it! You should now have a simple system for quests. Please let me know if you get any errors, but it shouldn't cause any.
Here's what it looks like on my site:
__________________

Last edited by Dinocanid; 11-05-2016 at 03:47 PM.
Reply With Quote
  #2  
Old 11-11-2016, 10:52 AM
lotus's Avatar
lotus lotus is offline
Member
 
Join Date: Oct 2016
Posts: 7
Gender: Female
Credits: 1,043
lotus is on a distinguished road
Default

It works perfectly! Thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:19 AM.

Currently Active Users: 1291 (0 members and 1291 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636