The Coin table works with the account's WCoinC (Credits) and GoblinPoint balances. WCoinP does not exist in this version: it is always 0 and is ignored when adding / subtracting. The add and subtract functions save to the database immediately and send the new balance to the client's Cash Shop.
onPlayerLogout, and the script must not be in restricted mode. The read function only requires the character to be logged in.Coin.Get
Reads the account's coin balance.
Coin.Get(aIndex) -> table
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
Returns: a table with 3 numeric fields: WCoinC, WCoinP (always 0), GoblinPoint. If the character is not valid, WCoinC and GoblinPoint are 0. Short names: CashShopGetPoint (returns a table); ObjectGetCoin(aIndex) returns 3 numbers WCoinC, WCoinP, GoblinPoint.
local c = Coin.Get(aIndex)
Message.Send(aIndex, 1, "WCoin: " .. c.WCoinC .. ", Goblin: " .. c.GoblinPoint)
Coin.Add
Adds coins to the account.
Coin.Add(aIndex, wcoinC, wcoinP, goblinPoint) -> boolean
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
wcoinC | integer | Amount of WCoinC to add (negative or omitted = 0) |
wcoinP | integer | Unused (a value must still be passed, e.g. 0, so that goblinPoint stays in the 4th position) |
goblinPoint | integer | Amount of GoblinPoint to add (negative or omitted = 0) |
Returns: true if performed (even when the amounts are 0); false if the character is not eligible. Each balance cannot exceed 2147483647 (the added amount is truncated to fit). Short names: CashShopAddPoint, ObjectAddCoin.
Coin.Add(aIndex, 100, 0, 5) -- +100 WCoinC, +5 GoblinPoint
Coin.Sub
Subtracts coins from the account. If the balance is insufficient, nothing is subtracted.
Coin.Sub(aIndex, wcoinC, wcoinP, goblinPoint) -> boolean
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
wcoinC | integer | Amount of WCoinC to subtract (negative or omitted = 0) |
wcoinP | integer | Unused (pass 0) |
goblinPoint | integer | Amount of GoblinPoint to subtract (negative or omitted = 0) |
Returns: true if subtracted; false if either balance is insufficient, or the character is not eligible. Short names: CashShopSubPoint, ObjectSubCoin.
if Coin.Sub(aIndex, 50, 0, 0) then
Item.Give(aIndex, { Index = 7181, Count = 1 })
else
Message.Send(aIndex, 1, "Not enough WCoin")
end