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.z == 1)
{
replaceAni("walk", "idle");
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
player.z += 0.2/temp.i;
sleep(0.05);
if(player.z < 1)
{
settimer(0.05);
}
else if(temp.i == 4)
{
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
if(player.z < -0.5)
{
replaceAni("walk", "walk");
player.z = 0;
sleep(0.05);
}
else
{
player.z -= 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.z == 1)
{
replaceAni("walk", "idle");
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
player.z += 0.2/temp.i;
sleep(0.05);
if(player.z < 1)
{
settimer(0.05);
}
else if(temp.i == 4)
{
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
if(player.z < -0.5)
{
replaceAni("walk", "walk");
player.z = 0;
sleep(0.05);
}
else
{
player.z -= 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.z == 1)
{
player.chat = "succes"
replaceAni("walk", "idle");
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
player.z += 0.2/temp.i;
sleep(0.05);
if(player.z < 1)
{
settimer(0.05);
}
else if(temp.i == 4)
{
temp.i = 0;
while(temp.i < 4)
{
temp.i += 0.5;
if(player.z < -0.5)
{
replaceAni("walk", "walk");
player.z = 0;
sleep(0.05);
}
else
{
player.z -= 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.