Home   Help Search Login Register  

Author Topic: Money System  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Money System
« on: 14 Sep 2009, 04:52:19 »
I've been working with some scripts, and here is what I have so far:
My purchase script (purchase.sqf):
_cash = cash
?(_cash < 200):goto "cantafford"
"Tractor" createvehicle getpos GL1;
cash = _cash - 200
hint format["Money: $%1", cash]
exit

#cantafford
_this sidechat "You dont have enough money!"
exit


My money display script (display.sqf):
cash = _this select 0

hint format["Money: $%1",cash]
exit

My money system script (money.sqf):
_player = _this select 0

cash = 500

?(local Server): [cash] exec "display.sqf"
exit

My profit script (Gain.sqf):
_cash = cash
cash = _cash + 200
hint format["Money: $%1", cash]
exit


However, I have to label a character ingame, called "P1" for it to work.  How do I make it so that it works for more than one person, and how do I make it specifically for a single person such as purchasing and profits?

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Money System
« Reply #1 on: 15 Sep 2009, 02:10:51 »
Your code raises some questions:

- Why do your files have a SQF ending when they contain SQS script?
- What purpose do the "_cash" and "_player" variables serve?
« Last Edit: 15 Sep 2009, 08:35:07 by Worldeater »
try { return true; } finally { return false; }

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Re: Money System
« Reply #2 on: 18 Sep 2009, 22:57:37 »
SQS and SQF wouldnt matter at this point, they both will work.
The "_cash" defines the money while the "_player" is going to define the player which will have the money.  Kinda hoping that it will reflect it to all players if they are in multiplayer.  I plan to have this script to be used for multiplayer.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Money System
« Reply #3 on: 04 Oct 2009, 05:56:24 »
The engine doesn't care what you name your script files, only how you call them: exec for SQS and execVM for SQF. However, since you are using SQS syntax, you should probably name your scripts with an SQS extension to avoid confusion.

If you use addAction then:
_object = _this select 0
_caller = _this select 1