Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   What's Wrong? (https://forums.graalonline.com/forums/showthread.php?t=63609)

RavenofEarth 01-21-2006 01:12 PM

What's Wrong?
 
I'm having trouble making a script that, after a certain amount of time (seconds) it warps you to a level.

NPC Code:
//#CLIENTSIDE
if (playerenters||created) {
timeout = 1;
}
if (timeout) {
this.warp==1;
}
if (this.warp==1) {
setlevel2 onlinestartlocal.nw,30,30;
}


Rick 01-21-2006 01:19 PM

o.O

HTML Code:

//#CLIENTSIDE
if (playerenters || created) {
  timeout = 1;
}

if (timeout) {
  setlevel2 onlinestartlocal.nw,30,30;
}


RavenofEarth 01-21-2006 01:22 PM

Doesn't work...

Rick 01-21-2006 01:27 PM

Oh, I just realized. That script is clientside. setlevel2 doesn't work clientsidely.

RavenofEarth 01-21-2006 01:35 PM

So, how would I make a script that after a certain amount of seconds or whatever, it warps you from the level you are, to the OSL?

Kronan 01-21-2006 03:28 PM

HTML Code:

if (actionserverside) {
  setlevel2 onlinestartlocal.nw,30,30;
}

//#CLIENTSIDE
if (playerenters || created) {
  timeout = 1;
}

if (timeout) {
  triggeraction 0,0,serverside,#n;
}


RavenofEarth 01-21-2006 06:27 PM

Something isn't right, it still refuses to work online.

ZeLpH_MyStiK 01-21-2006 06:58 PM

Quote:

Originally Posted by Kronan
HTML Code:

if (actionserverside) {
  setlevel2 onlinestartlocal.nw,30,30;
}

//#CLIENTSIDE
if (playerenters || created) {
  timeout = 1;
}

if (timeout) {
  triggeraction 0,0,serverside,#n;
}


...dont give bad advice, i'm assuming this is a level npc
NPC Code:

if (actionserverside) setlevel2 onlinestartlocal.nw,30,30;
//#CLIENTSIDE
if (created || playerenters) timeout = 1;
if (timeout) triggeraction x,y,serverside,;


i dont really mind giving this out since its just 4 lines, but you should really look over some of the documents graal give you or visit Graal Wiki.

RavenofEarth 01-21-2006 07:03 PM

Would it help if I said that's not working either? ;-;

Yen 01-21-2006 07:19 PM

. . .
Wtf is wrong with you people

PHP Code:

if (created) {
  
setshape 1,16,16;
}
if (
actiondowarp) {
  
with (getplayer(#p(0))) {
    
setlevel2 onlinestartlocal.nw,30,30;
  }
}
//#CLIENTSIDE
if (playerenters) {
  
timeout 1;
}
if (
timeout) {
  
triggeraction x+.5,y+.5,dowarp,#a;


You can't trigger something unless it has a shape.

RavenofEarth 01-21-2006 07:24 PM

Heh, I should have taken your word on your scripting skills before and hired you. But I guess it was protocol. O_o

Skyld 01-21-2006 07:27 PM

Quote:

Originally Posted by Yen
. . .
Wtf is wrong with you people

PHP Code:

if (created) {
  
setshape 1,16,16;
}
if (
actiondowarp) {
  
with (getplayer(#p(0))) {
    
setlevel2 onlinestartlocal.nw,30,30;
  }
}
//#CLIENTSIDE
if (playerenters) {
  
timeout 1;
}
if (
timeout) {
  
triggeraction x+.5,y+.5,dowarp,#a;


You can't trigger something unless it has a shape.

Do not always trust the information that the client sends.

You do not actually need to send the account name, and you do not actually need to use getplayer() to warp the player.

Yen 01-21-2006 07:33 PM

You don't? How would it know which player to warp, if there's more than one?

ZeLpH_MyStiK 01-21-2006 07:36 PM

It automatically uses the account name of the player triggering it. It's a lot more secure without sending #a, since clientside info can be edited. Plus, you don't have to +.5 to the xy coordinates of the level npc, it should trigger just fine. =\

Yen 01-21-2006 07:54 PM

Neh, I've never had it trigger using x,y.
I didn't know it automatically referenced the player that sent the trigger O-o

RavenofEarth 01-21-2006 08:04 PM

Eh, it works though, appreciate it Yen.

Prozac 01-21-2006 08:07 PM

what's wrong with just doing this

HTML Code:

if (created || playerenters)
 {
  sleep 1;
  setlevel2 onlinestartlocal.nw,30,30;
 }


Yen 01-21-2006 08:08 PM

If a player enters before the first one is warped, one player won't be warped.

Skyld 01-21-2006 09:04 PM

Quote:

Originally Posted by Yen
If a player enters before the first one is warped, one player won't be warped.

Not quite!

sleep causes a loss of focus on the player.

Lance 01-22-2006 12:28 AM

Quote:

Originally Posted by RavenofEarth
I'm having trouble making a script that, after a certain amount of time (seconds) it warps you to a level.

NPC Code:
//#CLIENTSIDE
if (playerenters||created) {
timeout = 1;
}
if (timeout) {
this.warp==1;
}
if (this.warp==1) {
setlevel2 onlinestartlocal.nw,30,30;
}


First, it would be wise to tell us if this is supposed to be a level NPC or a weapon NPC. The best solution to this problem differs between the two.

The main problem with your script is that your last block is a conditional block instead of an event block. Rick suggested how to best fix that.

The secondary problem with your script is that setlevel2 is a serverside command and must be executed on serverside.

---

There has been a lot of bad advice in this thread, and it has not made me very happy.

Quote:

Originally Posted by Rick
o.O

HTML Code:

//#CLIENTSIDE
if (playerenters || created) {
  timeout = 1;
}

if (timeout) {
  setlevel2 onlinestartlocal.nw,30,30;
}


I know you know that setlevel2 isn't a clientside command, but please look more carefully in the future to avoid making the same mistake.

Quote:

Originally Posted by Kronan
HTML Code:

if (actionserverside) {
  setlevel2 onlinestartlocal.nw,30,30;
}

//#CLIENTSIDE
if (playerenters || created) {
  timeout = 1;
}

if (timeout) {
  triggeraction 0,0,serverside,#n;
}


You are suggesting a weapon script. Not only would it be wise to note this, but it would probably be wise not to suggest a weapon script that tries to trigger to a weapon sharing the same name as the player's current nickname.
Quote:

Originally Posted by ZeLpH_MyStiK
...dont give bad advice, i'm assuming this is a level npc
NPC Code:

if (actionserverside) setlevel2 onlinestartlocal.nw,30,30;
//#CLIENTSIDE
if (created || playerenters) timeout = 1;
if (timeout) triggeraction x,y,serverside,;


i dont really mind giving this out since its just 4 lines, but you should really look over some of the documents graal give you or visit Graal Wiki.

Bad assumption to make at this point without further information. Also, as Yen pointed out, it would require a setshape (or an image) to function properly.

However.

Quote:

Originally Posted by Yen
. . .
Wtf is wrong with you people

PHP Code:

if (created) {
  
setshape 1,16,16;
}
if (
actiondowarp) {
  
with (getplayer(#p(0))) {
    
setlevel2 onlinestartlocal.nw,30,30;
  }
}
//#CLIENTSIDE
if (playerenters) {
  
timeout 1;
}
if (
timeout) {
  
triggeraction x+.5,y+.5,dowarp,#a;



You just suggested a script that would allow malicious people to warp any player on the server to the onlinestartlocal, regardless of where they are or what they're doing. You've become a trainer enabler; good job!

Quote:

Originally Posted by Prozac
what's wrong with just doing this

HTML Code:

if (created || playerenters)
 {
  sleep 1;
  setlevel2 onlinestartlocal.nw,30,30;
 }


Mostly just that it wouldn't work. As Skyld noted, sleep changes the scope. You can check out the effect yourself with a simple script:

NPC Code:
function onPlayerEnters() {
echo("1:" @ player.account);
sleep(1);
echo("2:" @ player.account);
}



---

Please, in the future, take care not to give bad advice. Remember, folks who consistently give bad advice will be masked from this forum. If you want to help (this part is appreciated) but have no idea what you're talking about or don't take the time to look at your solution carefully (this part is not), please don't confuse the person you're trying to help.


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

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