Home   Help Search Login Register  

Author Topic: Money & Taxi script questions  (Read 2961 times)

0 Members and 1 Guest are viewing this topic.

Offline Yasirotta

  • Members
  • *
Money & Taxi script questions
« on: 05 Aug 2008, 13:01:36 »
Here is codes i have using this far:

in init.sqs
man1money = 100

When player is using money
man1money = man1money -50

Checking how much money i have left:
man sidechat format ["I have %1 in my pocket",man1money]

All these codes are found in here OFPEC Forum. So, first question is why checking money doesn't work ? It just says something like "i have Echo Black 1: (player) in my pocket"

Second question, How i can get code of "Not enough money" ?  :dunno: Also, like that minimum cash is 0. So that could not go under that, like -50.

Third, I can use that "how much money i have left" as radio command. What if i want that in action menu ?

And finally, any ideas for taxi ? Maybe it would work whit action menu control, like "Trip to town1 (25$)". I have only four towns in game area, so there is no need to map-clicking taxi. Also, in this mission it would be better to have no map-clicking. And finally, is there easy way to keep that taxi running ? I mean, when player gets to town1, taxi drops him but goes somewhere else then ? Not staying town1 ?

Thanks for all replys what i have got this far. I have noticed there are a lots of wise men here 
« Last Edit: 05 Aug 2008, 13:11:15 by Yasirotta »

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #1 on: 05 Aug 2008, 15:01:40 »
For your first question, I can't see anything wrong with the code, though maybe an easier way to do it would be to display it as a hint.
Code: [Select]
hint format ["I have %1 in my pocket.",man1money]
If you want a not enough money then you would need to check the amount before you processed it for example:
Code: [Select]
_cost = 25
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]

//the rest of your actions go here

exit
#cantafford
hint "You cannot afford this"
exit

For checking your money, take the first statement and use it.

For a radio command:
Place a trigger, activation radio alpha.
Change the text to whatever you want (check money or something)
Make sure it is repeating
Put the command in the on activation

For athe action menu:
Use a script like the following (it needs to be activated at the start, it can be the init:
Code: [Select]
#check
?( man1 distance taxi1 < 10):goto "actions"
~1
goto "check"
#actions
taxitown1 = man1 addaction ["Take a trip to town 1 ($25)",taxitown1.sqs"]
#check2
~1
?( man1 distance taxi1 < 10): goto "check2"
man1 removeaction taxitown1
goto "check"

Then the script mentioned (taxitown1.sqs) would look like the script i made before about a limit, and make sure the line:
Code: [Select]
man1 removeaction taxitown1is in that also.

If somehting doesn't work or if you have mroe questions, please feel free to ask. :)
-=GC=-Fungus1999
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #2 on: 05 Aug 2008, 22:21:03 »
Then the script mentioned (taxitown1.sqs) would look like the script i made before about a limit, and make sure the line:
Code:

man1 removeaction taxitown1

is in that also.

Sorry, can't understand all cos my bad english :)
So, i lost the picture... What that taxitown1.sqs script should look like ?
And i can make other ways to town 2 or town 3 as same scripts by changing just names ?

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #3 on: 05 Aug 2008, 23:12:00 »
You would use this script, with the line added in:

Code: [Select]
_cost = 25
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction taxitown1

//the rest of your actions go here

exit
#cantafford
hint "You cannot afford this"
exit

For more places, you would add more actions to the starting script (the one that has checks in it). But don't forget to remove them as well.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #4 on: 06 Aug 2008, 17:30:10 »
It gives me error message:

taxitown1 = man1 addaction ["Take a trip to town 1 ($25)",taxitown1|#|.sqs"] Error Unknown Operator

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #5 on: 06 Aug 2008, 17:56:17 »
Sorry, my bad made a small typo. Should be
Code: [Select]
taxitown1 = man1 addaction ["Take a trip to town 1 ($25)","taxitown1.sqs"]not
Code: [Select]
taxitown1 = man1 addaction ["Take a trip to town 1 ($25)",taxitown1.sqs"]missed out a quote marks.
 :-[
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #6 on: 06 Aug 2008, 19:03:13 »
Nice ! ! !
It works  :D Okay, it says that take trip, but outside taxi. I went "ride in back" but then that action was gone.
How i can put it so, that you first get into taxi and then comes action line "Take trip to town 1" ?

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #7 on: 06 Aug 2008, 19:18:29 »
To work out whether you are in teh car, just change the checks in the following script.
Change this:
Code: [Select]
#check
?( man1 distance taxi1 < 10):goto "actions"
~1
goto "check"
#actions
taxitown1 = man1 addaction ["Take a trip to town 1 ($25)","taxitown1.sqs"]
#check2
~1
?( man1 distance taxi1 < 10): goto "check2"
man1 removeaction taxitown1
goto "check"
to this:
Code: [Select]
#check
?( man1 in taxi1 == true):goto "actions"
~1
goto "check"
#actions
taxitown1 = man1 addaction ["Take a trip to town 1 ($25)","taxitown1.sqs"]
#check2
~1
?( man1 in taxi1 == true): goto "check2"
man1 removeaction taxitown1
goto "check"

That should work, though I'm less sure about this.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #8 on: 06 Aug 2008, 19:54:26 »
Says first at start "Error ==: type bool, exepted numer,string,object,side...."

Or something like that :(

And just for sure, i use same taxitown1.sqs script for other car, just changing name to taxi2 and script to taxitown2 ?
And every time when man1 is buying something, does it work like this ?

#check
?( man1 distance dealer1 < 3):goto "actions"
~1
goto "check"
#actions
dealer1 = man1 addaction ["Buy Hand Grenade ($50)","dealer1.sqs"]
#check2
~1
?( man1 distance dealer1 < 10): goto "check2"
man1 removeaction dealer1
goto "check"

and dealer1.sqs is same kind like taxitown1.sqs but chaning same way prizes and names ?
Is there easier way, if dealer1 is selling 3 items ?

If someone just gives cash its just only "man1money = man1money +50" ?
And how i get that taxi1 moving btw ?  :blink:
« Last Edit: 07 Aug 2008, 00:01:10 by Yasirotta »

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #9 on: 07 Aug 2008, 10:49:00 »
He he, you sure are curious  :)

About the error, you could try changing these 2 lines:
Code: [Select]
?( man1 in taxi1 == true):goto "actions"
Code: [Select]
?( man1 in taxi1 == true): goto "check2"to
Code: [Select]
?( man1 in taxi1):goto "actions"
Code: [Select]
?( man1 in taxi1): goto "check2"
It may work, but again I'm unsure.

When you said
Quote
And just for sure, i use same taxitown1.sqs script for other car, just changing name to taxi2 and script to taxitown2 ?
That would work, just change anything related to taxi1 to taxi2

For buying things, could could use this script, and to have multiple options, you can add them to this script:
Code: [Select]
#check
?( man1 distance dealer1 < 3):goto "actions"
~1
goto "check"
#actions
dealer1option1 = man1 addaction ["Buy Hand Grenade ($50)","dealer1option1.sqs"]
dealer1option2 = man1 addaction ["Buy other weapon ($100)","dealer1option2.sqs"]
dealer1option3 = man1 addaction ["Buy rockets ($500)","dealer1option3.sqs"]
#check2
~1
?( man1 distance dealer1 < 3): goto "check2"
man1 removeaction dealer1
goto "check"

The very important thing is that you remove all of the actions in all 3 scripts.
So in dealer1option1, dealer1option2, and dealer1option3 would all need the following lines:
Code: [Select]
man1 removeaction dealer1option1
man1 removeaction dealer1option2
man1 removeaction dealer1option3

And the dealer1option1, 2 and 3 would look a bit like taxitown1.sqs.

Quote
If someone just gives cash its just only "man1money = man1money +50" ?
That's right, that'll jsut add money. Just remember that the money is just a variable, as a scripter you can control the money any way you can control a variable.

Quote
And how i get that taxi1 moving btw ?

I'm a bit unsure about this, that's why I left it out  :whistle:
I'll show you what you could do using the taxitown1.sqs:
Code: [Select]
_cost = 25
_pos = getmarkerpos "town1"
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction taxitown1
~3
taxi1 domove _pos1
exit
#cantafford
hint "You cannot afford this"
exit

If you'll notice, I've added this line:
Code: [Select]
_pos = getmarkerpos "town1"This just means it gets a position from a marker named town1. The great thing about this is that you can move the marker, and even make it invisible (type none).

Any more? :D
-=GC=-Fungus1999
« Last Edit: 07 Aug 2008, 10:50:38 by Gcfungus »
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #10 on: 07 Aug 2008, 12:52:07 »
I kinda worked, and diddn't.
I went to taxi, but there wasn't any new actions. But when i get out from taxi, it flashes soo quickly that "take trip to town1" when im getting out from taxi1. I guess that works, but some reason it just wont let it see inside vechile.

Then, we have multiple actions and few scripts. Im only confusing now, when comes that part when it checks can you afford that ?

Does it go like this ?

Dealer1.sqs
Code: [Select]
#check
?( man1 distance dealer1 < 3):goto "actions"
~1
goto "check"
#actions
dealer1option1 = man1 addaction ["Buy Hand Grenade ($50)","dealer1option1.sqs"]
dealer1option2 = man1 addaction ["Buy other weapon ($100)","dealer1option2.sqs"]
dealer1option3 = man1 addaction ["Buy rockets ($500)","dealer1option3.sqs"]
#check2
~1
?( man1 distance dealer1 < 3): goto "check2"
man1 removeaction dealer1
goto "check"

Dealer1option1.sqs
Code: [Select]
_cost = 50
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction dealer1option1
man1 addmagazine "Hand Grenade"

exit
#cantafford
hint "You cannot afford this"
exit

And if it works like this, i just do like that for dealer1option2.sqs and dealer1option3.sqs ???

And yes, i have two more questions  :D
If taxi makes thing GetPos command, how i could make it drop man1 to town1 and keep going to somewhere else ?
And if Dealer2 is selling LAW, how can i remove that after buying, so you cant buy that later again ?

Feels like i must buy you a pint someday  :cool2:
« Last Edit: 07 Aug 2008, 17:18:54 by Yasirotta »

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #11 on: 07 Aug 2008, 17:40:14 »
I don't know what's gone wrong exactly, and even if I did I probably couldn't solve it.

I can help you with the multiple actions however.
This script:
Code: [Select]
#check
?( man1 distance dealer1 < 3):goto "actions"
~1
goto "check"
#actions
dealer1option1 = man1 addaction ["Buy Hand Grenade ($50)","dealer1option1.sqs"]
dealer1option2 = man1 addaction ["Buy other weapon ($100)","dealer1option2.sqs"]
dealer1option3 = man1 addaction ["Buy rockets ($500)","dealer1option3.sqs"]
#check2
~1
?( man1 distance dealer1 < 3): goto "check2"
man1 removeaction dealer1
goto "check"
needs to be activated at the start, and only needs to be activated once as it is looping, sorta like a repeating trigger.

The second script (dealer1option1.sqs) is almost right.
Code: [Select]
_cost = 50
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction dealer1option1
man1 removeaction dealer1option2
man1 removeaction dealer1option3
//
man1 addmagazine "Hand Grenade"
//
exit
#cantafford
hint "You cannot afford this"
exit

I added // in to represent where you can add more magazines/weapons ect. It's important to remember to remove any actions you added earlier, not just the one.

For moving the taxi on, you could use a script like this:
Code: [Select]
_cost = 25
_pos = getmarkerpos "town1"
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction taxitown1
~3
taxi1 domove _pos1
#check
~1
?(man1 in car):goto "check"
?(taxi1 distance _pos > 40):goto "check
exit
#cantafford
hint "You cannot afford this"
exit

Should work, but could be problematic.

for your last question, what you would need to do is set up a variable.
Like so:
Code: [Select]
rocketdone = 1
#check
?( man1 distance dealer1 < 3):goto "actions"
~1
goto "check"
#actions
dealer1option1 = man1 addaction ["Buy Hand Grenade ($50)","dealer1option1.sqs"]
dealer1option2 = man1 addaction ["Buy other weapon ($100)","dealer1option2.sqs"]
?(rocketdone == 1):dealer1option3 = man1 addaction ["Buy rockets ($500)","dealer1option3.sqs"]
#check2
~1
?( man1 distance dealer1 < 3): goto "check2"
man1 removeaction dealer1
goto "check"
and
Code: [Select]
_cost = 50
?(man1money < _cost):goto "cantafford"
man1money = man1money - _cost
hint format ["I have %1 in my pocket.",man1money]
man1 removeaction dealer1option1
man1 addmagazine "LAWLauncher"
rocketdone = 2
exit
#cantafford
hint "You cannot afford this"
exit

If this doesn't work, please remember this is getting more complicated every time, lol.  :D
-=GC=-Fungus1999
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #12 on: 07 Aug 2008, 22:08:55 »
Ok.
I can't see that "take trip to town1" inside taxi1, and that working "Check your money" either. Maybe i change it back that old style distance mode, and add command man1 moveincargo taxi1 ? Might not look so realistic, but should work easier. If anyone has idea how to solve that problem that actions dont are visible in vechile, i would be very happy to hear it  :)

NEWS:
I changed back to distance command. First everything was working great, money dropped that 25$ and moveincargo works. But then, taxi1 diddn't move to town1. I was looking again script and i did this change:

Code: [Select]
taxi1 domove _pos1to this
Code: [Select]
taxi1 domove _pos
Now, taxi1 is moving nicely to town1 but when i get out i got this message:
Code: [Select]
?(taxi1 distance _pos > |#|10) Error: Type array, exepted object
At least we are very close that this works  :D
« Last Edit: 07 Aug 2008, 22:46:30 by Yasirotta »

Offline Gcfungus

  • Members
  • *
Re: Money & Taxi script questions
« Reply #13 on: 07 Aug 2008, 23:44:25 »
Ok, I think it would be easier to use the distnace thing. If anyone else can solve the problem that's great.

Also, about this error:
Code: [Select]
?(taxi1 distance _pos > |#|10) Error: Type array, exepted objectThat's my bad, it should be:
Code: [Select]
?(taxi1 distance town1 > 10)not
Code: [Select]
?(taxi1 distance _pos > 10)Remember town1 is the marker.  :)

Other than that, if there are any more questions then please feel free to ask. Let's hope someone mmore expirienced can help out with your other problem.  :good:
-=GC=-Fungus1999
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline Yasirotta

  • Members
  • *
Re: Money & Taxi script questions
« Reply #14 on: 08 Aug 2008, 12:06:27 »
Gcfungus, thanks a lot of your anwers.  :clap:
Now the hardest part is done, and i can solve taxi2 and other dealers myself. Once again, thank you.