|
Neobane Newbie
Joined: 08 May 2002 Posts: 1 Location: USA
|
Posted: Wed May 08, 2002 9:09 am
Logging Database |
I'm trying to set up a database so that when someone donates money to my guild account, the time/date, name, amount, and balance is recorded in a database. My problem is that the script logs the transaction 3 times and I can't figure out why.
#CLASS {accounting}
#VAR Date {Wed May 8 05:01:48 2002}
#VAR Name {Frieya}
#VAR Amount {1000}
#VAR Balance {}
#TRIGGER {: (%1) has deposited (%2) gold in our account!} {
#var Date {} {_nodef} {accounting}
#var Name {} {_nodef} {accounting}
#var Amount {} {_nodef} {accounting}
#var Balance {} {_nodef} {accounting}
Name={%1}
Amount={%2}
Time
Balance Guild
}
#TRIGGER {The system time ~(E.S.T.~): (%1)$} {Date={%1}}
#TRIGGER {Your groups Current Balance: (%1) gold pieces.} {
Balance={%1}
say addtrans
}
#TRIGGER {addtrans} {
#DBLOAD dofaccount
#NEW ALL Date=@Date Name=@Name Amount=@Amount Balance=@Balance
say "Transaction Recorded"
}
#CLASS 0 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed May 08, 2002 2:51 pm |
I can't see any obvious reasons in the script you provided, so it's probably the result of other triggers you have.
Is there any particular reason you "say addtrans" and trigger on "addtrans" instead of just using an alias? Either way, it would probably be a good idea to add a control variable to the main trigger. As it is now, you'll add an entry to your database any time you check the balance whether someone donated or not.
LightBulb
Vague questions get vague answers |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed May 08, 2002 7:03 pm |
One other item: we discourage the use of %1, %2, etc in the trigger phrase, reserving them for the trigger action. In their place we use wildcards such as %w, %d, *, %a, %n, etc. in the trigger phrase and use parentheses around any portion of the phrase we want to refer to in the action. The first item in parentheses is then %1, the next is %2, etc. So in place of
#TRIGGER {: (%1) has deposited (%2) gold in our account!} {
#var Date {} {_nodef} {accounting}
#var Name {} {_nodef} {accounting}
#var Amount {} {_nodef} {accounting}
#var Balance {} {_nodef} {accounting}
Name={%1}
Amount={%2}
Time
Balance Guild
}
you'd have
#TRIGGER {: (%w) has deposited (%d) gold in our account!} {
#var Date {} {_nodef} {accounting}
#var Name {} {_nodef} {accounting}
#var Amount {} {_nodef} {accounting}
#var Balance {} {_nodef} {accounting}
Name={%1}
Amount={%2}
Time
Balance Guild
}
LightBulb
Vague questions get vague answers |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|