OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: netta1234 on 15 Jul 2004, 18:09:02

Title: Another Question
Post by: netta1234 on 15 Jul 2004, 18:09:02
Yo all  ;)

i need a Train script

ok

you go to Car lincens shop and u buy the lincens

now are all the actions at the Car shop activated

Buy Red Skoda and more...

how do i script this?  :-\
Title: Re:Another Question
Post by: DBR_ONIX on 02 Aug 2004, 15:22:00
Err, heres the simplest way I can think..
Make the liscensing person, with an addaction..

------=------
liscaction = this addaction ["Buy liscence","buylis.sqs"]
------=------

Then, make a script :

buylis.sqs
------=------
lisperson removeaction liscaction
HINT "Thanks for getting a liscene,\nDrive carefully!"

buyaction = redskoda Addaction ["Buy this car",{[redskoda,100] exec "buycar.sqs"}]
buyaction = redskoda Addaction ["Buy this car",{[blueskoda,300] exec "buycar.sqs"}]
;...etc....
EXIT
------=------

So, that will make the redskoda cost 100 thingys, and the blueskoda cost 300 thingys
You keep copy/pasting them, editing the the car name ([carname,cost] exec "buycar.sqs")

Heres the buycar.sqs script :
------=------
_car = this select 0
_carcost = this select 1
?(carcost > totalmoney):EXIT
_car locked false
totalmoney=totalmoney- _carmoney
HINT FORMAT ["Thank you for buying this fine car! It cost %1 \n You have %2 left!",_carcost,totalmoney]
_car removeaction buyaction
EXIT
------=------
And when you buy the car, it checks you have enough money, if not, it quits.. It then unlocks the car, takes the money away for the car (I guess you have a money system? If not, put a line in your INIT.sqs - totalmoney=100)
It then says thank you, tells you how much the car costs, and how much you have left, takes the Buy Car action away, then exits.

If you don't understand this.. I can make up a demo mission with it for you
- Ben
[Edit - messed up the code tags]
[Edit 18 :P - WTF it wrong! The tags keep getting messed up! >:|]
[Edit 19.. - Remove all the code tags, replaced 'em with
------=------
]