Guild Door Help

My NPC is:

if(playerenters){setimg door.png;}
if(strequlals(#g,Police)){
setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#,admin)){
setlevel2 admin.nw
}
else if(strequals(#,Manager)){
setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#,Co-Manager)){
setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#,GP-Officer)){
setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#,Beta-Test)){
setlevel2 onlinestartlocal.graal,42.5,27;
}
else if(!strequals(#,admin.Manager,GP-Officer,Bera-Test,Police)){
setlevel2 mariostart.nw,42.5,27;
}
}

But the NPC dosn’t work!!! :bang: :frowning:
What is wrong??
Please help me!!!

you need to add playertouchesme

example

if(playertouchesme&&strequlals(#g,Police)){
setlevel2 worldm-17_police3.nw,42.5,27;
}

more help

this dosn’t work:

else if(!strequals(#,admin.Manager,GP-Officer,Bera-Test,Police)){
setlevel2 mariostart.nw,42.5,27;
}

have some one an other NPS???

if(playerenters){setimg door.png;}
if(strequlals(#g,Police)){
  setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#,admin)){
  [color=red]setlevel2 admin.nw[/color]
}
else if(strequals(#,Manager)){
  setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#,Co-Manager)){
  setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#,GP-Officer)){
  setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#,Beta-Test)){
  setlevel2 onlinestartlocal.graal,42.5,27;
}
else if(!strequals(#,admin.Manager,GP-Officer,Bera-Test,Police)){
  setlevel2 mariostart.nw,42.5,27;
}
}

Spoon, I think you’ve got an extra curly brace in there. Also, I don’t think strequals will trigger an action. It’s got to be inside something as Dontar says.

Also, in the last else if I don’t know what strequals does if you pass it more than 2 arguments.

In any case, since the last “if” is basically just checking to make sure that none of the earlier things is true… why not just leave it at “else”?

if(playerenters){setimg door.png;}
if (playertouchsme) {
if(strequlals(#g,Police)){
  setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#g,admin)){
  setlevel2 admin.nw,32,32;
}
else if(strequals(#g,Manager)){
  setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#g,Co-Manager)){
  setlevel2 manager.nw ,42.5,27;
}
else if(strequals(#g,GP-Officer)){
  setlevel2 worldm-17_police3.nw,42.5,27;
}
else if(strequals(#g,Beta-Test)){
  setlevel2 onlinestartlocal.graal,42.5,27;
}
else{
  setlevel2 mariostart.nw,42.5,27;
}
}
if (playerenters) {
 setimg door.png;
}
if (playertouchsme) {
  if(strequlals(#g,Police)|| strequals(#g,GP-Officer)){
    setlevel2 worldm-17_police3.nw,42.5,27;
  } elseif(strequals(#g,admin)){
    setlevel2 admin.nw,32,32;
  } elseif(strequals(#g,Manager) || strequals(#g,Co-Manager)){
    setlevel2 manager.nw ,42.5,27;
  } elseif(strequals(#g,Beta-Test)){
    setlevel2 onlinestartlocal.graal,42.5,27;
  } else {
    setlevel2 mariostart.nw,42.5,27;
  }
}

huzzah! Community effort to turn a pos script into a decent working door script.

haha, if only we could take a collaborative code-writing mechanism like this and make it work at my company.

___Merged doublepost__________________

oops. spoke too soon. The misspelling of the first strequals that riley mentioned never got fixed.

if (playerenters) {
 setimg door.png;
}
if (playertouchsme) {
  if(strequals(#g,Police)|| strequals(#g,GP-Officer)){
    setlevel2 worldm-17_police3.nw,42.5,27;
  } elseif(strequals(#g,admin)){
    setlevel2 admin.nw,32,32;
  } elseif(strequals(#g,Manager) || strequals(#g,Co-Manager)){
    setlevel2 manager.nw ,42.5,27;
  } elseif(strequals(#g,Beta-Test)){
    setlevel2 onlinestartlocal.graal,42.5,27;
  } else {
    setlevel2 mariostart.nw,42.5,27;
  }
}

Make it even more compact, if (strequals(#g,Admin))setlevel admin.nw;
yum

Or he can give staff warp rights.

why doesnt gscript have case statements?

I dont even know why case exists if you have the if statement.

switch (option);

case 1:doshit;
bla bla bla

as apposed to
if (option ==1)doshit;

its silly >.<

[QUOTE=tricxta;73268]
I dont even know why case exists if you have the if statement.

switch (option);

case 1:doshit;
bla bla bla

as apposed to
if (option ==1)doshit;

its silly >.<
[/QUOTE]

I’s just syntactic sugar. Cases being allowed to “fall through” to other cases can make things easier to maintain.

x = 5
switch (x)
 case 1:
   do stuff
   break
 case 2:
   other stuff
   break
 case 3:
 case 4:
 case 5:
   several cases here
   break
 case 6:
   something else
 default
   some default action

Random variables and else statements could easily accomplish this though. XD

I thought that “one-line” solutions are considered bad scripting style?

Guess what, declaring class variables not as private then calling them without going through a method is considered bad scripting practice.

I object to this, the mysteries of scripting x_x

You object to a lot of things :0

[QUOTE=tricxta;73370]
Guess what, declaring class variables not as private then calling them without going through a method is considered bad scripting practice.

I object to this, the mysteries of scripting x_x
[/QUOTE]

The only reason I still think you are a bad scripter is because you leave your scripts open to error.

[QUOTE=Yenairo;73385]The only reason I still think you are a bad scripter is because you leave your scripts open to error.[/QUOTE]

Well you can think that all you like, in fact you all can. I dont really give two shits… if it works and is short as possible im good.

I personally like Tricxtas scripting, but that isn’t sayin much since I learned some of the more advanced stff from it x.x

[QUOTE=tricxta;73389]Well you can think that all you like, in fact you all can. I dont really give two shits… if it works and is short as possible im good.[/QUOTE]

Well, if you would failproof your scripts you wouldn’t have to fix them (as often or at all.)