builder's lessons » buy prog

Buy programs

Buy progs work similar to give progs in their format. They only work for the PC buying an object from a mob, not selling them to a mob. They cannot be used to stop a PC from buying the object. If you wish to restrict a PC from buying from that mob then you will have to use an intercept program (a sample of which I will include below). An intercept on buy means that it works for EVERYTHING that the mobile sells but a buy program is for an individual object that the mobile sells.

>buy_prog i7931~
sayto $n This fey longsword was magically enhanced 
sayto $n by a Priestess of Corellon.
sayto $n With the fey shortsword they make well 
sayto $n balanced weapons for dual wielding.

The above prog activates when item vnum 7931 is bought from the mobile. In this case its a fey longsword. As you can see the buy prog is useful for telling PC's information about the object they just bought. Buy progs activate 100 percent of the time. If you want to reduce the chance of the mobile saying something then use an if rand in the prog.

>intercept_prog buy~
if guild($n) != Rangers
  sayto $n I am sorry, but I only cater to rangers.

This program here restricts all who are not rangers from buying from this mobile. It activates when the PC types buy. It cannot be used to restrict them from buying one item but rather from shopping with that mobile over all.