Graal Forums

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

[email protected] 01-12-2009 08:08 PM

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

Codein 01-12-2009 08:20 PM

Quote:

Originally Posted by [email protected] (Post 1456521)
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 :(

xXziroXx 01-12-2009 08:21 PM

Quote:

Originally Posted by [email protected] (Post 1456521)
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.

[email protected] 01-12-2009 08:24 PM

So this should fix the problem?

[email protected] 01-12-2009 08:29 PM

Could I use a class and join the script?

Example

join safe;

Codein 01-12-2009 08:40 PM

Quote:

Originally Posted by [email protected] (Post 1456526)
Could I use a class and join the script?

Example

join safe;

To a DB NPC, yeah.

Pelikano 01-12-2009 09:59 PM

You could also just use putnpc2 and then your this.vars won't reset anymore.

xXziroXx 01-12-2009 11:01 PM

Quote:

Originally Posted by Pelikano (Post 1456553)
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.

Tigairius 01-12-2009 11:38 PM

Quote:

Originally Posted by xXziroXx (Post 1456566)
What a great idea!

Meh, give the man props for originality.


All times are GMT +2. The time now is 10:03 AM.

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