Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-30-2005, 08:50 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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;
}

Reply With Quote
  #2  
Old 12-30-2005, 09:02 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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?
__________________
Reply With Quote
  #3  
Old 12-30-2005, 09:05 PM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
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.
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
  #4  
Old 12-30-2005, 09:22 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Make it a serverside script.
Reply With Quote
  #5  
Old 12-30-2005, 09:50 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
<_< 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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #6  
Old 12-30-2005, 10:00 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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

Reply With Quote
  #7  
Old 12-30-2005, 10:04 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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
__________________
Reply With Quote
  #8  
Old 12-30-2005, 10:06 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
like i said, not full scripts XD yeah i uploaded that bug too anyway, i'm wondering if the serverside version i posted will work as well, so i can upload it and fix it XD
Reply With Quote
  #9  
Old 12-30-2005, 10:28 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to 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.
  • 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).
__________________
Skyld
Reply With Quote
  #10  
Old 12-30-2005, 10:35 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
at least the format was better?
Reply With Quote
  #11  
Old 12-30-2005, 10:36 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
at least the format was better?
It's improving, for sure.
__________________
Skyld
Reply With Quote
  #12  
Old 12-30-2005, 11:12 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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!
Reply With Quote
  #13  
Old 12-30-2005, 11:36 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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?
__________________
Skyld
Reply With Quote
  #14  
Old 12-30-2005, 11:42 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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?
Reply With Quote
  #15  
Old 12-31-2005, 01:30 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
awww i changed it already oh well, works fine either way for what i wanted it for
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:39 PM.


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