Lua/Events/Shared/SharedObjectValueChange
From JC2-MP Documentation
< Lua
Name | SharedObjectValueChange |
---|---|
Arguments (in table) | object object, string key, object value |
Return option | None |
Description
Fired when a shared value changes. Shared values are persistent across modules, but not between server/client.
Fired when EntityStorageBase:SetValue is called from any module. It is not fired by calling EntityStorageBase:SetNetworkValue.
Example
Client
Use '/set key value' and '/get key' to play around with it.
function Foo(args) if args.object.__type ~= "Player" then return end Chat:Print( tostring(args.object).."'s "..args.key.." was set to "..tostring(args.value), Color.Yellow ) end Events:Subscribe("SharedObjectValueChange", Foo) function LocalPlayerChat(args) local words = args.text:split(" ") if words[1] == "/set" and #words == 3 then LocalPlayer:SetValue(words[2], words[3]) elseif words[1] == "/get" and #words == 2 then local value = LocalPlayer:GetValue(words[2]) Chat:Print( words[2].." is currently set to "..tostring(value), Color.Yellow ) end end Events:Subscribe("LocalPlayerChat", LocalPlayerChat)
Additional notes
- If you set a key to the value it's already set to, the event will still fire.