Hi! Some of you saw my thread where I asked help for this but I solved it myself. Okay, so this script is set to a weapon's main script, and when player gets enough close, a text appears and says "Press ENTER to buy M9 for 20 health".
The name must be written invidually (making fpi files, every on their own).
To change the health cost, change the text's 20 and plrhealthgreater=20 and plraddhealth=-20 (at the fourth line).
To change the range where it can be bought change plrdistwithin=40 of 3, 4 and 5 lines but don't forget to change plrdistfurther=65 to health cost + 20.
This works on 1.17, I haven't tested other versions.
---
This can be changed to use any entity, not only weapon.
For doors, you can use this:
;Artificial Intelligence Script
;Header
desc = Use Door (Push Open and Push Closed)
;Triggers
:state=0:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=150,fpgcrawtextg=150,fpgcrawtextb=150,fpgcrawtextx=50,fpgcrawtexty=60,plrdistwithin=60,state=5
:state=5,plrdistwithin=60:fpgcrawtext=Press <Enter> to open this door for 150 health.
:state=5,plrdistwithin=60,plrhealthgreater=150,plrusingaction=1:activate=2,plraddhealth=-150
:state=5,activated=2:state=1,setframe=0,sound=$0
:state=1:incframe=0
:state=1,frameatend=0:state=2,coloff
:state=2,plrdistwithin=60,plrusingaction=1:activate=0
:state=2,activated=0:state=3,sound=$1,colon
:state=3:decframe=0
:state=3,frameatstart=0:state=5,setframe=0
;End of Script
Thanks,
TP