Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   error in RC with gui (https://forums.graalonline.com/forums/showthread.php?t=134261622)

callimuc 01-09-2011 02:04 PM

error in RC with gui
 
hey guys i was testing around with gui scripting and somehow i could have done 2 warping buttons :D

now i found a script which has a warper menu so i tested around that and after a while i got a problem. the RC keeps saying:

error: missing semicolon at line 5: setlevel2 callimap_c1.nw,10,10;
<b>error: missing semicolon at line 10: setlevel2 level2.nw,35,34;
<b>error: missing semicolon at line 15: setlevel2 level3.nw,35,44;
<b>error: missing semicolon at line 20: setlevel2 level4.nw,32,32;
<b>error: missing semicolon at line 25: setlevel2 level5.nw,29,25;

i could find any mistake so i copied the setlevel2 from other gui button (which worked) but it still keeps saying that. can anyone help?

and the scripts are:
PHP Code:

function onActionServerSide(action) {
  switch (
action) {
    case 
"Warp000":
    
setlevel2 callimap_c1.nw,10,10;
      
player.dir 2;
      
player.chat "Warped to the OSL!";
    break;
    case 
"Warp001":
      
setlevel2 level2.nw,35,34;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp002":
      
setlevel2 level3.nw,35,44;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp003":
      
setlevel2 level4.nw,32,32;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp004":
      
setlevel2 level5.nw,29,25;
      
player.dir 2;
      
player.chat "Warped";
    break;
  }
}
//#CLIENTSIDE
function onCreated() {
//starting from here is gui and so on




or should i use the triggerserver?

-callimuc

TSAdmin 01-09-2011 02:47 PM

Quote:

Originally Posted by callimuc (Post 1621548)
hey guys i was testing around with gui scripting and somehow i could have done 2 warping buttons :D

now i found a script which has a warper menu so i tested around that and after a while i got a problem. the RC keeps saying:

error: missing semicolon at line 5: setlevel2 callimap_c1.nw,10,10;
<b>error: missing semicolon at line 10: setlevel2 level2.nw,35,34;
<b>error: missing semicolon at line 15: setlevel2 level3.nw,35,44;
<b>error: missing semicolon at line 20: setlevel2 level4.nw,32,32;
<b>error: missing semicolon at line 25: setlevel2 level5.nw,29,25;

i could find any mistake so i copied the setlevel2 from other gui button (which worked) but it still keeps saying that. can anyone help?

and the scripts are:
PHP Code:

function onActionServerSide(action) {
  switch (
action) {
    case 
"Warp000":
    
setlevel2 callimap_c1.nw,10,10;
      
player.dir 2;
      
player.chat "Warped to the OSL!";
    break;
    case 
"Warp001":
      
setlevel2 level2.nw,35,34;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp002":
      
setlevel2 level3.nw,35,44;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp003":
      
setlevel2 level4.nw,32,32;
      
player.dir 2;
      
player.chat "Warped";
    break;
    case 
"Warp004":
      
setlevel2 level5.nw,29,25;
      
player.dir 2;
      
player.chat "Warped";
    break;
  }
}
//#CLIENTSIDE
function onCreated() {
//starting from here is gui and so on




or should i use the triggerserver?

-callimuc

It's expecting there to be no spaces between "setlevel2", and where it's going to, as such thinks that the "setlevel2" part is missing a semicolon. You're mixing GS1 with GS2. The GS2 format for setLevel2 is, using one of your lines for example:

PHP Code:

    case "Warp000":
      
player.setLevel2("callimap_c1.nw"1010);
      
player.dir 2;
      
player.chat "Warped to the OSL!";
    break; 

As you can see, the format for setLevel2() is ReferenceObject.setLevel2("LevelNameInQuotes.nw", X, Y);

Codein 01-09-2011 03:14 PM

Although not relevant to your problem, there is a lot of duplication in there. It might be a good idea to abstract out the repeated code into a function.

callimuc 01-09-2011 04:04 PM

Quote:

Originally Posted by TSAdmin (Post 1621551)
It's expecting there to be no spaces between "setlevel2", and where it's going to, as such thinks that the "setlevel2" part is missing a semicolon. You're mixing GS1 with GS2. The GS2 format for setLevel2 is, using one of your lines for example:

PHP Code:

    case "Warp000":
      
player.setLevel2("callimap_c1.nw"1010);
      
player.dir 2;
      
player.chat "Warped to the OSL!";
    break; 

As you can see, the format for setLevel2() is ReferenceObject.setLevel2("LevelNameInQuotes.nw", X, Y);

ah ok i had the setlevel2("blabla",10,10); but without player.setlevel2("blabla",10,10); but it still wont wor, but i dont have any errors now




Quote:

Originally Posted by Codein (Post 1621552)
Although not relevant to your problem, there is a lot of duplication in there. It might be a good idea to abstract out the repeated code into a function.

so do u mean i should make like:
PHP Code:

function onCreated() {
//blabla
  
Warp000();
}
function 
Warp000() {
//or function onWarp000() { i have seen this two what should i use
//blabla



gwFCCtennis 01-09-2011 04:36 PM

Now calli, where have I seen this script before....

Codein 01-09-2011 06:56 PM

Quote:

Originally Posted by callimuc (Post 1621559)
ah ok i had the setlevel2("blabla",10,10); but without player.setlevel2("blabla",10,10); but it still wont wor, but i dont have any errors now






so do u mean i should make like:
PHP Code:

function onCreated() {
//blabla
  
Warp000();
}
function 
Warp000() {
//or function onWarp000() { i have seen this two what should i use
//blabla



No, not at all.

I mean like:

PHP Code:

function warpPlayer(levelxychatText)
{
  
setlevel2(levelxy);
  
player.dir 2;
  
  if (
chatText != null)
    
player.chat chatText;
  else
    
player.chat "Warped";


This way, if you wanted to change the direction for all warps, you would only need to change it in one place, saving you time and money (you pay for gold right?).

And onSomething is generally used for events rather than bog-standard function yet I've them being used as if there is no distinction.

PowerProNL 01-09-2011 07:16 PM

I don't care about == or =

it works fine so what is the problem.

cbk1994 01-09-2011 07:21 PM

Quote:

Originally Posted by PowerProNL (Post 1621606)
I don't care about == or =

it works fine so what is the problem.

Please stop scripting.

An example of when it's a problem:

PHP Code:

function onCreated() {
  if (
wasBar()) {
    
// this shouldn't be called, but is!
    
echo("damn");
  }
}

function 
wasBar() {
  
temp.foo "foo";
  return (
foo "bar");



PowerProNL 01-09-2011 07:29 PM

Quote:

Originally Posted by cbk1994 (Post 1621610)
Please stop scripting.

no? why would I?

fowlplay4 01-09-2011 07:31 PM

Quote:

Originally Posted by PowerProNL (Post 1621615)
no? why would I?

Because you have no idea what you're doing.

Crow 01-09-2011 07:41 PM

Quote:

Originally Posted by fowlplay4 (Post 1621618)
Because you have no idea what you're doing.

This.

Codein 01-09-2011 09:15 PM

He shouldn't stop scripting. He should learn from this and try to improve. He should definitely stop giving out completely wrong advice though.

Deas_Voice 01-09-2011 10:20 PM

Quote:

Originally Posted by Codein (Post 1621639)
He shouldn't stop scripting. He should learn from this and try to improve. He should definitely stop giving out completely wrong advice though.

Quote:

Originally Posted by PowerProNL (Post 1621606)
I don't care about == or =

it works fine so what is the problem.

if that's his attitude about scripting, then he should.

Skyld 01-09-2011 11:25 PM

Quote:

Originally Posted by PowerProNL (Post 1621606)
I don't care about == or =

it works fine so what is the problem.

Because in the future when you post about a script not working, we are going to laugh at you, and then link you back to this very post and ridicule your terrible attitude towards scripting. Maybe then you will wish you had listened to the advice of people who know more about GScript than you do. We do not have time for people who "don't care", and we do not want people who "don't care" posting in this forum.

xAndrewx 01-09-2011 11:26 PM

When I first started I made the most retarded posts in the NPC forum. (Thinking as though I was a scripter... hehe)

I suppose I learned from it though, and you will too. Don't give up ^^


All times are GMT +2. The time now is 07:17 AM.

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