Jump to content

[HELP]Deposit/Withdraw


Recommended Posts

Hi! I made a Clan System, but i don't know how to make the deposit and withdraw. I made the GUI and Buttons, i only need how can i script this: Upper will show you the ammount in the Clan Safebox. when you press/select on "Deposit" you will need to enter an ammount to deposit. "Withdraw" button where you will withdraw money. Can someone help me? Thanks a lot!

Link to comment

You'll need to use addEventHandler for onClientGUIClick both the deposit and withdraw buttons. You'll want the handler functions each to call triggerServerEvent which would inform the server that a client wants to deposit or withdraw and the amount. Each of those events should also block both buttons from being pressed again until the balance updates. You also want to addEvent and addEventHandler for an event with a balance update from the server, and this event's handler function should update the displayed clan balance text label, and enable the deposit and withdraw buttons, which we previously disabled after the initial click.

Now, on the server side, you'll want to addEvent both events and mark them as remotely triggerable, then addEventHandler for each of those events and the handler functions should then verify whether the amount being withdrawn is not more than what the clan's account balance is, and that the deposit amount is not more than what the player has at hand. Additionally, and especially for the deposit amount, you want to make sure the number is greater than 0. After these verification, you'll want to addPlayerMoney or takePlayerMoney and update the clan's balance, which depends on how you store it. Then you should triggerClientEvent some update event to inform the client of the clan balance change. Considering you've implemented blocking of the deposit and withdraw buttons upon initial click, you'll want to send the update event even if balance transfers were not performed due to insufficient balances or what not, sending the unchanged balance, to unblock the deposit and withdraw buttons again on the client-side.

You can read more about GUI based client and server interactions on Introduction to Scripting the GUI › Scripting the button

Edited by Addlibs
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...