It is suggested that if you are familiar with World at War scripting and/or Black Ops scripting, that you check out the BO3 | What's changed from WaW scripting?
This tutorial will show the steps to setting up a Custom Script to include a "Purchase Loop" which can be implemented to allow traps, wallbuys, and other custom scripts to have a way of purchasing the feature.
The _zm_score.gsc contains the function minus_to_player_score, which will allow the user to remove points from a given player as well as display the change of points on the HUD.
Since this script is not a part of your specific script, your must include the using line for this file so the script as access to minus_to_player_score.
To check if the player is press the use key on a trigger, you will have to create a trigger_use in radiant and give it a kvp of targetname with your own name for the value (this tutorial named the trigger "test_trigger").
The script will get the trigger using the GetEnt function as well as use the waittill function to wait until the trigger has been activated. Notice how there is a variable in the waittill function named player;
the player variable here is being defined as the entity that activated the trigger. This is important, since it can be used to minus the score from the player later.
Checking if the player has enough points to actually purchase the feature requires an If Statement. This will allow the script to compare the integer value of the player's score to the cost of the feature.
This cost has to be set before hand as its own variable. As for the player's score, it is defined as a variable on the player - player.score
The script will require 2 While Loops to achieve the logic for the Purchase Loop. The first While Loop is to allow the script to perform your code multiple times such as a Trap or purchasing an Item more than once.
The second While Loop is inset into the first one to allow it to be used multiple times. This second While Loop will loop until the player has enough points to activate the trigger.
Note: while loops require a form of "waiting" so that it doesn't loop multiple times on the same frame. This can be in the form of a waittill or wait function.
The final step is to allow the inset While Loop to break (meaning it will allow the code to continue outside of the loop) so if the player does have enough points it will perform the rest of the code.
Using the player variable you can now call the function from _zm_score.gsc to minus the points from the player. Also adding the break keyword to the if statement will allow for the code to break out of the most immediate loop and continue the code below.
An extra step would be to include sounds for the purchase loop. When the player purchases the feature using a sounds like a "cha-ching" will solidify the purchase, as well as doing a deny sound for when they don't have enough points.
These sounds are played on the trigger, but can also be played on the player. Note the names "name_of_purchase_sound" and "name_of_deny_sound" are just made up alias names. If you want to include your own sounds or know some in game aliases then you can include those.