Comments (8)
It works perfectly!
from pointshop2.
It's updated instantly whenever something is changed inside the shop. What do you want to store in the purchasedata? In MySQL the purchasedata is just a JSON blob so you can put whatever you want in there. E.g.
KInventory.Item.findById( itemId ):Then( function( item )
item.purchaseData.myExtraData = "test"
return item:save()
end )
from pointshop2.
I wanted to add a LVL/EXP value to it. Also wanted to find someway to identify that item in specific in an inventory
from pointshop2.
@kamshak is there a way to update only that data client side?? Also, if i have the item equipped and then i move it back into inventory it removes the change i made to the item.
from pointshop2.
Here's the code im using
`
local Gitem = ply:PS2_GetItemInSlot("Hat")
KInventory.Item.findById(Gitem.id):Then(function(item)
item.purchaseData.effect = WEffect
return item:save()
end)
`
from pointshop2.
Doing this will keep it from changing if the player moves the item around.
KInventory.ITEMS[Gitem.id] = item
Still need to find a way to update it :/
from pointshop2.
If you're updating the item that is in an Inventory or slot it's important that you modify the item instance that PS2 uses, there is a global lookup table KInventory.ITEMS
that you can use. If you need that data clientside after you'd need to manually network the change, you can use ITEM:ClientRPC for that, e.g.:
sh_purchase_data_update_mixin.lua
-- Extend base_item for purchase data updates
local PurchaseDataUpdateMixin = {}
function PurchaseDataUpdateMixin:included( klass )
klass.static.AllowRPC("PurchaseDataUpdated")
end
if CLIENT then
function PurchaseDataUpdateMixin:PurchaseDataUpdated(newData)
self.purchaseData = newData
end
end
if SERVER then
function PurchaseDataUpdateMixin:UpdatePurchaseData(newData)
self.purchaseData = newData
return self:save( ):Then(function( )
self:ClientRPC("PurchaseDataUpdated", newData)
end)
end
end
KInventory.RegisterItemClassMixin("base_pointshop_item", PurchaseDataUpdateMixin)
E.g.
local itemId = 12345
-- Get the item like this if you have the id but don't know if it's equipped or in inventory
local item = KInventory.ITEMS[12345]
-- if this is null you can use the db (KInventory.Item.findById)
-- you can also get the item from a slot or elsewhere, e.g.
-- local item = ply:PS2_GetItemInSlot("Hat")
local newPurchaseData = table.Copy(item.purchaseData)
newPurchaseData.effect = "test effect"
item:UpdatePurchaseData(newPurchaseData)
from pointshop2.
Awesome!!! Thank you for all the help!! @kamshak
from pointshop2.
Related Issues (20)
- I'm having trouble opening the PS2 and spawning pac3 models in the sky
- No bodygroup section in model creation HOT 2
- error HOT 3
- Connection to MySQL Server not working
- Import error HOT 2
- Currency HOT 1
- Problems with DLC HOT 1
- Problem with PH:X integration HOT 2
- The problem with hats and accessories
- Lua error when opening inventory
- SQLite to Mysql HOT 1
- PAC3 + Pointshop2 Conflict? HOT 2
- Particle effects issue after pac3 update HOT 12
- Inventory start HOT 4
- libk still working? HOT 1
- Couldn't include file 'ps2\modules\dlc\boosters\sv_content.lua' HOT 1
- Can't equip items HOT 2
- I can't open any edit item HOT 2
- Needs to be rewritten for PS2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pointshop2.