![]() |
Kind of rusty. =/
Okay, so I haven't scripted in a bit, trying to get back into the groove somewhat, so I've decided to pick back up on some old scripting projects, but alas! I have run into problems, of course. ^^ So, I have a question about a issue at hand, and I also have a question in regards to something I want to do in the future.
Okay so, first thing: (Nevermind I figured this part out, but help with the second question would be appreciated.) :asleep: And secondly: I was wondering, how exactly would I go about checking through ALL the flags in a DB and see if they match to a specific sent array? Eg: DBNpc - Test_Stats: Holds flags - this.test_1 = {1, 2, 3}; and this.test_2 = {3, 4, 5}; Now, say in a weapon NPC I have a weapon creating arrays: this.check_1 = {2, 3, 4}; and this.check_2 = {3, 4, 5}; and I want to send them both to the Test_Stats NPC to check if they match up to any flags that are stored within that DB. (Of course when actually made this flag list will be much more extensive.) How exactly would I go about checking all of those flags and seeing if they match up, so that I could than return whether they match up or not? :noob: |
hmm you could do something like
(inside test_stats) HTML Code:
public function onCheckArray(arr) { |
I basically want to create an Alchemy system with a bunch of different formulas for items. Like: this.weapon_1 = "Iron, quantity", "Stock, quantity", etc" would be in the DB, along with a bunch of others. Than in a weapon NPC I would be creating the array based on what items the player is trying to put together, and when they try to create something it would run a check through the DB to see if it matches any formula in the DB.
|
ah hmm you don't wanna do a quantity/stock in a flag to cross reference =p
If I were you, I would make a script which would automatically generate a bunch of items from a list of vars, and then have the ID different to each one something similar to this: http://forums.graalonline.com/forums...ad.php?t=78506 As an example, I would name an item something like Pirates_Flare_Blade_of_Darkness Rogues_Spider_Fang_of_Nature Then base your items around there. I would automatically have each item type defined =[ You can also make your own weapons, if you want personal items. |
Quote:
|
Quote:
|
Quote:
|
hmm why the quantity in the DB? bad move =[
|
Why not? lol It's not like anyone can hack a DB and no staff will be able to give theirselves items unless I give them the access to alter the flags. :confused:
|
Quote:
|
Quote:
|
Okay so Drew, what you showed me worked, but now I've run into another issue with this. The function only returns when the array is an exact match to the flag in the DB. (Which it should) But is there a way I can make it so that it will return when the array is in any order? Eg:
this.array = {2, 3, 1}; //In Weapon this.return_array = {1, 2, 3}; //In NPC When I send this.array to the NPC, I would still like to return this.return_array, even though the numbers are off in sequence, they are still the same numbers. |
I would really recommend a new system, you could do something like
HTML Code:
public function onCheckArray(arr) { |
Quote:
1. Store each recipe id in an array. (this.recipes = {}) 2. Store recipe information in it's own variable. (this.recipe.(@id) = {"name", {"ingredient", 1, "other", 1}}) 3. Cycle through each recipe and provided ingredients until a match is found. Rough implementation: PHP Code:
|
hmm how so @ my script
|
| All times are GMT +2. The time now is 06:22 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.