PDA

View Full Version : Couple Questions


Bandor
03-24-2015, 01:50 PM
Just got a couple quick questions having trouble finding info.

1) How can I make a npc give multiple items,a package deal if you will? I know I could just do summonitem multiple times but I was hoping to give them a bag of items,Could I create a spell and then have the npc selfcast the spell summoning a bag of items? What would be best way of doing this for say 2-3 bags of items.

2) How can I make it so players recieve an item in their alt currency or inventory every x amount of hours? I know it would go in my global_player but not sure asto what the code would look like.

3) And Lastly Editing books? Like recipe books. How in the world can I go about editing them can't seem to find any info on it at all.

Kingly_Krab
03-24-2015, 02:21 PM
1. Take a look at the Phantom Plate spell (summons a bag with items in it) and just have the client cast a custom version of that spell.

2. Use EVENT_CONNECT and EVENT_TIMER with an hourly timer: sub EVENT_CONNECT {
quest::settimer("Reward", 3600);
}

sub EVENT_TIMER {
if ($timer eq "Reward") {
quest::stoptimer("Reward");
$client->AddAlternateCurrencyValue(CURRENCY ID, AMOUNT);
$client->Message(315, "You have received AMOUNT CURRENCY for staying online for an hour!");
quest::settimer("Reward", 3600);
}
}3. Books table in the database, then set the book information in the items table.

Uleat
03-24-2015, 08:36 PM
I would **HIGHLY** recommend against giving items in bags at this time.

When a 'loaded' bag is placed on the visible cursor, a proper database save is performed and the bag and its contents remain intact.

If something occurs and the 'loaded' bag is pushed into a 'limbo' slot, there is no guarantee that the contents of the bag will be recoverable.

Bandor
03-24-2015, 10:20 PM
Hmm. Might have to come up with a way of doing this differently. Really wanna be able to have a starting package type thing, just not sure how to go about it.

Kingly_Krab
03-24-2015, 10:42 PM
You could do it in starting_items if you want them to start with it.

Bandor
03-24-2015, 10:57 PM
Was hoping to do it via quest. That would be a easy enough work around though, I take it /claim doesn't work?

Kingly_Krab
03-24-2015, 11:21 PM
Claim does work.

Uleat
03-24-2015, 11:21 PM
If you ensure that nothing is on the cursor before 'summoning' a filled bag, you can probably get away with it.

It would limit the event to one bag with contents, which must go onto the cursor first, and then any 'loose' items afterwards.

You could always put in safety code to check that your bag ID is on the visible cursor, and empty, and then pile in the items
that you want in it.

If it's not visible, or empty, you could then just push the items to the cursor normally.


This is very doable..but, poses a risk of item loss if you're not 100% in-tune with what's going on behind the scenes.


EDIT: I reference the cursor explicitly because if room is not found in the 'regular' inventory, the returned available slot is always
SlotCursor.

Bandor
03-26-2015, 09:39 AM
Would it just be safer to give multiple 'loose' items? And if so what would be considered the safe number? Figure im going to just let players purchase the items from the npc and have the npc just give 1 or 2 items. But am curious for future reference.

would the code for multiple rewards be structured like this:
quest::summonitem();
quest::summonitem();

Kingly_Krab
03-26-2015, 02:17 PM
Well you could have multiple calls or do a one-line for loop like this (if your items were 1001, 1003, 1005, etc): sub EVENT_SAY {
if ($text=~/Hail/) {
quest::summonitem($_) for (1001, 1003, 1005);
}
}

Bandor
03-26-2015, 04:33 PM
Ok cool thank you guys

Kingly_Krab
03-26-2015, 04:47 PM
You're welcome.

Uleat
03-26-2015, 09:07 PM
Technically, the Server 'should' allow 1000 items on the cursor.

Testing showed that it will only access up to around 102 items from the database.


Even with the lower limit, you should stick to no more than 37 items (1 visible, 36 in limbo) or you will cause serious desync issues.
And that doesn't mean adding 37 items to a cursor that already has items on it :P

All clients currently supported enforce this 1+36 limit (even RoF+ with it's differing format.)

Bandor
03-27-2015, 09:38 AM
Awesome Uleat. I doubt I'll ever add more then 3-5 but that is very good to know,just what I was searching for. Tyvm