Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   keeping a var forever? (https://forums.graalonline.com/forums/showthread.php?t=77501)

Shakaraja 11-09-2007 08:20 PM

keeping a var forever?
 
well i tried something and im new to this scripting stuff :p
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.

Rapidwolve24 11-09-2007 09:42 PM

I highly suggest you visit the GScript wiki.

Switch 11-09-2007 10:23 PM

You didn't even separate client side from server side.
And you're using some GS1 commands (addstring)...

Shakaraja 11-09-2007 10:32 PM

:cry::cry:yes but, i cant find it there :cry::cry:

Shakaraja 11-09-2007 10:33 PM

How do i use Addstring as GS2?
its long b4 i scripted about 3 years ago x.X

Googi 11-09-2007 10:44 PM

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.

Tigairius 11-09-2007 11:09 PM

Store the variable in a DB NPC or a text file.

Inverness 11-10-2007 12:09 AM

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"); 


bscharff 11-10-2007 01:48 AM

Also, functions cannot be inside other functions.

Inverness 11-10-2007 12:13 PM

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.

Tigairius 11-10-2007 04:33 PM

You should use an event inside of the function to replicate what you're trying to do.

Shakaraja 11-10-2007 08:07 PM

oh i get it thanks guys


All times are GMT +2. The time now is 11:40 PM.

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