payment currency||doc135595

September 20, 2022


 Player:payCurrency(coinName, count, clear, check, reason) 
  • The class to which the function belongs:Player


Pay in-game currency.


Variable name type Description
coinName string currency name
count int quantity
clear boolean Whether to empty when insufficient
check boolean whether to check only
reason string Reason for payment

Value Returned

type Description
boolean Payment result

Code Samples

On the server side of the entity templatemount script, add the register when the entity of this class diesCallback, paying currency to change max health

Trigger.addHandler(this:cfg(), "ENTITY_DIE", function(context)
    local player = context.obj1
    local isSuce = player:payCurrency("green_currency", 1, true, true, 'AddMaxHP') 
    if isSuce then
      player:setProp('maxHp', 60)