ATM Machine - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Help (/Forum-Script-Help) +--- Thread: ATM Machine (/Thread-ATM-Machine) |
ATM Machine - Eduardo - 10-04-2013 08:32 AM 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 // RE: ATM Machine - darksun84 - 10-04-2013 08:55 AM 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 RE: ATM Machine - RanXerox - 10-04-2013 08:56 AM There are so many things wrong with this I don't know where to begin lol. RE: ATM Machine - Eduardo - 10-04-2013 08:59 AM so can you help me fix it ? =P RE: ATM Machine - Mordaunt - 10-04-2013 09:03 AM 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 RE: ATM Machine - Rattlehead - 10-04-2013 09:15 AM 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. RE: ATM Machine - RanXerox - 10-04-2013 09:28 AM 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 :-) RE: ATM Machine - darksun84 - 10-04-2013 09:30 AM and more3 doesn't exist ! RE: ATM Machine - Rattlehead - 10-04-2013 11:34 AM 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) |