Author Topic: Saving bought items from a minigame after respawning.  (Read 797 times)

Basically what I'm trying to do is make any item a player has bought in a minigame stay with them after they respawn.

I host a dodgeball server and players are always complaining that their dodgeballs/other items they have bought don't stay with them after they respawn.

Are there any add-ons I can get to help out with this, and if not is this even possible with eventing or other stuff?

Hey, I played on you server and owned everyone, until I kept buying gold balls, which reduced my score.

Ok, here is what you need:

-VCE

That's it.

Here are the events that go on the white ball's selection brick.

Code: [Select]
[0] [Onactivate] [Client] [VCE_Ifvariable] [White] [==] [1] [1 3]
[1] [Onvariabletrue] [Player] [Clearitems]
[2] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[3] [Onvariablefalse] [Self] [VCE_Ifvalue] [<var:cl:score>] [>=] [5] [4 8]
[4] [Onvariabletrue] [Client] [VCE_Modvariable] [Score] [Subtract] [5]
[5] [Onvariabletrue] [Client] [VCE_Modvariable] [White] [Set] [1]
[6] [Onvariabletrue] [Player] [Clearitems]
[7] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[8] [Onvariablefalse] [Client] [Centerprint] [You don't have enough money] [3]

I'm basing this off the format you did in your game.  Tell me if anything goes wrong, I did this off the top of my head.

Hey, I played on you server and owned everyone, until I kept buying gold balls, which reduced my score.

Ok, here is what you need:

-VCE

That's it.

Here are the events that go on the white ball's selection brick.

Code: [Select]
[0] [Onactivate] [Client] [VCE_Ifvariable] [White] [==] [1] [1 3]
[1] [Onvariabletrue] [Player] [Clearitems]
[2] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[3] [Onvariablefalse] [Self] [VCE_Ifvalue] [<var:cl:score>] [>=] [5] [4 8]
[4] [Onvariabletrue] [Client] [VCE_Modvariable] [Score] [Subtract] [5]
[5] [Onvariabletrue] [Client] [VCE_Modvariable] [White] [Set] [1]
[6] [Onvariabletrue] [Player] [Clearitems]
[7] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[8] [Onvariablefalse] [Client] [Centerprint] [You don't have enough money] [3]

I'm basing this off the format you did in your game.  Tell me if anything goes wrong, I did this off the top of my head.

Alright thanks! I'll try this right now with the results.

Hmm, it didn't work. I copied the events exactly how you said but it only shows the error message "You don't have enough money" even if i have over the amount needed to buy the item.

Hmm, it didn't work. I copied the events exactly how you said but it only shows the error message "You don't have enough money" even if i have over the amount needed to buy the item.

I don't see anything I wrote, other than the revision I made below, that would result in your issue.  Some common mistakes people make in copying down events are; when writing values, like <var:cl:score>, they forget to use these symbols "< > :".  Also, VCE_Ifvalue and VCE_Ifvariable can be easily mixed up, so check that.  Another thing easily done wrong are the ranges of the VCE_Ifvariables- make sure there is the starting event number, followed by a space, then the ending event line number, like so [3 5].  The last common thing is forgetting to change [==] to [>=] wherever it is needed.  This will mess it up if your score is above 5.  Go back over the events thoroughly and check for any of these errors.  If it still doesn't work, then post a picture of the events and I can check if there is anything wrong there.


The revision I mentioned earlier was that you should replace line 4 with [incscore] instead of [modvar] [score].  There are sometimes issues with modifying a variable replacer.  Also, how practiced are you with VCE?  I want to know how much I need to explain if any further issues arise.

(1)
Code: [Select]
[0] [Onactivate] [Client] [VCE_Ifvariable] [White] [==] [1] [1 3]
[1] [Onvariabletrue] [Player] [Clearitems]
[2] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[3] [Onvariablefalse] [Self] [VCE_Ifvalue] [<var:cl:score>] [>=] [5] [4 8]
[4] [Onvariabletrue] [Client] [incscore] [-5]
[5] [Onvariabletrue] [Client] [VCE_Modvariable] [White] [Set] [1]
[6] [Onvariabletrue] [Player] [Clearitems]
[7] [Onvariabletrue] [Player] [Additem] [Dodgeball White]
[8] [Onvariablefalse] [Client] [Centerprint] [You don't have enough money] [3]