Author Topic: Button a player can only press once?  (Read 1448 times)

Say, for an in-game poll machine. You click a button once, it increments a number on a print brick, but you click it again, it says "Sorry, you've already voted." I've tried doing this using VCE Variables, with no success... Is  this possible? Thank you. :)

onactivate>client>vce_ifvariable[pollclicked][!=][1][1 3] (change the 3 to hit the last onvaraiblefalse/onvariabletrue line)
onvariabletrue>client>centerprint[<color:ffffff>You already voted.]
onvariablefalse>client>vce_modvariable[pollclicked][set][1]
onvariablefalse>target>output (put the other stuff here)

onactivate>client>vce_ifvariable[pollclicked][!=][1][1 3] (change the 3 to hit the last onvaraiblefalse/onvariabletrue line)
onvariabletrue>client>centerprint[<color:ffffff>You already voted.]
onvariablefalse>client>vce_modvariable[pollclicked][set][1]
onvariablefalse>target>output (put the other stuff here)

What exactly does != mean? I tried it with ==. What I tried was:

OnActivate>Client>VCE_ifVariable>[pollclicked][==][0][1 3]
OnVariableTrue>Client>VCE_ModVariable[pollclicked][set][1]
OnVariableFalse>Client>VCE_ModVariable[pollclicked][set][0]


And the rest, under that...

onactivate>client>vce_ifvariable[pollclicked][!=][1][1 3] (change the 3 to hit the last onvaraiblefalse/onvariabletrue line)
onvariabletrue>client>centerprint[<color:ffffff>You already voted.]
onvariablefalse>client>vce_modvariable[pollclicked][set][1]
onvariablefalse>target>output (put the other stuff here)

I did exactly as you said:

Code: [Select]
onactivate>client>vce_ifvariable[pollclicked][!=][1][1 3] (change the 3 to hit the last onvaraiblefalse/onvariabletrue line)
onvariabletrue>client>centerprint[<color:ffffff>You already voted.]
onvariablefalse>client>vce_modvariable[pollclicked][set][1]
onvariablefalse>self>incrimentPrintCount[1]

With no luck? It's just saying You already voted.

I tried making another brick with
Code: [Select]
OnActivate>Client>VCE_ModVariable[pollclicked][set][0]

To try and reset my Variable, with no luck either. any ideas?

== is equals
!= is not equals
What exactly does != mean? I tried it with ==. What I tried was:

OnActivate>Client>VCE_ifVariable>[pollclicked][==][0][1 3]
OnVariableTrue>Client>VCE_ModVariable[pollclicked][set][1]
OnVariableFalse>Client>VCE_ModVariable[pollclicked][set][0]


And the rest, under that...
that would let you vote every other click
also, forgot that the true/falses should be flipped (trues should be false, falses should be true), or flip the != to be ==, sorry

Thank you so much, so what that means is;

Line 1: If the Variable "pollvoted" is NOT 1; it sends it to line 3&4(OnVariableFalse) But if it IS, it sends it to Line 2(OnVariableTrue)

Line 2: If the Variable is true(Not 1) it sends a message saying you've already voted.

Line 3&4: If the Variable is false(1) it incrementsPrintCount by [1] AND sets the Variable to 1, therefore next time you click, the Variable is already 1, meaning it would send it straight to OnVariableTrue(Line 2)... Saying you've already voted?

Sorry, I like to understand how events work, and not just know the lines to make them work. :)

line numbers start at 0

line 0 checks if pollclicked is 1
line 1 returns true and centerprints that you have clicked
line 2 returns false and sets pollclicked to 1, signifying that you have clicked it
line 3 returns false and incriments the print count
(based on what i said, with != flipped to ==)
Sorry, I like to understand how events work, and not just know the lines to make them work. :)
good, then you might not need help later, if you understand it all

line numbers start at 0

line 0 checks if pollclicked is 1
line 1 returns true and centerprints that you have clicked
line 2 returns false and sets pollclicked to 1, signifying that you have clicked it
line 3 returns false and incriments the print count
(based on what i said, with != flipped to ==)good, then you might not need help later, if you understand it all

I see now, I've just made a kickass voting build in my house, on my server. So I can just see what players think of it' using onVariableFalse>Self>PromtClient... :) It works like a charm, thank you.