Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-28-2010, 09:20 PM
Liberated Liberated is offline
not doing alot
Liberated's Avatar
Join Date: Feb 2008
Posts: 1,366
Liberated has a spectacular aura about
My script isn't working, what to do. A step by step guide.

How i check my scripts.
I understand that i am quite the nooby scripter,
but i figured that there are more noobier scripters out there.
And i was hoping this method i use might help more people.
This method is strictly about problems that the npc server doesn't show
when you update your script.
This is the script that i will be using to demonstrate this method,
i have deliberately faulted it,
because i thought it would be clearer like this then working with a functional script.
PHP Code:
//#CLIENTSIDE
function onKeyPressed(code,key)
{
  if( 
key == "f")
  {
    if(
player.== 1)
    {
      
replaceAni("walk""idle");
      
temp.0;
      while(
temp.4)
      {
        
temp.+= 0.5;
        
player.+= 0.2/temp.i;
        
sleep(0.05);
        if(
player.1)
        {
          
settimer(0.05);
        }
        else if(
temp.== 4)
        {
          
temp.0;
          while(
temp.4)
          {
            
temp.+= 0.5;
            if(
player.< -0.5)
            {
              
replaceAni("walk""walk");
              
player.0;
              
sleep(0.05);
            }
            else
            {
              
player.-= 0.2/temp.i;
              
sleep(0.05);
            }
          }
        }
      }
    }  
  }

now this script is not completely functioning, because i have put 2 errors in here.
NOw here is the method i use:
I take this line:
PHP Code:
player.chat "succes"
but you can also use an echo if you prefer.
And i put it after the first conditional, like this.
PHP Code:
//#CLIENTSIDE
function onKeyPressed(code,key)
{
  if( 
key == "f")
  {
    
player.chat == "succes";
    if(
player.== 1)
    {
      
replaceAni("walk""idle");
      
temp.0;
      while(
temp.4)
      {
        
temp.+= 0.5;
        
player.+= 0.2/temp.i;
        
sleep(0.05);
        if(
player.1)
        {
          
settimer(0.05);
        }
        else if(
temp.== 4)
        {
          
temp.0;
          while(
temp.4)
          {
            
temp.+= 0.5;
            if(
player.< -0.5)
            {
              
replaceAni("walk""walk");
              
player.0;
              
sleep(0.05);
            }
            else
            {
              
player.-= 0.2/temp.i;
              
sleep(0.05);
            }
          }
        }
      }
    }  
  }

Because there is nothing wrong with this part, whenever i press f,
my player will say "succes".

I will delete the player.chat i have put in my script,
and put it after the next conditional.
Like this.
PHP Code:
//#CLIENTSIDE
function onKeyPressed(code,key)
{
  if( 
key == "f")
  {
    if(
player.== 1)
    {
      
player.chat "succes"
      
replaceAni("walk""idle");
      
temp.0;
      while(
temp.4)
      {
        
temp.+= 0.5;
        
player.+= 0.2/temp.i;
        
sleep(0.05);
        if(
player.1)
        {
          
settimer(0.05);
        }
        else if(
temp.== 4)
        {
          
temp.0;
          while(
temp.4)
          {
            
temp.+= 0.5;
            if(
player.< -0.5)
            {
              
replaceAni("walk""walk");
              
player.0;
              
sleep(0.05);
            }
            else
            {
              
player.-= 0.2/temp.i;
              
sleep(0.05);
            }
          }
        }
      }
    }  
  }

You will see that the player will now not say anything,
which means that there is an error somewhere in the script between here and the last conditional.
The error is obviously that player.z starts at 0,
so as long as our player is on the ground, nothing will happen.

Once we fix this, this script is still not working,
because there is also an error further ahead in the script.
So if you know how your script is supposed to work, you can check it step by step,
in the order of which your script is supposed to work.
And you should be able to locate the errors.
Now that you have located the errors, you can use the /scripthelp command on the RC,
Check the wiki. http://wiki.graal.us, search the forum if a topic about it exists,
ask a friend for help, and if all of that didn't work,
post a topic on the forums about your problem.

I hope this has helped some people, and again, i know that i'm not a good scripter(yet).
But i think this method might help some people. And help people understand how their scripts work.
And how to fix them if they are not working.

And, although i might have better put this at the start,
in case you don't understand what the script is supposed to do.
this is a script that makes your player jump in the air, although not over objects yet.
Reply With Quote
 


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 10:23 AM.


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