HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A Banking Trigger

06-08-2004, 01:51 AM#1
IronGauntlet
I need help with a banking trigger. I need the trigger to be able to withdraw any given amount of money that the user specifies from his/her bank account in the game and add that same amount to their gold. Is this possible to do with 1 trigger or will I have to make 500 different triggers, each saying a different integer?

I have a bank because it doesn't seem logical for 1 hero to be able to carry around 10000 gold coins and still be able to fight anything. All that money would weigh him down.
06-08-2004, 02:18 AM#2
Bulletcatcher
I'm just writing this from what I remember, some errors might exist.

Needs two variables:
One array of integers: bank[1...number of players]. This holds the money information.

One array of units: hero[1...number of players]. Create a trigger to set the variable to the proper unit when a player selects their hero.

Regions where bank actions are allowed would be 'Bank1', 'Bank2', etc.

One:
Code:
Triggers:
Player 1 types a chat string containing "-withdraw" as a substring.
Player 2 types a chat string containing "-withdraw" as a substring.
etc..., for all players

Conditions:
Bank[Player number of (Triggering player)] greater than or equal to (s2i(substring(Entered chat string,11,100)))
Or, multiple conditions:
Hero[Player number of (Triggering player)] is in region Bank1
Hero[Player number of (Triggering player)] is in region Bank2
Hero[Player number of (Triggering player)] is in region Bank3
and so on, for however many banks you have.

Actions:
Set Bank[Player number of (Triggering player)] = (Bank[Player number of (Triggering player)] - s2i(substring(Entered chat string,11,100)))
Set (Triggering player) gold equal to (Gold of (Triggering player)) + s2i(substring(Entered chat string,11,100))
Display text message to (Triggering player): "Withdrew " + s2i(substring(Entered chat string,11,100)) + " gold."
Two:
Code:
Triggers:
Player 1 types a chat string containing "-deposit" as a substring.
Player 2 types a chat string containing "-deposit" as a substring.
etc..., for all players

Conditions:
Gold of (Triggering player) greater than or equal to (s2i(substring(Entered chat string,10,100)))
Or, multiple conditions:
Hero[Player number of (Triggering player)] is in region Bank1
Hero[Player number of (Triggering player)] is in region Bank2
Hero[Player number of (Triggering player)] is in region Bank3
and so on, for however many banks you have.

Actions:
Set (Triggering player) gold equal to (Gold of (Triggering player)) - s2i(substring(Entered chat string,10,100))
Set Bank[Player number of (Triggering player)] = (Bank[Player number of (Triggering player)] + s2i(substring(Entered chat string,10,100)))
Display text message to (Triggering player): "Deposited " + s2i(substring(Entered chat string,10,100)) + " gold."

Oh, and one more:

Code:
Triggers:
Player 1 types a chat string containing "-bank" as an exact match.
Player 2 types a chat string containing "-bank" as an exact match.
etc..., for all players

Conditions:
none

Actions:
if bank[number of (triggering player)] is less than or equal to 0 then
  Display text message to (triggering player): "You don't have any money in the bank."
else
  Display text message to (triggering player): "Your account balance is currently " + string(bank[number of (triggering player)]) + " gold."
endif
Display text message to (triggering player): "To deposit gold into the bank, type:
-deposit <gold amount>
when near a bank. To withdraw gold from the bank, type:
-withdraw <gold amount>
when near a bank.
"

06-08-2004, 11:50 AM#3
IronGauntlet
Can you tell me which conditions and actions these are?

Conditions:
Bank[Player number of (Triggering player)] greater than or equal to (s2i(substring(Entered chat string,11,100)))

Actions:
Set Bank[Player number of (triggering player)] = (Bank[player number of(triggering player)] – s2i(substring(entered chat string,11,100)))
06-08-2004, 12:18 PM#4
IronGauntlet
s2i? what is that?
06-09-2004, 01:52 PM#5
AntJAB
Quote:
Set Bank[Player number of (triggering player)] = (Bank[player number of(triggering player)] – s2i(substring(entered chat string,11,100)))

This I actualy just figured out from reading this, as I never used player typed controlls before, but here I go:

Set Bank[Player number of (triggering player)] =
This is saying to set the Bank variable of that current player to equal something.

(Bank[player number of(triggering player)] –
This is saying to take the current ammount of the player's Bank and subtract from it.

s2i(substring(entered chat string,11,100)))
Here is what you are asking... s2i I am not sure about, however for your case it doesn't seem important. The 11 is the begining of the chat string that it will look for the numbers, and it goes up to (or stops looking for the number at) 100.

If you want to withdraw 400 gold:
-_w_i_ t_h_d_r_a_w_[space]_4__0__0
1_2_3_4_5_6_7_8_9___10___11_12_13
The gold ammount begins on character 11.

Hope that helps!