OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Yasirotta on 31 May 2009, 21:46:31
-
im using DoMove command in script, like this:
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos
~2
tax1 domove _pos2
#check
~1
?( playeeri distance taxi1 < 2):goto "check"
?(taxi1 distance apple > 10):goto "check"
exit
#cantafford
hint "You cannot afford this"
exit
Well, tax1 start to moving _pos but after 2 sec it takes new direction to _pos2 :confused:
How i can make it so, that first move must be done, before tax1 takes new direction to _pos2 ?
-
First, check your spelling. Are tax1 and taxi1 different or should they be the same?
Use unitReady (http://www.ofpec.com/COMREF/index.php?action=details&id=377) to check if a unit has arrived at its destination.
This would mean some slight rearranging of the script to put the second destination in the "check" loop (assuming tax1 should be taxi1):playeeri moveincargo taxi1
taxi1 domove _pos
#check
~1
? (unitReady taxi1): taxi1 domove _pos2
? (playeeri distance taxi1 < 2): goto "check"
? (taxi1 distance _pos > 10): goto "check" <--- using _pos instead of apple
@ (unitReady taxi1) <--- ensures the taxi moves onto _pos2 even if the loop is broken
taxi1 domove _pos2
exit
-
Yes, it was typo :whistle: tax1 should be taxi1
The script works now, but i still get error. Taxi1 moves to first _pos, and goes then to _pos2.
Still, when taxi1 reaches _pos2 and playeeri jumps off from taxi1, cames this kinda error message:
'(taxi1 distance _pos > |#| 10)': Error distance: Type Array, expected Object
My whole script of taxitown1.sqs:
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos
#check
~1
? (unitReady taxi1): taxi1 domove _pos2
? (playeeri distance taxi1 < 2): goto "check"
? (taxi1 distance _pos > 10): goto "check"
@ (unitReady taxi1)
taxi1 domove _pos2
#cantafford
hint "You cannot afford this"
exit
And other script for taking the taxi in taxi1.sqs (in case you need it):
#check
?( playeeri distance taxi1 < 5):goto "actions"
~1
goto "check"
#actions
taxitown1 = playeeri addaction ["Take a trip to Apple Hill ($25)","taxitown1.sqs"]
#check2
~1
?( playeeri distance taxi1 < 5):goto "check2"
playeeri removeaction taxitown1
goto "check"
-
That's me being foolish. As posted in your other thread:
In OFP the distance command expects two objects, using arrays won't work.
What's been tried so far is _pos which is a location in 3 dimensions and "apple" which is a marker. You could try putting "apple" back, but I don't think it will work.
You could try using another object - something nearby or place an invisible H - or else do some trigonometry.
? ( (((getPos taxi1 select 0) - (_pos select 0)) ^ 2) + (((getPos taxi1 select 1) - (_pos select 1)) ^ 2) ) > 100: goto "check"
-
Well, my turn to be foolish and ask where i put that line in my script :-[
Also, trying to drop player (in script playeeri) to _pos and taxi1 would go to _pos2.
Im using this code:
playeeri action ["EJECT", vehicle playeeri]
Or, if easier way whit these im happy if you can help. My ribs are now broken, and eating so much painkiller that my mind isn´t working as 100% :good:
-
Well, my turn to be foolish and ask where i put that line in my script :-[
Instead of ? (taxi1 distance _pos > 10): goto "check"
-
Thank you, now it works whitout error.
Still, just wonderin how i can throw player out from that taxi1 at _pos before taxi1 goes to _pos2 ???
-
Here's an absolutely bare-bones script I've just been practising with, take from it whatever you need:
_pos = getMarkerPos "apple"
_pos2 = getMarkerPos "orange"
player moveInCargo taxi1
taxi1 doMove _pos
#journey1
~1
? (unitReady taxi1): goto "destination"
goto "journey1"
#destination
if (player in taxi1) then {(driver taxi1) globalchat "We're here."} else {goto "journey2"}
~10
if (player in taxi1) then {(driver taxi1) globalchat "Get out, you bum."; unassignVehicle player; player action ["Eject", taxi1]}
#journey2
taxi1 doMove _pos2
exitOnce the script is started, the taxi will make the journey (to _pos and then on to _pos2) all on it's own - whether the player is on board or not.
The player will only receive messages if he is in the taxi at the time.
If he does not get out at _pos, he will be kicked out after 10 seconds.
-
Thank you very much, this is lovely !
Well, your script is working but one tiny problem found.
I have moneycheck, that checks do player have money to take taxi. I have tried to put that "you cant afford this" diffrent places but it always shows that as hint, even if you can afford it. I think this script checks all #-marked, so umm... help ?
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos
#journey1
~1
? (unitReady taxi1): goto "destination"
goto "journey1"
#destination
if (playeeri in taxi1) then {(driver taxi1) globalchat "We're here."} else {goto "journey2"}
~10
if (playeeri in taxi1) then {(driver taxi1) globalchat "Get out, you bum."; unassignVehicle playeeri; playeeri action ["Eject", taxi1]}
#journey2
taxi1 doMove _pos2
#cantafford
hint "You cannot afford this"
exit
-
Add another exit after #journey2, to end the script there (ie. once the taxi has finished its route):
#journey2
taxi1 doMove _pos2
exit <---
#cantafford
hint "You cannot afford this"
exit