Home   Help Search Login Register  

Author Topic: Money system...  (Read 5103 times)

0 Members and 1 Guest are viewing this topic.

Waterman

  • Guest
Money system...
« on: 21 Mar 2003, 21:03:28 »
Hi there. I have started making an MP mission along the lines of C&R (cops and robbers).  I was wondering if there was anyone there who has a script I could use for this. ???

  What I would like it to do is, when a person goes up to a certain object or building, have the option to buy a vehicle or something then subract X amout from the player and the object that is bought appears.
 It would also have to include starting money and wages for every so often.

I know it sounds a bit much :o :P, so if there is a script already made with tutorial, could someone help me...

Cheers,
Waterman. :)

Waterman

  • Guest
Re:Money system...
« Reply #1 on: 21 Mar 2003, 22:15:13 »
I think it's ok now... ::)
I think I have it working but I will see, so I wont solve it incase this doesn't work out...

Waterman. :)

Waterman

  • Guest
Re:Money system...
« Reply #2 on: 22 Mar 2003, 12:49:41 »
Actually the scripts I found only apply for 1 player I think... :-\

Take a look at these scripts and in particular the init.sqs:

<Init.sqs>

Code: [Select]
yourcash = 1000
priceredcar = 400
redcar lock true

<Buyredcar.sqs>

Code: [Select]
? (yourcash - priceredcar) >=0 : redcar lock false; yourcash = yourcash - priceredcar
[] exec "leavecarshop.sqs"
[] exec "carshop.sqs"

<Carshop.sqs>

Code: [Select]
player sidechat format ["You have £%1", yourcash]
player sidechat format ["The Sport car costs £%1", pricesportcar] player sidechat format ["The Red car costs £%1", priceredcar]

buyredcar = player addaction ["Buy red car", "buyredcar.sqs"]

<leavecarshop.sqs>

Code: [Select]
player removeaction buyredcar


That is the scripts I am using at the moment and seem to work, but not sure if it would work for all players in MP.  How would I modify these so that they would apply for all players? ???  I know it has something to do with the Init.sqs, but not sure what to do.

Or better still, if you have money scripts that work already...

Cheers,
Waterman. :)

Rappy

  • Guest
Re:Money system...
« Reply #3 on: 22 Mar 2003, 14:02:00 »
did something similiar for the whole side(west/east) as a kind of RTS system.

To buy vehicles, weapons etc

add some string to init like:
westcash = 10000
then when a player from west wants to buy a car for example(lets say there's a building for that)
buyjeepw = player addaction ["BUY JEEP (400$)", "buyjeepw.sqs"]


and in buyjeepw.sqs

?(side player == east):exit
?(westcash >399):goto "continue"
~0.2
player sidechat "Damn I dont have enough money"
exit

#continue
westcash = westcash - 400
vendor sidechat "Thank you for the purchase"
~5
"Jeep" CreateVehicle getmarkerpos "vendor"
exit



Or something like that depending on your needs


For wages you could have a timer
So it reduces cash for every 2 minutes currently, and substracts 100 units of cash

timerwages = 0
#loop
?(timerwages == 60):goto "wages"
~2
timerwages = timerwages + 1
goto "loop"

#wages
~1
westcash = westcash - 100
goto  "loop"


And ófcourse to this place you could add a check to make sure there is some cash at all.

Or adjust and add the scripts to have cash for players separately etc.
« Last Edit: 22 Mar 2003, 14:04:17 by Rappy »

Waterman

  • Guest
Re:Money system...
« Reply #4 on: 22 Mar 2003, 14:42:26 »
thanks for that Rappy. I'll try that one out...

But first, how do you activate the wages script? Do you put that code in the init, or do you make a trigger ingame?
Also, I take it "vendor" is the name of the marker where you want the cars to spawn?

Cheers,
Waterman. :)

Rappy

  • Guest
Re:Money system...
« Reply #5 on: 23 Mar 2003, 11:25:43 »
Np, I enjoy writing scripts :D

might have mistakes though as I havent tested any of that


As wages is something you would like to have constantly (unless you want to cancel it like when there is no need to pay wages to anyone)
then you could have it in init.sqs  as [] exec "wages.sqs"
or in a game logic trigger with a condition of true , either way it would be execed when the game starts.


if you wanna pause it you could have a @(startwages == true) or something similiar there to wait until the startwages condition is true again so it can continue.


yah vendor is the name of the marker where you'd like the car appear to.

You could also have the car there on the beginning alrdy aswell as you had in your first post and just have it locked down until you pay the cash.
This could be effective to have tons of cars on sight(altough could too many could lag)

But creating the vehicle on the spesific marker position would work too as you can pretty easily move it, or even preplace the car somewhere and have it getpos setpos-ed to the marker.

All sorta depends on what you would like it to end up as or look like :)

Waterman

  • Guest
Re:Money system...
« Reply #6 on: 23 Mar 2003, 14:43:43 »
Thanks again for that, but what I think I'm really after is for each player in an MP to have his own individual account, and rather than using sidechat to show items to buy, use the action menu like in the Cops and Robbers MOD.

From what you have said and given me, I think your scripts are for a side rather than individuals.  I you can modify it to work for individuals rather than teams, that would be excellent. :)

Cheers,
Waterman. :)


Rappy

  • Guest
Re:Money system...
« Reply #7 on: 23 Mar 2003, 15:14:54 »
Yah its not very much different :)

You have to have separate publicvars for each player in init like:

player1cash = 4000
player2cash = 2000
etc.


And then create an actionmenu system for the thing, I did some menu based on the action window once and it can eventually get quite complex like with subdirectories, since you need to also have another script run with each to kill all the old actions, then create the new ones (that are in the menu) and then make some action, "back" which would then load the old list again.

ok thats overcomplexed talk


What I mean:

in init.sqs

buymenu = player addaction ["Buy Cars", "buymenu.sqs"]
etc for the initial options in player action menu, if you want em to appear near buildings for example then all you needed to do for that was to add that same line to that object instead, might be wrong here though as you might also have to add a distance check:

?(player distance vendor < 10): player addaction ["buy cars", "buymenu.sqs"]


in buymenu.sqs you'd have to then summon the allmighty list of new stuff, like:

?(checker1>=1): [] exec "emptier1.sqs",checker1= 0, exit

#buy_menu
buyjeep = player addaction ["BUY JEEP (400$)", "buyjeep.sqs"]
buytruck = player addaction ["BUY TRUCK (500$)", "buytruck.sqs"]
checker1 = checker1 + 1
exit


Now where it gets complex is when it comes to getting rid of all the older actions and stuff like that especially when you have several menus
thats why I added that checker var, to make sure I dont have the menu run twice or anything like that.
and this way I can also close the menu if I select it again, you can leave it out if you have it come up when you are close to some building and then add another line there:
?(player distance vendor > 10): [] exec "emptier1.sqs"

which would also exec the script emptier1.sqs where you could clean all the actions that shouldnt be there anymore (thats why its important to add IDs so you can kill the actions)

in emptier1.sqs

Player RemoveAction buyjeep
Player RemoveAction buytruck
exit


I think this should work :D

However in mp you need to be extra sure that some things dont get mixed up.

so its good to add checks like ?(side player == west): exit
depending on which side the script was ment for or:
?(player == playername) to make it player dependant.

Waterman

  • Guest
Re:Money system...
« Reply #8 on: 23 Mar 2003, 16:00:43 »
Ok. That appears to be what I'm after... :D I'll try it out and get back to you if I have any problems or someone else...

Cheers,
Waterman. :cheers:

Waterman

  • Guest
Re:Money system...
« Reply #9 on: 23 Mar 2003, 17:44:31 »
How do you activate the "buy cars" menu?
I tried putting this in the init of the building I wanted to use and it game me an error...

Code: [Select]
?(player1 distance vendor < 10): player1 addaction ["buy cars", "buymenu.sqs"]
...where player1 is the name of a player. ;) and vendor was the name of the building I used.
I also tried that same code in a trigger and same error message...(I think it said something about invalid number or something). ::)

So what am I doing wrong?

Waterman.
« Last Edit: 23 Mar 2003, 17:45:08 by Waterman »

Rappy

  • Guest
Re:Money system...
« Reply #10 on: 23 Mar 2003, 23:04:00 »
hmph my mistake.

into a condition of something (trigger or a gamelogic):
player1 distance vendor < 10

on activation field:
player1 addaction ["buy cars", "buymenu.sqs"]

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Money system...
« Reply #11 on: 23 Mar 2003, 23:51:06 »
dat meens he wil have 2 make difrent variable foreach player right ? - and addaction 4each player alone ? 2 heavy i think ;D - ill make somin betar tomoz and attach it here (need som time 2 work on it ;))

on da meantime waterman go and work on skye  ;)  ;D

@ rappy - if u wanna do dat script here is hint (or foor 4 though or watever ;D)

arrays is da key (actualy 1 array 4 all)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Rappy

  • Guest
Re:Money system...
« Reply #12 on: 24 Mar 2003, 17:22:05 »
Yah arrays make a lot of things easier, but I think they can sometimes be a bit complex aswell if you are just trying to get into scripting.

You could just have all of the players that you will use in the game in the array and launch its own script for all of em via:
"_x exec scriptname" ForEach arrayname

And yah now than I think about it, the script can be made shorter with an array :D
But it rarely is the first thing I think about for some reason  ;)

Waterman

  • Guest
Re:Money system...
« Reply #13 on: 24 Mar 2003, 20:08:59 »
Ok. Thanks LCD... You telling me what to do?! >:(  ;) LOL.

Waiting for that script(s)... ;)

Cheers Rappy also for you effort,
Waterman. :D

P.S. @LCD - Asmo has made a new mission like that one he made a while ago... Im going to get more kills than you are... ;) ;D

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Money system...
« Reply #14 on: 25 Mar 2003, 00:36:22 »
here is da script u want ;D

u wil need 2 make all da oder scripts but it should b simple  ;)  ;D

2 start an account (note da script is named LCD_Swiss_Bank - so its account ;))

do

["init",unitname,startinMoneyAmmount(number)] exec "LCD_Swiss_Bank.sqs"

2 show how much money dere is - do

["show",unitname] exec "LCD_Swiss_Bank.sqs" (it shows in hint now but it can b changed)

2 add or remove 2 account

["add_remove",unitname,ammount(can b negative number or positive number)] exec "LCD_Swiss_Bank.sqs"

now wen u use it w/ action script instead of unitname use _this select 1 in da action script (gives da name of da man who made da action ;D

im sure o forgot somin  ::) but u wil have 2 tel me wat ;D

:cheers:

tel me if u need more help on somin ;D

LCD OUT

P.S yes i do tel u wat 2 do :P i need dat island finished ;) and u wil never get higher score muhahahahahahaha
« Last Edit: 25 Mar 2003, 00:38:13 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta