Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-26-2012, 05:19 PM
jamitsu89 jamitsu89 is offline
Registered User
Join Date: Jun 2011
Posts: 27
jamitsu89 is an unknown quantity at this point
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
Reply With Quote
  #2  
Old 02-26-2012, 05:29 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
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?
__________________
Reply With Quote
  #3  
Old 02-26-2012, 05:36 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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
__________________
Quote:
Reply With Quote
  #4  
Old 02-26-2012, 05:45 PM
jamitsu89 jamitsu89 is offline
Registered User
Join Date: Jun 2011
Posts: 27
jamitsu89 is an unknown quantity at this point
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
Reply With Quote
  #5  
Old 02-26-2012, 06:01 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #6  
Old 02-26-2012, 06:13 PM
jamitsu89 jamitsu89 is offline
Registered User
Join Date: Jun 2011
Posts: 27
jamitsu89 is an unknown quantity at this point
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 +2. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.