Home   Help Search Login Register  

Author Topic: Money Counter for Each Player  (Read 663 times)

0 Members and 1 Guest are viewing this topic.

Mike

  • Guest
Money Counter for Each Player
« on: 06 Nov 2002, 09:37:08 »
Can anyone tell me how I would add say $5000 "dollars" to each player and hint a message "You have $5000 left" and that sort of thing.. how would I make it remove $500 from a player and make a message for just that player saying "You have $4500 left" ...

I want to make basically a buying menu.. but the currency counters for each player is something I dont know how to do.. I know how to spawn a vehicle and I can figure out how to add action the option to buy the vehicle. But I dont know how to actually have money that is removed and given to another player once a player hits a buy action..

Any help with how to add money counters would be verry appreciated ;D  :cheers:
« Last Edit: 06 Nov 2002, 09:40:56 by Mike »

DG

  • Guest
Re:Money Counter for Each Player
« Reply #1 on: 06 Nov 2002, 12:27:19 »
Well , this is a 5min job so I hope this helps and gets you started in the right direction....

first you need to invent the value for the game , forget the "$" it just gets in the way .... but you can still have it show up though.

I have written startmoney.sqs and display.sqs below , put these in the gamefolder with the mission.sqs and this is what I did:

1. created player (name:P1 , Initialization:[P1] exec "startmoney.sqs") rest of the settings can be anything
2. (most important!) created Game Logic "Server" , selectF1 ,doubleclk , select Game Logic for the "Side" value , then in the name "Server" , then ok.

That should do it but let me explain the thinking so that you can go forward with this on your own.

the first line takes in the value from the Init Field "[here]" in the game. [0,1,2,3 ....etc] essentially the first value which is P1

second line I invent the VARIABLE "startingmoney" and its value "5000"

third line , for us to take that value to the "display.sqs" we enclose it the the [] square brackets and its the "local Server" that is executing the script.

-------------------------------------startmoney.sqs
_player = _this select 0

startingmoney = 5000

?(local Server): [startingmoney] exec "display.sqs"
exit

-----------------------------------------

 again the value in the [] that the script receives is explained as "startingmoney" , this is not really necessary for just one value but good habit

then the "hint" shows the value on the screen , notice how the "$" is just placed along side of it , that reduces the confusion for the game.


-----------------------------------display.sqs
startingmoney = _this select 0

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

 Cheers hope this starts you off !

DG

Mike

  • Guest
Re:Money Counter for Each Player
« Reply #2 on: 06 Nov 2002, 20:51:22 »
It was a great 5 minute answer.. But if u could cover how the best way to remove money from taht account and give another player money you would help me a lot! ;)

edited

well I have figured out how to remove money from the starting money variable:

hint format["Money: $%1",startingmoney - 500]

but will that be removing the money from everyone? or do I have to copy this script for each player and change the names?.. And how do I change the starting money so it takes off the 500 so that next time they buy something the 5000 u start with is actuallt 4500 and so u can buy different things so that..

hint format["Money: $%1",startingmoney - 500]

will make u end up with 4000 instead of 4500 again

edited again.. ;)

well Ive done some tinkering and found out how to do it basically all I had to add was:

startingmoney = startingmoney - 500

duh ;)

edited 1 last time..

Im still having problems.. it only has 1 value for money.. do I need a new one for each player?..
« Last Edit: 11 Nov 2002, 01:41:34 by Mike »