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 01-12-2009, 08:08 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Wink My Scripting Problem.

Hello, I am working on a Shop Safe Script and it functions perfectly, but when you update the level or edit it with graal editor, it resets automatically to 0. I Need some help on this please for all you excellent scripters out there.

Here is the script.

//Scripted By Jamerson61894!
if (created) {
}
if (playertouchsme) {
}
if (playerchats && strcontains(#c,/deposit)){
tokenize #c;
this.rupeeadd = strtofloat(#t(1));
if (playerrupees >= this.rupeeadd){
if (this.rupeeadd > 0){
playerrupees -= this.rupeeadd;
this.safemoney += this.rupeeadd;
setcharprop #c,#v(this.safemoney) dollars in safe!;
}
}
}

if (playerchats && strcontains(#c,/withdraw)){
tokenize #c;
this.takemoney = strtofloat(#t(1));
if (this.safemoney >= this.takemoney){
if (this.takemoney > 0){
if (strequals(#a,GULTHEX)){

playerrupees += this.takemoney;
this.safemoney -= this.takemoney;
setplayerprop #c, Took #v(this.takemoney) dollars out of safe!;
setcharprop #c, #v(this.safemoney) dollars in safe!
}
}
}
}
if (playerchats && strcontains(#c,/balance)){
tokenize #c;
setcharprop #c, #v(this.safemoney) dollars in safe!
}
if (timeout){
setcharprop #c, ;}



If you could help me fix the problem with the update level part, I would be most greatful.

Thanks,

-Jamerson61894
Reply With Quote
  #2  
Old 01-12-2009, 08:20 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by [email protected] View Post
stuff
-Jamerson61894
You have to use a DB NPC for it save. Basically, using NC, create NPC in the same position where this script is, and copy and paste the script inside it. Then delete level NPC.

I don't really like how you've combined events and flags. I think that's a bit of a taboo and shouldn't be done. Do this:

HTML Code:
if (playerchats) {
	tokenize #c;
	
	if (strcontains(#c,/withdraw)) {
		this.takemoney = strtofloat(#t(1));
		if (this.safemoney >= this.takemoney){
			if (this.takemoney > 0){
				if (strequals(#a,GULTHEX)){
					playerrupees += this.takemoney;
					this.safemoney -= this.takemoney;
					setplayerprop #c, Took #v(this.takemoney) dollars out of safe!;
					setcharprop #c, #v(this.safemoney) dollars in safe!
	            }
			}
		}
	}
	
	elseif (strcontains(#c, /deposit)) {
		this.rupeeadd = strtofloat(#t(1));
		if (playerrupees >= this.rupeeadd){
			if (this.rupeeadd > 0){
				playerrupees -= this.rupeeadd;
				this.safemoney += this.rupeeadd;
				setcharprop #c,#v(this.safemoney) dollars in safe!;
			}
		}
	}
	
	elseif (strcontains(#c, /balance)) {
		setcharprop #c, #v(this.safemoney) dollars in safe!
	}
}

if (timeout){
  setcharprop #c, ;
}
Also, try learning GS2
Reply With Quote
  #3  
Old 01-12-2009, 08:21 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by [email protected] View Post
Hello, I am working on a Shop Safe Script and it functions perfectly, but when you update the level or edit it with graal editor, it resets automatically to 0.
As Codein said, store the data in Database NPC's or serverr. flags, the first being recommended. And you can't save data in the Graal Editor.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #4  
Old 01-12-2009, 08:24 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
So this should fix the problem?
Reply With Quote
  #5  
Old 01-12-2009, 08:29 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Could I use a class and join the script?

Example

join safe;
Reply With Quote
  #6  
Old 01-12-2009, 08:40 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by [email protected] View Post
Could I use a class and join the script?

Example

join safe;
To a DB NPC, yeah.
Reply With Quote
  #7  
Old 01-12-2009, 09:59 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
You could also just use putnpc2 and then your this.vars won't reset anymore.
Reply With Quote
  #8  
Old 01-12-2009, 11:01 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Pelikano View Post
You could also just use putnpc2 and then your this.vars won't reset anymore.
What a great idea!

Quote:
Originally Posted by Newly Hired NAT
/clearnpcs levelname.nw
Oops, I just deleted all NPC's in that level.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #9  
Old 01-12-2009, 11:38 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by xXziroXx View Post
What a great idea!
Meh, give the man props for originality.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
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 05:11 AM.


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