Home   Help Search Login Register  

Author Topic: Problem with money script. HELP!  (Read 8029 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #15 on: 05 Sep 2006, 19:34:11 »
I see, i made a mistake when creating the array and it's subarrays;


Quote
"if (alive _x) then {cash_array = cash_array + [_x,0,0]}" foreach [w1,w2,w3,w4,e1,e2,e3,e4]

in init.sqs should be changed into:

Code: [Select]
"if (alive _x) then {cash_array = cash_array + [[_x,0,0]]}" foreach [w1,w2,w3,w4,e1,e2,e3,e4]

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #16 on: 05 Sep 2006, 20:47:28 »
I just noticed another mistake i made:

The onActivation line of the trigger:

Code: [Select]
cash_array select temp_count set [3,temp_cash]; cash_update = false; publicVariable "cash_update"

should be changed into:

Code: [Select]
cash_array select temp_count set [2,temp_cash]; cash_update = false; publicVariable "cash_update"

Look: cash_array looks now like this:

[[unit1,cash,0],[uni2,cash,1],[unit3,cash,2]]

Now my mistake was i did change the counter (3rd element of the subarray).
But i should change the cash (second element of the subarray).

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #17 on: 06 Sep 2006, 17:32:22 »
 I again copy / paste the codes...

 when script was executed there came a error :  'cash_update]l#l': error missing (     :blink:

 (again got a screenshot)

 P.S   you said:

Now into each unit's init field you only put:

this addEventHandler ["killed",{_this ecec {cash_update.sqs}}]

is that  ecec supposed be exec   :scratch:
« Last Edit: 07 Sep 2006, 18:26:25 by tommi »

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #18 on: 06 Sep 2006, 18:37:18 »
Yes it's supposed to be exec  :)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Problem with money script. HELP!
« Reply #19 on: 07 Sep 2006, 18:08:05 »
Not 100% sure but the following line might be in error:

"publicVariable _x" forEach [cash_update,temp_count;cash_update]

I would suspect the last entry in the array, the emboldened part, try removing it.

I think it might be superfluous, however MP stuff is not my thing.

If the second instance of cash_update is correct then it might just need the semi-colon changed to a comma.


Planck
I know a little about a lot, and a lot about a little.

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #20 on: 07 Sep 2006, 18:19:24 »
Quote
Not 100% sure but the following line might be in error:

"publicVariable _x" forEach [cash_update,temp_count;cash_update]

I would suspect the last entry in the array, the emboldened part, try removing it.

 that one diden't work...

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Problem with money script. HELP!
« Reply #21 on: 07 Sep 2006, 18:27:33 »
Please be more precise, what did you try and what happened.

I meant for you to change:

"publicVariable _x" forEach [cash_update,temp_count;cash_update]

to

"publicVariable _x" forEach [cash_update,temp_count]

If that is what you did and it didn't work......what error message did you get after?


Planck
I know a little about a lot, and a lot about a little.

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #22 on: 07 Sep 2006, 18:32:43 »


 I changed 

"publicVariable _x" forEach [cash_update,temp_count;cash_update]

to

"publicVariable _x" forEach [cash_update,temp_count]

and got a error messege :
 
 'publicVariable _xl#l': Error publicVariable : type Bool, expected String


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Problem with money script. HELP!
« Reply #23 on: 07 Sep 2006, 18:37:51 »
I would wait and till CD comes back on the site for a definitive answer here.....as I said MP stuff is not really my thing.

In the meantime you could try instead:

publicVariable "_x" forEach [cash_update,temp_count]

 :dunno:


Planck
I know a little about a lot, and a lot about a little.

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #24 on: 07 Sep 2006, 18:43:37 »
 I tried  publicVariable "_x" forEach [cash_update,temp_count]...
 it di not work

 I understand MP stuff is not really your thing....

 thanks anyway  ;)

 I'll try different variations of   publicVariable "_x" forEach [cash_update,temp_count]   :D

 

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #25 on: 07 Sep 2006, 19:39:17 »
OK, i found the buggers in the publicVariable statement;

I sent twice the variable: cash_update
and i forgot: temp_cash instead.

"publicVariable _x" forEach ["temp_cash","temp_count","cash_update"]

There where the quotation marks missing.
PublicVariable "varname"
It's a string and i did just pv the pure variable name.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #26 on: 08 Sep 2006, 13:34:37 »
 OK now there dosen't come 'cash_update]l#l': error missing ( any more... thats good

 when I killed the first enemy the script was fine, but when I killed the second enemy unit there came a error messege:

'cash_array select temp_count setl#l [2,temp_cash]; cash_update = false; publicVariable "cash_array": Error Zero divisor

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #27 on: 08 Sep 2006, 14:23:49 »
 :scratch: i did nowhere say that you should publicVariable "cash_array", or did i?

You've put that by yourself me guess.

PublicVariable "cash_update"

But thinking about it, this trigger is running global, so you can leave the publicVariable "cash_update"
out of it also. But you must let remain the command: cash_update = false.

Either this version:

Code: [Select]
cash_array select temp_count set [2,temp_cash]; cash_update = false; publicVariable "cash_update"
or this one:

Code: [Select]
cash_array select temp_count set [2,temp_cash]; cash_update = false
:edit - well for better overview i'll make a sumarry of what we have now:

init.sqs
Code: [Select]
;init.sqs

cash_array = []
temp_cash = 0
temp_count = 0
cash_update = false

"if (alive _x) then {cash_array = cash_array + [[_x,0,0]]}" foreach [w1,w2,w3,w4,e1,e2,e3,e4]

_i = 0
_count = count cash_array

#loop

(cash_array select _i) set [3,_i]

_i = _i + 1
?(_i < _count): goto "loop"

Init field of each unit:
Code: [Select]
this addEventHandler ["killed",{_this exec {cash_update.sqs}}]

cash_update.sqs
Code: [Select]
;cash_update.sqs

@!cash_update
"if (_this select 1 == _x select 0) then {temp_cash = (_x select 1);temp_count = (_x select 2); temp_cash = temp_cash + 40}" forEach cash_array

cash_update = true
"publicVariable _x" forEach ["cash_update","temp_count","cash_update"]
exit

Trigger:
Code: [Select]
size: 0/0
activation: none / repeatedly
condition: cash_update
onActivation: cash_array select temp_count set [2,temp_cash]; cash_update = false

OK, i hope i sorted all errors out now.

~S~ CD
« Last Edit: 08 Sep 2006, 14:49:51 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline tommi

  • Members
  • *
Re: Problem with money script. HELP!
« Reply #28 on: 08 Sep 2006, 15:12:56 »
I dont know WTF is wrong with the Trigger...     :blink:

 I have onActivation: cash_array select temp_count set [2,temp_cash]; cash_update = false

 still getting a error messege: 'cash_array select temp_count setl#l [2,temp_cash]; cash_update = false : Error Zero divisor 

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: Problem with money script. HELP!
« Reply #29 on: 08 Sep 2006, 16:00:08 »
 :scratch: I can't try it out but maybe it doesn't work to use the set command on a subarray in that way.

OK try this workaround:

Code: [Select]
temp_array = cash_array select temp_count; temp_array set [2,temp_cash]; cash_array set [temp_count,temp_array]; cash_update = false
maybe this helps  :)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted