This site contains mature content. Do not use this site if you are under 18.
This page last updated: January 2023
Author: Hooded Silence
Doc version: v0.1
Code Base: v0.2
Index
Intro
Variables
Examples
Code base
Intro
The payment system is designed to integrate both cash and payment into a streamlined function to reduce the code base and to standardise how payments are made within the codebase. The function is located in shortgs.qsrc.
Variables
External (input)
The payment system uses the array epayments to carry the variables. There is two required variables:
epayments['value'] = (Int)cost of goods. Required
$epayments['description'] = (Str) Item Description - What's been bought. Required
The following variables are available which can be applied for various scenarios:
$epayments['method'] = (Str) how payment is to be completed in either cash or card. leave blank for both.
$epayments['item_variable'] = (Str) item variable to be purchased to be added to players inventory.
epayments['quantity'] = (Int) How many items to be added, defaults to one item.
$epayments['loc'] = (Str) Where do you want the character to go after payments are complete, falls back to $loc if not set.
$epayments['loc_arg'] = (Str) Location arg variable, defaults to $loc_arg
$epayments['banner'] = (Str) Show a custom banner image for the content area if required.
Any optional variable can be safely ignored if not required.
Internal
$construct_cash = Transitory variable to facilitate displaying the output for cash payments.
$construct_card = Transitory variable to facilitate displaying the output for card payments.
Code examples
See fit.qsrc – start for examples of subscription payment and custom banner.
See salon.qsrc – hair_removal for examples of a custom return after purchasing services.
Code Base
!! Author - Hooded Silence
!! Date created - 26 Aug 22
!! Payment system - Used to pay for items in various game locations
!! v. 02 - Refactoring to make usage simpler using the epayments array
!! command syntax: gs 'shortgs','payments'
!! All variabls are initiated at point of origin
!!
!! epayments[value] = cost of goods. Required
!! $epayments[method] = how it''s to be paid cash or card. leave blank for both. Optional
!! $epayments[description] = Item Description - What's been bought. Required
!! $epayments[item_variable] = item variable to be purchased to be added to players inventory. Optional.
!! epayments[quantity] = How many items to be added. Defaults to one - Optional.
!! $epayments[loc] = Where do you want the character to go to, optional falls back to starting location if set. Optional
!! $epayments[act] = If there's a specific act to return to. Optional
!! $epayments[banner] = banner image for the sale. Optional
!! Optional with no content are ignored.
!! Use stock image for the purchase screen?
if $ARGS[0] = 'payments':
*clr & cla
if epayments['value'] = 0:
msg '<b>Error, Cash Value not set.</b>'
end
if $epayments['description'] = '':
msg '<b>Error, Item Description not set.</b>'
end
!! Construct payment call
if $epayments['item_variable'] ! '':
$construct_cash = '<a href="exec: money -= <<epayments[''value'']>> & <<$epayments[''item_variable'']>> += <<epayments[''quantity'']>> & gs ''shortgs'', ''paymentcomplete'' ">Cash</a>'
$construct_card = '<a href="exec: karta -= <<epayments[''value'']>> & <<$epayments[''item_variable'']>> += <<epayments[''quantity'']>> & gs ''shortgs'', ''paymentcomplete'' ">Card</a>'
else
$construct_cash = '<a href="exec: $epayments[''method''] = ''cash'' & money -= <<epayments[''value'']>> & gs ''shortgs'', ''paymentcomplete'' ">Cash</a>'
$construct_card = '<a href="exec: $epayments[''method''] = ''card'' & karta -= <<epayments[''value'']>> & gs ''shortgs'', ''paymentcomplete'' ">Card</a>'
end
!Use stock image for the purchase screen?
if $epayments['banner'] ! '':
'<center><img <<$set_imgh>> src="images/' + $epayments['banner'] + '"></center>'
end
if ($epayments['method'] ! 'cash' and $epayments['method'] ! 'card') and (epayments['value'] <= money and epayments['value'] <= karta + bankDebtLimit):
'How do you want to pay for the <<$epayments[''description'']>>? <<$construct_cash>> or <<$construct_card>>'
elseif ($epayments['method'] = 'cash' or $epayments['method'] = '') and epayments['value'] <= money:
'Pay for the <<$epayments[''description'']>> with <<$construct_cash>>?'
elseif ($epayments['method'] = 'card' or $epayments['method'] = '') and epayments['value'] <= karta + bankDebtLimit:
'Pay for the <<$epayments[''description'']>> with your <<$construct_card>>?'
else
'You don''t have enough money in your purse or bank account for this item.'
end
act 'Cancel Payment': gt $loc, $loc_arg
end
!! Payment complete
if $ARGS[0] = 'paymentcomplete':
*clr & cla
'Thank you for your custom. Please come again!'
*nl
'You paid ' + epayments['value'] + '<b>₽</b>' + iif ($epayments['method'] = 'cash',' in cash', ' with your bank card') + ' for your ' + $epayments['description']
gs 'stat'
!! clean up all the variables
killvar 'construct_cash'
killvar 'construct_card'
if $epayments['loc'] ! '':
act 'Finish payment': gt $epayments['loc'], $epayments['loc_arg']
else
act 'Finish Payment': gt $loc, $loc_arg
end
end