Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-10-2012, 06:44 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Is this viable to load on login?

I have an item by itself being load which has the unique ID of the item and I also have a bunch of clientr.item.itemname.data.etc vars that are holding the data. Would this be viable to load on each login? Keep in mind this is just one item.
PHP Code:
clientr.item.wornsword.1=1,wornsword,none,0
clientr
.item.wornsword.data.bi1=mage
clientr
.item.wornsword.data.bi2=1
clientr
.item.wornsword.data.bi3=fireball
clientr
.item.wornsword.data.gems=red
clientr
.item.wornsword.data.itemdescription=Just a test sword
clientr
.item.wornsword.data.itemgani=walk
clientr
.item.wornsword.data.itemimage=block.png
clientr
.item.wornsword.data.itemname=Worn Sword
clientr
.item.wornsword.data.itemsubtype=onehandsword
clientr
.item.wornsword.data.itemthumbnail=block.png
clientr
.item.wornsword.data.itemtype=weapon
clientr
.item.wornsword.data.realname=wornsword
clientr
.item.wornsword.data.rowid=
Any help, suggestions would be appreciated. I want to keep it like this if at all possible. It would make everything easier for me to expand later on without having just one really long string with no apparent order. I will do it the other way if needed.
Reply With Quote
  #2  
Old 03-10-2012, 06:47 AM
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
I don't see why not, but you could always do some testing.

Generate a bunch of dummy items/data and then test out loading them on login.
__________________
Reply With Quote
  #3  
Old 03-10-2012, 06:50 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Well from what I have heard if the account file gets too big it will not read properly.
Reply With Quote
  #4  
Old 03-10-2012, 06:51 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Use an SQL Database to create items and store specific data for them. The SQL Explorer tool is probably the best option for doing so.

I don't know about stuff not loading if you have too many variables, but it's generally a bad idea to store that kind of information on player accounts.
Reply With Quote
  #5  
Old 03-10-2012, 07:00 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
The item information is stored in a SQL database and cached into a DBNPC. The unique item information in the array is pulled directly from the SQL database. All this is done on login and if a specific items information is updated it will update it on all the online players.
Reply With Quote
  #6  
Old 03-10-2012, 07:08 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Quote:
Originally Posted by Cubical View Post
The item information is stored in a SQL database and cached into a DBNPC. The unique item information in the array is pulled directly from the SQL database. All this is done on login and if a specific items information is updated it will update it on all the online players.
Problem?

Unless you want players to be able to customize items or weapons, this is a perfectly good way of storing this information. It can significantly reduce the amount of data being loaded by the server at any given time.

If you consider the fact that players could have hundreds of things stored on their account at any given time, and that those things might have up to ten or more variables associated with them, the numbers add up fast. And loading all of those things every time a player logs in doesn't make things any better.
Reply With Quote
  #7  
Old 03-10-2012, 07:10 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by Draenin View Post

I don't know about stuff not loading if you have too many variables, but it's generally a bad idea to store that kind of information on player accounts.
it's not getting stored, I'm just trying to figure out if it's fine to store that many. imagine that times like 600 for those items hording people
Reply With Quote
  #8  
Old 03-10-2012, 07:18 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Quote:
Originally Posted by Cubical
imagine that times like 600 for those items hording people
Exactly. Now imagine all that being loaded every time someone logs in.


Just create items in a database and then generate an Item ID via script that makes the item 'unique.'

That way you can change the basic variables of the item globally, while still giving players the benefit of possibly customizing their stuff.
Reply With Quote
  #9  
Old 03-10-2012, 07:24 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I'm already doing that by having a table for the base stats of everything then another table solely for stats that would be unique to one weapon, the initial question wasn't where i planned on storing my player/item data it was just if having that many flags in a players account file will cause any issues.

Quote:
Originally Posted by Cubical View Post
I have an item by itself being load which has the unique ID of the item and I also have a bunch of clientr.item.itemname.data.etc vars that are holding the data. Would this be viable to load on each login? Keep in mind this is just one item.
PHP Code:
clientr.item.wornsword.1=1,wornsword,none,0
clientr
.item.wornsword.data.bi1=mage
clientr
.item.wornsword.data.bi2=1
clientr
.item.wornsword.data.bi3=fireball
clientr
.item.wornsword.data.gems=red
clientr
.item.wornsword.data.itemdescription=Just a test sword
clientr
.item.wornsword.data.itemgani=walk
clientr
.item.wornsword.data.itemimage=block.png
clientr
.item.wornsword.data.itemname=Worn Sword
clientr
.item.wornsword.data.itemsubtype=onehandsword
clientr
.item.wornsword.data.itemthumbnail=block.png
clientr
.item.wornsword.data.itemtype=weapon
clientr
.item.wornsword.data.realname=wornsword
clientr
.item.wornsword.data.rowid=
Any help, suggestions would be appreciated. I want to keep it like this if at all possible. It would make everything easier for me to expand later on without having just one really long string with no apparent order. I will do it the other way if needed.
Reply With Quote
  #10  
Old 03-10-2012, 07:30 AM
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
If I was going to make a simple item system, this is how I would structure it:
  1. I would have one database table to store item information (call it ITEMS_INFO) with columns such as:
    UID, NAME, TYPE, DESCRIPTION, GANI, REAL_NAME, ...
    This table would have one row for every item on your server.

  2. I would have another table to store player possessions (call it PLAYER_ITEMS) with the columns:
    ACCOUNT, ITEMSINFO_UID, QUANTITY

  3. I would also maintain a cache of each player's item info in clientr.vars. I would update the entire cache on login, and also individual items as they are bought/sold/dropped/whatever.

A simple way to load all of a player's items in a single query (such as when they login) would look something like:
NPC Code:
select PLAYER_ITEMS.QUANTITY, ITEMS_INFO.* from PLAYER_ITEMS
left join ITEMS_INFO on PLAYER_ITEMS.ITEMSINFO_UID = ITEMS_INFO.UID
where PLAYER_ITEMS.ACCOUNT = 'salesman'


You could then loop through the result of this query to update the player's clientr.var cache. If a player has 600 items, you'd only have a single SQLite query and a loop that iterates 600 times when they log on.

There's also really no need to cache the SQLite databases in DBNPCs. From my personal experience, it is much faster to just stick with SQLite.

You shouldn't have an issue with too many clientr.vars (Era does something similar). Just remember to only store information that you will actually use...such as the information that will be displayed in an inventory or on the player's HUD.
__________________
Reply With Quote
  #11  
Old 03-10-2012, 07:31 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Quote:
Originally Posted by Cubical
the initial question wasn't where i planned on storing my player/item data it was just if having that many flags in a players account file will cause any issues.
The issue is that those flags will have to be loaded every time a player logs in. If you have a lot of players and a lot of flags on those players, it can greatly increase a server's average workload.

Whether or not it can cause issues for a player's account, I'm not entirely sure. I suspect the answer to that would be yes, but I can't say for certain because I've never tried to see if I can crash a player's account by overloading it with variables.
Reply With Quote
  #12  
Old 03-10-2012, 07:33 AM
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
Quote:
Originally Posted by Draenin View Post
The issue is that those flags will have to be loaded every time a player logs in. If you have a lot of players and a lot of flags on those players, it can increase a server's workload.

Whether or not it can cause issues for a player's account, I'm not entirely sure. I suspect the answer to that would be yes, but I can't say for certain.
Unless the server is getting 100 logins/ms or something ridiculous, retrieving some data from a database and setting some clientr.variables won't be that big of a deal.
__________________
Reply With Quote
  #13  
Old 03-10-2012, 07:35 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I'd imagine it'd be better to store it in a DB NPC as it would keep it in the memory.
Reply With Quote
  #14  
Old 03-10-2012, 07:40 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Quote:
Originally Posted by salesman View Post
Unless the server is getting 100 logins/ms or something ridiculous, retrieving some data from a database and setting some clientr.variables won't be that big of a deal.
Retrieving data from a database is what I'm advocating here. Storing all of that information in clientr.variables is not.
Reply With Quote
  #15  
Old 03-10-2012, 07:53 AM
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
Quote:
Originally Posted by Cubical View Post
I'd imagine it'd be better to store it in a DB NPC as it would keep it in the memory.
You could always test it out. Create a table with several thousand rows. Create a DBNPC with the same data. Measure how long it takes to retrieve information from both of them.

Quote:
Originally Posted by Draenin View Post
Retrieving data from a database is what I'm advocating here. Storing all of that information in clientr.variables is not.
If the information is going to be accessed frequently on the clientside, you don't really have any other options. Although, I'd recommend caching anything that doesn't need to be secure in client.vars as opposed to clientr.vars. For example, the item's icon file name or a description about the item for displaying in the inventory.
__________________
Reply With Quote
Reply


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 01:39 AM.


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