Author Topic: Variable Events - onRelay can't check Client variable?  (Read 1211 times)

I'm trying to make a simple bank system where people can either deposit or withdraw their savings all at once. However, to do so, I need my events to be able to tell when to stop giving money to the player.

Here's what I have:

OnActivate -> Self -> FireRelay
OnRelay -> Self -> FireRelay
OnRelay -> Self -> VCE_ifVariable [cyrbank] >

OnVariableTrue -> Client -> VCE_modVariable [cyrbank] subtract [1]
OnVariableTrue -> Player -> VCE_modVariable [cyr] add [1]
OnVariableFalse -> Self -> CancelEvents

So, basically what I want it to do is look at the client's value for how much money they've already saved (cyrbank) and keep decreasing that while adding the same amount to the player's money (cyr). Then I want it to stop when cyrbank equals 0. Can you guys help me out? What am I missing?

I'm trying to make a simple bank system where people can either deposit or withdraw their savings all at once. However, to do so, I need my events to be able to tell when to stop giving money to the player.

Here's what I have:

OnActivate -> Self -> FireRelay
OnRelay -> Self -> FireRelay
OnRelay -> Self -> VCE_ifVariable [cyrbank] > [ø]
OnVariableTrue -> Client -> VCE_modVariable [cyrbank] subtract [1]
OnVariableTrue -> Player -> VCE_modVariable [cyr] add [1]
OnVariableFalse -> Self -> CancelEvents

So, basically what I want it to do is look at the client's value for how much money they've already saved (cyrbank) and keep decreasing that while adding the same amount to the player's money (cyr). Then I want it to stop when cyrbank equals 0. Can you guys help me out? What am I missing?

I think I should also specify (even though this'll end up making a triple post) that since OnRelay can't check variables on anything other than itself, I need to find a roundabout way to make this work.

OnRelay can't check variables on anything other than itself, I need to find a roundabout way to make this work.
[Self] > [VCEifValue] > [<var:cl/pl:cyrbank>] Use cl if client, pl if player.

I would do...
[0][0] >[OnActivate] > [Self] > [FireRelay]
[1][33] >[OnRelay] > [Self] > [FireRelay]
[2][0] > [OnRelay] > [Self] > [VCEifValue] [<var:cl:cyrbank>] [>] [0] [3 6]
[3][0] > [OnVariableTrue] > [Self] > [VCEmodVariable] [Client] [cyrbank] [subtract] [1]
[4][0] >[OnVariableTrue] > [Self] > [VCEmodVariable] [Player] [cyr] [add] [1]
[5][0] > [OnVariableFalse] > [Self] > [SetEventEnabled] [2] []
[6][500] > [OnVariableFalse] > [Self] > [SetEventEnabled] [2] [tick]

I'm pretty sure that would work....

[Self] > [VCEifValue] > [<var:cl/pl:cyrbank>] Use cl if client, pl if player.

<headdesk>

Thanks Zenloth. I completely forgot about those. I'll give it a try now.

<headdesk>

Thanks Zenloth. I completely forgot about those. I'll give it a try now.

This will not work! Values are preset numbers that cannot be changed via events!

Instead, try Method A or Method B. Both will work.

Method A: Set a brick's variable to the client's variable

Code: [Select]
[X] 0 [0] onActivate -> Self -> fireRelay
[X] 1 [0] onRelay -> Self -> fireRelay
[X] 2 [0] onRelay -> Self -> VCE_modVariable {Brick} -> [cyrbank] set [<var:cl:cyrbank>]
[X] 3 [0] onRelay -> Self -> VCE_ifVariable -> [cyrbank} > [0] [4 6]
[X] 4 [0] onVariableTrue -> Client -> VCE_modVariable -> [cyrbank] subtract [1]
[X] 5 [0] onVariableTrue -> Player -> VCE_modVariable -> [cyr] add [1]
[X] 6 [0] onVariableFalse -> Self -> cancelEvents

Method B: Use functions rather than relays

Code: [Select]
[X] 0 [0] onActivate -> Self -> VCE_stateFunction -> [Withdraw] [2 2]
[X] 1 [0] onActivate -> Self -> VCE_callFunction -> [Withdraw] [ ]
[X] 2 [0] onVariableFunction -> Client -> VCE_ifVariable -> [cyrbank} > [0] [3 5]
[X] 3 [0] onVariableTrue -> Client -> VCE_modVariable -> [cyrbank] subtract [1]
[X] 4 [0] onVariableTrue -> Player -> VCE_modVariable -> [cyr] add [1]
[X] 5 [0] onVariableTrue -> Self -> callFunction -> [Withdraw] [ ]

This will not work! Values are preset numbers that cannot be changed via events!
I am fairly sure you can use variable replacers with the ifValue on any variables.

No, you can't. ifValue only works with "special variables", or values.

No, you can't. ifValue only works with "special variables", or values.
Zentrhox emailed me and it works. Also, check up on your variable replacers in the VCE guide. It works.

Difference between VCE_ifVariable and VCE_ifValue


onActivate -> self -> VCE_ifValue <var:player:money> ...
onActivate -> self -> VCE_ifValue <var:player:health> / <var:client:bl_id> ...

onActivate -> player -> VCE_ifVariable money ...