Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-09-2007, 08:20 PM
Shakaraja Shakaraja is offline
Developer In Practice
Join Date: Oct 2007
Location: netherlands
Posts: 29
Shakaraja is on a distinguished road
keeping a var forever?

well i tried something and im new to this scripting stuff
but i kinda suck at this.. anyway i really need help on this:
(deleted the doing stuff xD)

PHP Code:
function onCreated()
  {
  
ShowStart();
  
ap 100;
  
dir 2;
  
setTimer(0.05);
}
function 
onPlayerchats()
  {
  function 
onActionLeftMouse()
    {
    if (
player.account == "Shakaraja" || player.account == "Graal685799" || player.account == "DarknessShadow" && player.chat.starts("/statue"))
      {
do 
stuff;
    }
  }
  elseif (
player.chat == "/clear")
    {
    function 
onActionLeftMouse() {
      if (
player.account == "Shakaraja" || player.account == "Graal685799" || player.account == "DarknessShadow" && player.chat == "/clear")
        {
        
ShowStart();
        
setTimer(0.05);
      }
    }
  }
}
function 
onTimeout()
  {
  if (
this.bla != "")
    {
    
with(findplayer(this.bla))
      {
setstring stuff;
addstring stuff (as this.bla)
    }
show stuff;
  }
  else
    {
    
ShowStart();
  }
  
setTimer(0.05);
}
function 
ShowStart(){
some more stuff xD;

i want it to keep the var forever. that it keeps showing.
because when i say update level or the NPC server restarts/resets
the var will be gone and everything will back to normal
this is in a statue case.

Last edited by Shakaraja; 11-09-2007 at 08:22 PM.. Reason: forgot something xD
Reply With Quote
  #2  
Old 11-09-2007, 09:42 PM
Rapidwolve24 Rapidwolve24 is offline
North*
Join Date: Oct 2007
Location: Massachusetts
Posts: 178
Rapidwolve24 is on a distinguished road
Send a message via AIM to Rapidwolve24 Send a message via MSN to Rapidwolve24
I highly suggest you visit the GScript wiki.
Reply With Quote
  #3  
Old 11-09-2007, 10:23 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
You didn't even separate client side from server side.
And you're using some GS1 commands (addstring)...
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 11-09-2007, 10:32 PM
Shakaraja Shakaraja is offline
Developer In Practice
Join Date: Oct 2007
Location: netherlands
Posts: 29
Shakaraja is on a distinguished road
yes but, i cant find it there
Reply With Quote
  #5  
Old 11-09-2007, 10:33 PM
Shakaraja Shakaraja is offline
Developer In Practice
Join Date: Oct 2007
Location: netherlands
Posts: 29
Shakaraja is on a distinguished road
How do i use Addstring as GS2?
its long b4 i scripted about 3 years ago x.X
Reply With Quote
  #6  
Old 11-09-2007, 10:44 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
You might want to just re-set the var in the onCreated event if possible. I'm not sure what types of vars survive NPCServer resets. I suspect server/serverr vars would but you don't want to use those unless you have to. You might want to have a dbnpc (do dbnpc vars survive NPCServer restarts?) that stores vars like this or use a text file.
__________________
Reply With Quote
  #7  
Old 11-09-2007, 11:09 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
Store the variable in a DB NPC or a text file.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #8  
Old 11-10-2007, 12:09 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
You do not define functions inside other functions -.-

You don't use setstring or addstring in GS2.
PHP Code:
//GS1
setstring this.string,This is a String;
setstring this.array,This,is,a,String,Array;
addstring this.array,I am adding this;
//GS2
this.string "This is a String";
this.array = {"This""is""a""String""Array"};
this.array.add("I'm adding this"); 
__________________
Reply With Quote
  #9  
Old 11-10-2007, 01:48 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
Also, functions cannot be inside other functions.
__________________
Trying to be nice now...
Reply With Quote
  #10  
Old 11-10-2007, 12:13 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
You should try to learn the basics about how Functions, Variables, and Objects work in relation to each-other, such concepts apply to many other languages besides GScript.
__________________
Reply With Quote
  #11  
Old 11-10-2007, 04:33 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
You should use an event inside of the function to replicate what you're trying to do.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #12  
Old 11-10-2007, 08:07 PM
Shakaraja Shakaraja is offline
Developer In Practice
Join Date: Oct 2007
Location: netherlands
Posts: 29
Shakaraja is on a distinguished road
oh i get it thanks guys
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:57 AM.


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