DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • November 20, 2017, 02:48:04 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: 1 ... 20 21 [22]   Go Down
  Print  
Author Topic: Item system  (Read 75196 times)
0 Members and 1 Guest are viewing this topic.
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 169


View Profile
« Reply #315 on: June 23, 2017, 11:32:54 PM »

Question, if anyone knows...how does one, as an Admin...give items to players?  I can Edit them, Delete then and Take them (for myself) but I can't GIVE them.  Is there a way I am not aware of without messing around in MySQL??

The reason I ask is because there is an Item in my Item System called "Fix Items" which wukd be useful to give to a player to fix things...just have it execute the right thing, and bingo.  But no idea how to get it into the players hands...short of putting it up for sae in my alt-currency shop (unique module) at a zero proce, and coordinating with that player to make them get it and then remove it from the store right away.

By the way...with regards the starge error I was getting, I figured tht out, too.  I have a module called creaturedrop.php...not sure if that is part of the otiginalItem System or it is an add-on, and I do not know if it is unique to my site...I am suspecting it could bem because of the author of tht moduke...this person and I collaborated heavily years ago on several unique things.

Anyway...the problem was...once I set my creatures in the Forest to actually drop items, which I had not done before, I would every so often get this error.  Turned out that it was a call to undefined function...the function add_item_by_id was not defined, because thhe author of the module forgot to put a require-once for the itemhandler.php module!
Logged
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 191


View Profile WWW
« Reply #316 on: June 28, 2017, 09:41:28 AM »

I try to respond to a few things you mentioned.

The "creaturedrop" is not part of the itemsystem as far as I know.
The drops are managed by findloot.php in where you set the categories of items who can drop.

As for the "give item to a player" - nothing out of the box.

The PHP for giving an item is really short:

Code:
require_once("modules/inventory/lib/itemhandler.php");
$id = THE_ITEM_ID_YOU_WANT_TO_GIVE.
$user = THE_USER_ID;
$quantity = THE_QUANTITY;
add_item($id,$quantity,$user);
output("`\$Item no. %s added once, the user now has %s pieces.", $id, check_qty($id,$user));

You need to replace the capital lettered texts with integer numbers to fit the bill.
If you do direct SQL, you may add unique items twice, or over the max quantity you defined in the item manager.
Logged
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 169


View Profile
« Reply #317 on: June 29, 2017, 06:06:02 AM »

I try to respond to a few things you mentioned.

The "creaturedrop" is not part of the itemsystem as far as I know.
The drops are managed by findloot.php in where you set the categories of items who can drop.

As for the "give item to a player" - nothing out of the box.

The PHP for giving an item is really short:

Code:
require_once("modules/inventory/lib/itemhandler.php");
$id = THE_ITEM_ID_YOU_WANT_TO_GIVE.
$user = THE_USER_ID;
$quantity = THE_QUANTITY;
add_item($id,$quantity,$user);
output("`\$Item no. %s added once, the user now has %s pieces.", $id, check_qty($id,$user));

You need to replace the capital lettered texts with integer numbers to fit the bill.
If you do direct SQL, you may add unique items twice, or over the max quantity you defined in the item manager.

Thanks.  So I would have to create an item called Give Items...which I would give only to myself...and change the exec value on it to match the player I wanted to give and the item I wanted to give.  Then I could give the item.

Understand.

As to creaturedrop:  That is an add-on to this which was coded by myself and another person I am no longer in contact with.  But I found the error...we had not done require_once lib/itemhandler.php
So whenever the add_item_by_id function was called, it did not know what to do with it...undefined function, and it would throw the error.

I fixed it.

Like I said, ths was NOT a part of the originalItem System...it was something we added on...because I had a specific item I wanted dropped ONLY by a specific monster...it was in keeping with a certaiin theme.

In this case, I have a Misteltoe Arrow.  It is for use against the Green Dragon only.  BUT...I wanted it dropped ONLY by Loki.  (This is in keeping with Norse Mythology...which my site utilizes...if you are familiar, Loki killed Baldur with a Mistletoe Arrow)

I did not find myself able, in the item system as it came...to control it so that ONLY that creature could drop that item.

I since expanded it so that a luck potion called Felix Felicitas (from Happy Potter) is dropped ONLY by a monster called Lucky Bastard.

I kinda have a few different themes running thru my site, actually, but there is a strong Norse presence...and a strong Japanese presence.  I know, it's a weird mix but it works.  Because I am weird, LOL.
« Last Edit: July 06, 2017, 01:58:05 AM by TGTarheel » Logged
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 169


View Profile
« Reply #318 on: July 02, 2017, 07:07:11 AM »

Is there any way to get Basic Item Shop to allow buying and selling of more categories of Items?

I have tried and run up on a brick wall.  It just will not allow other categories of items to be bought and sold...even if you have set the item to be buyable and sellable.

So far, mine will allow buy/sell of items in categories Feed, Loot and Vouchers.  But none others.

I changed a few items categories in order to MAKE the shop buy and sell them but this is NOT how I want to go about it.
Logged
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1740


View Profile
« Reply #319 on: July 06, 2017, 05:35:44 PM »

The basic item shop by default only buys/sells items from the Loot category.

Try these changes at your own peril!
Code:
<?php
//
//-----[ FIND (line 133) ]-----
//
shopnav("runmodule.php?module=basicitemshop&op=sell""Loot"true$session['user']['acctid'], true);

//
//-----[ REPLACE WITH ]-----
//
// Note that the shopnav() function checks for an array so this should work.
//
shopnav("runmodule.php?module=basicitemshop&op=sell", array("Loot","cat2_name","cat3_name","etc"), true$session['user']['acctid'], true);



//
//-----[ FIND (line 144) ]-----
//
$inventory get_inventory($session['user']['acctid'], 0"Loot");
while (
$item db_fetch_assoc($inventory)) {
if ($item['sellable'] == false) continue;
$quantity += $item['quantity'];
$goldvalue += $item['sellvaluegold'] * $item['quantity'];
$gemvalue += $item['sellvaluegems'] * $item['quantity'];
}

//
//-----[ REPLACE WITH ]-----
//
// Note that the get_inventory() function wont accept an array. :(
//
$categories = array('Loot','Cat2_name','Cat3_name','etc');
foreach( 
$categories as $catname )
{
$inventory get_inventory($session['user']['acctid'], 0$catname);
while( $item db_fetch_assoc($inventory) )
{
if( $item['sellable'] == false ) continue;
$quantity += $item['quantity'];
$goldvalue += $item['sellvaluegold'] * $item['quantity'];
$gemvalue += $item['sellvaluegems'] * $item['quantity'];
}
}

//
//-----[ FIND (line 233) ]-----
//
$sql "SELECT itemid FROM ".db_prefix('item')." WHERE class = 'Loot' AND sellable = 1";

//
//-----[ REPLACE WITH ]-----
//
$categories = array('Loot','Cat2_name','Cat3_name','etc');
$classes "IN (".join(","$categories).")";
$sql "SELECT itemid FROM ".db_prefix('item')." WHERE class $classes AND sellable = 1";


If that works, you could think about creating a setting to put the categories in, that way they wouldn't be hard coded to the file. Smiley
Logged

TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 169


View Profile
« Reply #320 on: July 06, 2017, 06:23:36 PM »

The basic item shop by default only buys/sells items from the Loot category.

Try these changes at your own peril!
Code:
<?php
//
//-----[ FIND (line 133) ]-----
//
shopnav("runmodule.php?module=basicitemshop&op=sell""Loot"true$session['user']['acctid'], true);

//
//-----[ REPLACE WITH ]-----
//
// Note that the shopnav() function checks for an array so this should work.
//
shopnav("runmodule.php?module=basicitemshop&op=sell", array("Loot","cat2_name","cat3_name","etc"), true$session['user']['acctid'], true);



//
//-----[ FIND (line 144) ]-----
//
$inventory get_inventory($session['user']['acctid'], 0"Loot");
while (
$item db_fetch_assoc($inventory)) {
if ($item['sellable'] == false) continue;
$quantity += $item['quantity'];
$goldvalue += $item['sellvaluegold'] * $item['quantity'];
$gemvalue += $item['sellvaluegems'] * $item['quantity'];
}

//
//-----[ REPLACE WITH ]-----
//
// Note that the get_inventory() function wont accept an array. :(
//
$categories = array('Loot','Cat2_name','Cat3_name','etc');
foreach( 
$categories as $catname )
{
$inventory get_inventory($session['user']['acctid'], 0$catname);
while( $item db_fetch_assoc($inventory) )
{
if( $item['sellable'] == false ) continue;
$quantity += $item['quantity'];
$goldvalue += $item['sellvaluegold'] * $item['quantity'];
$gemvalue += $item['sellvaluegems'] * $item['quantity'];
}
}

//
//-----[ FIND (line 233) ]-----
//
$sql "SELECT itemid FROM ".db_prefix('item')." WHERE class = 'Loot' AND sellable = 1";

//
//-----[ REPLACE WITH ]-----
//
$categories = array('Loot','Cat2_name','Cat3_name','etc');
$classes "IN (".join(","$categories).")";
$sql "SELECT itemid FROM ".db_prefix('item')." WHERE class $classes AND sellable = 1";


If that works, you could think about creating a setting to put the categories in, that way they wouldn't be hard coded to the file. Smiley

Well, if I am gonna do that, I might as well start from a place where I am defining settings as categories and plug those in, no??

I assume if there are more categories in the code than a specific admin out in settings it would just return a "" value and no biggie, right?

If I undertake this and it works, I'll release it here, with credit.
Logged
Pages: 1 ... 20 21 [22]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
16 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search