Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Bank? (https://forums.graalonline.com/forums/showthread.php?t=63091)

excaliber7388 12-30-2005 08:50 PM

Bank?
 
This script works fine offline, however online you can only deposit or withdrawl in multiples if 5 if you say deposit 10 you deposit 50 ext. why would it do that?
NPC Code:
if(created)
{
setshape 1,64,32;
}
if(actionmoney)
{
if(strequals(#p(0),deposit))
{
setstring clientr.balance,#v(strtofloat(#s(clientr.balance)) +strtofloat(#s(client.deposit)));
playerrupees=playerrupees-strtofloat(#s(client.deposit));
setplayerprop #c,Deposited #s(client.deposit);
}
if(strequals(#p(0),withdraw))
{
setstring clientr.balance,#v(strtofloat(#s(clientr.balance))-strtofloat(#s(client.withdraw)));
playerrupees=playerrupees+strtofloat(#s(client.wit hdraw));
setplayerprop #c,Withdrew #s(client.withdraw);
}
}
//#CLIENTSIDE
if(playerchats)
{
if(strequals(#c,balance))
{
setplayerprop #c,Balance: #s(clientr.balance);
}
if(startswith(deposit,#c))
{
setstring client.deposit,#T(#e(7,-1,#c));
if(playerrupees>=strtofloat(#s(client.deposit)))
{
triggeraction x,y,money,deposit;
}
}
if(startswith(withdraw,#c))
{
setstring client.withdraw,#T(#e(9,-1,#c));
if(strtofloat(#s(client.withdraw))<=strtofloat(#s( clientr.balance)))
{
triggeraction x,y,money,withdraw;
}
}
}
if(playertouchsme)
{
say2 Banking commangs:#b
deposit amount#b
withdraw amount#b
balance-check balance;
}


ZeLpH_MyStiK 12-30-2005 09:02 PM

I laugh at your completely insecure bank and how many people will rob it.

Anyways, back on topic:
Exactly how many instances of the script do you have on the level? 5?

Maniaman 12-30-2005 09:05 PM

That is horribly insecure :(

ShadowBlaze/Zelph_Mystik is right. You probably have multiple instances of the NPC in the level, which is why it is doing it multiple times.

Lance 12-30-2005 09:22 PM

Make it a serverside script.

ApothiX 12-30-2005 09:50 PM

<_< Didn't people just tell you not to post full scripts, in the other thread? You really should learn how to read/understand what people tell you.

excaliber7388 12-30-2005 10:00 PM

and how would i get help without a full script posted? anyway, il;l cut some out of this then :P
NPC Code:
if(created)
{
setshape 1,64,32;
}

if(playerchats)
{
if(strequals(#c,balance))
{
setplayerprop #c,Balance: #s(clientr.balance);
}
if(startswith(deposit,#c))
{
setstring clientr.deposit,#T(#e(7,-1,#c));
if(playerrupees>=strtofloat(#s(clientr.deposit)))
{
setstring clientr.balance,#v(strtofloat(#s(clientr.balance)) +strtofloat(#s(clientr.deposit)));
playerrupees=playerrupees-strtofloat(#s(clientr.deposit));
setplayerprop #c,Deposited #s(clientr.deposit);
}
}
if(startswith(withdraw,#c))
{
setstring clientr.withdraw,#T(#e(9,-1,#c));
if(strtofloat(#s(clientr.withdraw))<=strtofloat(#s (clientr.balance)))
{
setstring clientr.balance,#v(strtofloat(#s(clientr.balance))-strtofloat(#s(clientr.withdraw)));
playerrupees=playerrupees+strtofloat(#s(clientr.wi thdraw));
setplayerprop #c,Withdrew #s(clientr.withdraw);
}
}
}
//some stuff removed here ;)


ZeLpH_MyStiK 12-30-2005 10:04 PM

I love how i can withdraw -10000000, and since my gralat count cant go into the negatives when you subtract the 10000000, it allows me to withdraw 10000000 back out as real money. =D

excaliber7388 12-30-2005 10:06 PM

like i said, not full scripts XD yeah i uploaded that bug too x_x anyway, i'm wondering if the serverside version i posted will work as well, so i can upload it and fix it XD

Skyld 12-30-2005 10:28 PM

Hey, look!
  • Tokenize the chat text (#c) before you check startswith(), that way you can jump into strequals(#t(0),foo)) and work with strtofloat(#t(1)) or whatever.
  • Stop using playerrupees = playerrupees... and start using playerrupees +=, etc.
  • Make sure that any amounts given to the bank script are above 0. We don't want negative values, now, do we?
  • Stop setting unnecessary client strings (i.e. clientr.deposit).

excaliber7388 12-30-2005 10:35 PM

at least the format was better? ;)

Skyld 12-30-2005 10:36 PM

Quote:

Originally Posted by excaliber7388
at least the format was better? ;)

It's improving, for sure.

Lance 12-30-2005 11:12 PM

Quote:

Originally Posted by Skyld
Hey, look!
  • Tokenize the chat text (#c) before you check startswith(), that way you can jump into strequals(#t(0),foo)) and work with strtofloat(#t(1)) or whatever.

Yes, let's tokenize everything the player says regardless of whether or not we will actually be checking more than the first word! This is a good idea!

Skyld 12-30-2005 11:36 PM

Quote:

Originally Posted by Lance
Yes, let's tokenize everything the player says regardless of whether or not we will actually be checking more than the first word! This is a good idea!

Do you not see sense in having two tokens, instead of checking the entire chat text and then finding substrings and trimming that, especially when here you only expect at most two tokens?

Lance 12-30-2005 11:42 PM

Quote:

Originally Posted by Skyld
Do you not see sense in having two tokens, instead of checking the entire chat text and then finding substrings and trimming that, especially when here you only expect at most two tokens?

You're missing the point.

If I have an exciting conversation with you about Yu-Gi-Oh and its awesomeness in this theoretical tokenize-just-inside-the-playerchats-event bank level, it would be tokenizing everything you and I said in addition to performing all of those if-checks on our chat text.

How is that superior to only having the relevant if-checks?

excaliber7388 12-31-2005 01:30 AM

awww i changed it already :D oh well, works fine either way for what i wanted it for


All times are GMT +2. The time now is 05:20 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.