Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   SQL DB - Communicating Items from Server to Client (https://forums.graalonline.com/forums/showthread.php?t=134265850)

jamitsu89 02-26-2012 06:19 PM

SQL DB - Communicating Items from Server to Client
 
Hey,

Say there's 100 items in default.items within the SQL DB and I'm looking to access the fields for a few of those items, I'm going to need the info Clientside.

Now, I need these ASAP, and so can't put in a request to the server to find the info and then send it back to the Client, so the way I'm considering is to have a weapon that loads all the info when a function (for when it is updated also) is called and brings it to the Clientside so that it can be requested via the other weapons.

I suppose my first question is, how would you retrieve the fields from the SQL DB, and if it's similar, how would you take all that information from the server to the client for later use?

Cheers in advance

salesman 02-26-2012 06:29 PM

The data is going to be accessed frequently by the client?

If so, just retrieve the data from the DB on login and/or whenever it changes, and cache it in clientr.vars


edit: what exactly are you trying to do? I'm assuming this is for displaying items in an inventory or something?

fowlplay4 02-26-2012 06:36 PM

I'm guessing you'll keep track of what items they have via clientr.flags or maybe even in an SQL db, you'd run a query based on that information on retrieve those rows.

Then just store the row data in clientr.flags. I.e. clientr.itemdata.(@uniqueitemid) = rowdata;

There's 4 tutorials listed here that may help for the communicating back and forth if you need to:
http://public.zodiacdev.com/index.ph...er_Interaction

jamitsu89 02-26-2012 06:45 PM

It's for a loot system.

My thoughts went down the road of, well I could cache all the information within the NPC that is being looted and then display in the loot menu when clicked, but I then thought, why would I need to do that for everything when it's far easier just to have all of it stored somewhere on the Client so every script can always access it without doing it first within the script itself.

Cheers for the input though. I'll most likely retrieve the data on login and have it stored within a weapon, this.[itemname] = [restOfFields] .

Thanks for the quick responses

fowlplay4 02-26-2012 07:01 PM

For your loot system I'm guessing you're going to use a triggerclient to let the client know to open the loot window. In this case it would be preferably just to send all the data when they need it. I.e.

player.triggerclient("-LootSystem", "loot", this.loot_id, {{"itemid", "item name", "icon.png", itemamount}});

As long as your Item DB is indexed properly you won't have much of an issue retrieving the data in a timely manner.

jamitsu89 02-26-2012 07:13 PM

Well, it's actually for a minigame that then provides loot at the end. As such, when you finish the game a flag is set that lets the NPC know you've finished (you will only ever be on one at a time, and Ownership of the NPC is set on the serverside so no one else can use it at the same time). Another flag is set that lets the NPC know what loot it should be providing (set on the player after the minigame ends). It then sets the loot within itself on the clientside and when it has been looted communicates with the server to reset itself for another player.

The above information isn't too important, but what is is that it doesn't use any client > server interaction except at the end for the reset. So I can't simply send the loot information along with something else.

I suppose I can settle for having all possible loot in each NPC stated, and then requesting the fields from the SQL DB accordingly while the player is playing the minigame, but that seems like a work around for something that could work much better.


All times are GMT +2. The time now is 10:35 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.