Home   Help Search Login Register  

Author Topic: Need help with purchase script  (Read 2040 times)

0 Members and 1 Guest are viewing this topic.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Need help with purchase script
« on: 31 Aug 2002, 19:50:21 »
ok, ive started on a purchase script which works fine except for a few minor problems.

i want to remove the players current weapon if he buys a new one - im not sure how to do it

heres the script so far - there is one script per weapon (all addaction weapons)

Code: [Select]

? money < 600 : goto "nomoney"

box1 removeaction buym16

ap1 addmagazine "m16"
ap1 addmagazine "m16"
ap1 addmagazine "m16"
ap1 addmagazine "m16"
ap1 addweapon "m16"

money = money - 600

buym16mag = box1 addaction ["Purchase Ammo", "m16ammo.sqs"]

_money = money

hint "You now have _money Dollars left"

exit

#nomoney

hint "You do not have enough money"

exit

does that work? the bit with the money?

now what i need help with is - i want to remove any weapon and all its magazines in slot 1 if the player buys a weapon (not removeallweapons since he has a handgun)

also - when i do addactions, can i add a [] bit in - so instead of having a ammo script for each weapon - i can just use and array and type what ammo it is?

e.g.

buyammo = box1 addaction ["Purchase Extra Ammo", [m16] exec "ammo.sqs"]

would that work? if it does then i just need to have one script which would look like:

Code: [Select]
_ammo = _this select 0

? money < 10 : goto "nomoney"

ap1 addmagazine "_ammo"

money = money -10

_money = money

hint "You now have _money Dollars left"

exit

#nomoney

hint "You do not have enough money"

exit

yet again - does the amount of money hint work? ive just added it now and its a complete guess - could some1 help me with that?

cheers

:thumbsup:
« Last Edit: 31 Aug 2002, 19:58:35 by Messiah »
Proud Member of the Volunteer Commando Battalion

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Need help with purchase script
« Reply #1 on: 01 Sep 2002, 03:48:48 »
The command "primaryWeapon player" will give you the players primary weapon.

The command "secondaryWeapon player" will give you the players secondary weapon.

If the player has NO primary weapon, the command will return nothing.

What you could do is....

player removeweapon (primaryweapon player)
player removemagazines (primaryweapon player)

....before buying the weapon.

The great thing is, even if you try to remove his weapon when the player has no primary weapon it wont give you an error.

The same thing goes for secondary weapons (LawLaunchers,AA Launchers, ect.)

As for actions there is no way to initialize them with arguments, so I think sticking with one script per weapon is the best thing to do.
« Last Edit: 01 Sep 2002, 03:51:34 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Need help with purchase script
« Reply #2 on: 01 Sep 2002, 16:20:26 »
ok cheers - that solves that problem - so you cant add an array to an addaction?

hmmmm - that just doubles my scripts

anyone know how to make the hint work?

so that it will display what the value of the variable money is?

cheers.
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Need help with purchase script
« Reply #3 on: 01 Sep 2002, 18:27:49 »
Code: [Select]
hint format ["You now have %1 Dollars left", _money]
There ya go!  :)


Whoot Whoot!  ::)

 8)PEACE

 

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Need help with purchase script
« Reply #4 on: 01 Sep 2002, 19:39:19 »
cheeeeeeeeeeeeeeers.
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Need help with purchase script
« Reply #5 on: 01 Sep 2002, 22:25:06 »
No prooooobs :cheers:

Oh and just what is this for? An upcoming peace mission perhaps?  :P

 8)PEACE
« Last Edit: 01 Sep 2002, 22:27:49 by Gameer_77 »

_54th_Yoshi

  • Guest
Re:Need help with purchase script
« Reply #6 on: 01 Sep 2002, 23:03:58 »
I was working on a purchase script, but never got it working correctly. I would really like to see this script working like it should. When you get it finished, i would like it if you send it to me through e-mail, or post it in the forums. Cheers! :cheers:

Soldier8Boy

  • Guest
Re:Need help with purchase script
« Reply #7 on: 02 Sep 2002, 06:19:43 »
Any chance I could get that script, Messiah? I wanne do a bank robbing, recruit gang, buy weapons and vehicles mission. Got some other scripts already, just need that one.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Need help with purchase script
« Reply #8 on: 02 Sep 2002, 13:18:42 »
yeah - i'll post an example mission in the script beta testing forum
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Need help with purchase script
« Reply #9 on: 02 Sep 2002, 23:12:01 »
Messiah, i don't want to burst your bubble, but Bn880 has already done this for his mission "The Working Mission Nogova".  ::)

 8) PEACE

dj_flash

  • Guest
Re:Need help with purchase script
« Reply #10 on: 02 Sep 2002, 23:22:24 »
I also made a purchase script today. You can purchase nearly everything (weapons, soldiers, score, tanks, ...).

I used a dialog for it so you can select the weapons in a nice list. (But only in resistance.)

You can  configure the list of items to whatever you want and don't have to use any action if you don't want to. (You could use a trigger at some place for example).

I deleted the attachment now and put it into the beta-testing section.
« Last Edit: 02 Sep 2002, 23:31:59 by dj_flash »

Gameer_77

  • Guest
Re:Need help with purchase script
« Reply #11 on: 02 Sep 2002, 23:35:40 »
Oooh...Dialogs...Me like dialogs....mmmm...link....never mind...ill find it myself...cool mate...seee ya... ::)

 8) PEACE

dj_flash

  • Guest
Re:Need help with purchase script
« Reply #12 on: 03 Sep 2002, 00:02:04 »
just look in the beta-testing section