Rather than resort to scripts, you should probably look into the possibility of implementing something such as this within Customer Special Pricing.
If that can't be done, review the special price hook -
Customer Special Pricing Hook (R-CSPx.MAC)
Some simple syntax examples are also included.
It's easier to answer more specific questions than very general questions but that might get you pointed in the right direction.