Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ATM Machine
Author Message
Eduardo
Apprentice
*

Posts: 6
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Sep 2013
Reputation: 0



Post: #1
ATM Machine
Hi guys,

I'm having some troubles with my atm machine. if i put in <ARGS> a value like 1111111111 it deposites that amount of gold even if i don't have it and I have this exception:

IF <ARGS> > 50000
SRC.SYSMESSAGE Your maximum deposite is 50000 gps.
Return 1


The script is:

Code:
// First you must put 'i_bank_mem' somehow   //
// on the player for example in skillclass:  //

//ON=@LOGIN                                
// IF !<findid(i_bank_mem)>                  //
// NEWITEM i_bank_mem                        //
// SRC.ACT.EQUIP                             //
// ENDIF                                     //


[ITEMDEF i_bank_mem]
ID=i_memory
NAME=custom bank
TYPE=T_EQ_SCRIPT
LAYER=30

ON=@CREATE
MORE=//Gold amount stores here (in case You want to put starting money or other)
MOREY=//Last amount taken from the bank
MOREX=//Last amount deposited to the bank
MORE2=//The highest amount been in the bank
MORE3=10


[FUNCTION withdraw]
SRC.ACT=<findid(i_bank_mem).uid>
IF <ARGS> > 50000
SRC.SYSMESSAGE Your maximum withdraw is 50000 gps.
Return 1
ELSE
IF <ARGS> > <SRC.ACT.MORE>
SRC.SYSMESSAGE You don't have that much money!
ELSE
SRC.ACT.MORE=<SRC.ACT.MORE>+-<ARGS>
SRC.ACT.MOREY=<ARGS>
SRC.NEWITEM i_gold
NEW.AMOUNT <ARGS>
NEW.BOUNCE
IF <ARGS> <= 1
SRC.SYSMESSAGE You withdraw <ARGS> gp from the ATM.
ELSE
SRC.SYSMESSAGE You withdraw <ARGS> gps from the ATM.
ENDIF
ENDIF

[FUNCTION deposite]
SRC.ACT=<findid(i_bank_mem).uid>
IF <ARGS> > 50000
SRC.SYSMESSAGE Your maximum deposite is 50000 gps.
Return 1
ELSE
IF !(<RESTEST i_gold <ARGS>>)
SRC.SYSMESSAGE You don't have that much money!
ELSE
IF <ARGS>+<SRC.ACT.MORE> > <SRC.ACT.MORE2>
SRC.TAG.MOST=<ARGS>+<SRC.ACT.MORE>
SRC.ACT.MORE2=<SRC.TAG.MOST>
SRC.TAG.MOST=
ENDIF
SRC.ACT.MORE=<SRC.ACT.MORE>+<ARGS>
SRC.ACT.MOREX=<ARGS>
SRC.CONSUME i_gold <ARGS>
SRC.SOUND 50
IF <ARGS> <= 1
SRC.SYSMESSAGE You deposite <ARGS> gp to the ATM.
ELSE
SRC.SYSMESSAGE You deposite <ARGS> gps to the ATM.
ENDIF
ENDIF


[DIALOG d_bank]
0,0
PAGE 0
RESIZEPIC 200 200 3500 400 300
PAGE 1
GUMPPIC 340 370 0988
GUMPPIC 340 400 0988
DTEXT 220 220 03f <var.blankline>
DTEXT 220 220 03f <SRC.NAME>'s Automated Teller Machine
DTEXT 250 270 03f Gold In ATM: <eval(<src.findid(i_bank_mem).more>)>
DTEXT 250 310 03f Most Gold In ATM: <eval(<src.findid(i_bank_mem).more2>)>
DTEXT 250 370 03f Withdraw:
TEXTENTRY 356 375 600 20 1152 1 0
DTEXT 250 400 03f Deposite:
TEXTENTRY 356 403 600 20 1152 2 0
BUTTON 380 450 047f 0480 1 0 0
BUTTON 510 375 04b9 04ba 1 0 1
BUTTON 510 405 04b9 04ba 1 0 2


[DIALOG d_bank TEXT]

[DIALOG d_bank BUTTON]
ONBUTTON=1
SRC.WITHDRAW <ARGTXT[1]>
ONBUTTON=2
SRC.DEPOSITE <ARGTXT[2]>
(This post was last modified: 10-04-2013 08:54 AM by Mordaunt.)
10-04-2013 08:32 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: ATM Machine
in the deposit function there are 4 IF but only 3 endif, while in the withdraw function there are 3 IF but only 2 endif.

Probably caused by bad indention Tongue
10-04-2013 08:55 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #3
RE: ATM Machine
There are so many things wrong with this I don't know where to begin lol.
10-04-2013 08:56 AM
Find all posts by this user Like Post Quote this message in a reply
Eduardo
Apprentice
*

Posts: 6
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Sep 2013
Reputation: 0



Post: #4
RE: ATM Machine
so can you help me fix it ? =P
10-04-2013 08:59 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #5
RE: ATM Machine
First of all, lose the memory item, you really don't need it. If you want to store such information, store it on the player in tags, it'll be simpler.

Secondly, don't use VARs, they are global and can be messed up if someone else is performing the same funtion at the same time.
I see this one is VAR.blankline, there is no purpose in it as far as I can make out, just remove it.

Thirdly, never set anything as SRC.ACT, it's liable to get messed up during the process, if it is a UID store it as REF1

[Image: 2nis46r.jpg]
10-04-2013 09:03 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #6
RE: ATM Machine
apparently this is an old 55i script, that someone attempted to bring up to date adn failed bad

the var.blankline was to insert a blank line in the dialog?? redundant as you can just step down the text instead

the whole script is bad, i dont get the point of it either when u already have a bank with gold.

[Image: matts_siggy.gif]
10-04-2013 09:15 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #7
RE: ATM Machine
1. ARGS allows the use of strings... maybe use ARGN to force only numbers. Either that or validate that only numbers were entered.

2. There are limits to the biggest number you can store in MORE1 and MORE2 ... your deposit and withdraw functions need to accomodate those limits. Also, the limits for MOREX and MOREY are a potential problem as well.

3. Your script is not properly testing for negative numbers (what happens when someone deposits -50000 or withdraws -50000)... This is due to bad logic (too many IFs and not enough ENDIFs and/or they are in the wrong order. My suggestion is put all the failure conditions in their own IF/ENDIF section at the top of your function.

4. As a general rule, SRC.NEWITEM is bad form, always use SERV.NEWITEM or run the risk of an invalid reference.

5. SRC.ACT.anything makes no sense... by doing this you are chaining references and run the risk of invalid objects breaking your command. Also, it is possible to exploit scripts that rely on SRC.ACT to modify other objects... for example, I could exploit your script to give myself a +50 magic sword... or I could exploit it by emptying the bank of someone standing next to me!

6. Be careful with things like this: IF <ARGS>+<SRC.ACT.MORE> ...because if <ARGS> is a string (which I mentioned earlier is possible) you are literally putting a plus sign at the end of it followed by the value of <SRC.ACT.MORE> (which, because its exploitable, might come from my new magic sword's MORE value... not your bank memory object.) The solution is to force it to be mathamatically considered by putting the condition in () marks or <EVAL >

7. There is no need to add negative numbers like this: SRC.ACT.MORE=<SRC.ACT.MORE>+-<ARGS> ... just subtract directly like this: SRC.MORE -= <ARGN>

8. Don't overload ACT... it is there for built-in actions of the core system... instead, do this: REF1=<findid(i_bank_mem).uid>

9. Deposit does not have a trailing e

:-)
10-04-2013 09:28 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #8
RE: ATM Machine
and more3 doesn't exist !
10-04-2013 09:30 AM
Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #9
RE: ATM Machine
i lol'd at #9 so hard it made my eyes water. (only becus of the 8 b4 that had nothing at all to do with 9)

[Image: matts_siggy.gif]
10-04-2013 11:34 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)