Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Warping players (Bug?) (https://forums.graalonline.com/forums/showthread.php?t=134265776)

Emera 02-18-2012 04:11 AM

Warping players (Bug?)
 
I don't know if this is a bug or if I'm doing this wrong, but it worked a few weeks ago using this method and it's not working now. I'm basically trying to "summon" a player by sending my level, x and y to the serverside, then warping the player to the said co-ordinates. For some reason, if I'm on a gmap, it will warp the player far to the right of my co-ordinates.

This is the summon trigger.
PHP Code:

case "summon":
  
with(findplayer(params[1])) {
    
temp.slevel params[2];
    
temp.sx params[3];
    
temp.sy params[4];        
    
player.setlevel2(temp.slevel,temp.sx,temp.sy);
  }
break; 

and this is what I'm sending to the server.
PHP Code:

triggerserver("gui",name,"summon",wc_TextList1.selected.text,player.level,player.x,player.y); 

wc_TextList1.selected.text being a players account name.

Any ideas?

ffcmike 02-18-2012 04:18 AM

Quote:

Originally Posted by Emera (Post 1684885)
I don't know if this is a bug or if I'm doing this wrong, but it worked a few weeks ago using this method and it's not working now. I'm basically trying to "summon" a player by sending my level, x and y to the serverside, then warping the player to the said co-ordinates. For some reason, if I'm on a gmap, it will warp the player far to the right of my co-ordinates.

This is the summon trigger.
PHP Code:

case "summon":
  
with(findplayer(params[1])) {
    
temp.slevel params[2];
    
temp.sx params[3];
    
temp.sy params[4];        
    
player.setlevel2(temp.slevel,temp.sx,temp.sy);
  }
break; 

and this is what I'm sending to the server.
PHP Code:

triggerserver("gui",name,"summon",wc_TextList1.selected.text,player.level,player.x,player.y); 

wc_TextList1.selected.text being a players account name.

Any ideas?


It's because clientside player.level is the singular level, whereas serverside player.level would be the map object, while player.x and player.y is relevant to your map coordinates.
You don't really need to be passing level and coordinates for a basic summon though, you could just do:

PHP Code:

case "summon":
  
temp.pl findplayer(params[1]);
  if(
temp.pl == NULL){
    return;
  }
  
temp.pl.setlevel2(player.level.nameplayer.xplayer.y);
break; 


Emera 02-18-2012 04:18 AM

Quote:

Originally Posted by ffcmike (Post 1684889)
It's because clientside player.level is the singular level, whereas serverside player.level would be the map object, while player.x and player.y is relevant to your map coordinates.
You don't really need to be passing level and coordinates for a basic summon though, you could just do:

PHP Code:

case "summon":
  
temp.pl findplayer(params[1]);
  if(
temp.pl == NULL){
    return;
  }
  
temp.pl.setlevel2(player.level.nameplayer.xplayer.y);
break; 


Thank you so much <3

scriptless 02-18-2012 04:19 AM

I don't think you need "player.setlevel2".. Shouldn't that be "setlevel2()" since you already focused on the player?

Emera 02-18-2012 05:10 AM

Quote:

Originally Posted by scriptless (Post 1684893)
I don't think you need "player.setlevel2".. Shouldn't that be "setlevel2()" since you already focused on the player?

It's not needed but I think it's good practice.

scriptless 02-18-2012 05:57 AM

Quote:

Originally Posted by Emera (Post 1684902)
It's not needed but I think it's good practice.

Why? My mind is going "player.player.blah"... lol

cbk1994 02-18-2012 07:10 AM

Quote:

Originally Posted by scriptless (Post 1684910)
Why? My mind is going "player.player.blah"... lol

Because it makes it clear what object is being acted upon.

You don't have to use player.level in a script—you could just use level. But then it's not clear what level you're working with. The NPC's level or the player's level?

It just makes it easier to understand.

scriptless 02-18-2012 07:35 AM

Quote:

Originally Posted by cbk1994 (Post 1684916)
Because it makes it clear what object is being acted upon.

You don't have to use player.level in a script—you could just use level. But then it's not clear what level you're working with. The NPC's level or the player's level?

It just makes it easier to understand.

So it's just for a person reading it to look easier? why not //player after it? Just curious is there any advantages?

fowlplay4 02-18-2012 07:56 AM

Quote:

Originally Posted by scriptless (Post 1684917)
So it's just for a person reading it to look easier? why not //player after it? Just curious is there any advantages?

'level' on it's own could refer to this.level (NPC) or player.level depending on where the code is.

You can eliminate that possible confusion by using the appropriate prefix in your code.

Also comments are supposed to help people understand what's going on in your code not help add confusion with an obscure looking comment.

The only time I don't use the player prefix is with client and clientr flags.

scriptless 02-18-2012 09:16 AM

Quote:

Originally Posted by fowlplay4 (Post 1684918)
'level' on it's own could refer to this.level (NPC) or player.level depending on where the code is.

You can eliminate that possible confusion by using the appropriate prefix in your code.

Also comments are supposed to help people understand what's going on in your code not help add confusion with an obscure looking comment.

The only time I don't use the player prefix is with client and clientr flags.

Why not for client/clientr ?

Skyld 02-18-2012 03:31 PM

Quote:

Originally Posted by scriptless (Post 1684921)
Why not for client/clientr ?

I personally encourage player.clientr.foo.

Emera 02-18-2012 04:03 PM

Quote:

Originally Posted by Skyld (Post 1684932)
I personally encourage player.clientr.foo.

I do that too. It's good practice that's all.

fowlplay4 02-18-2012 06:09 PM

Quote:

Originally Posted by scriptless (Post 1684921)
Why not for client/clientr ?

Because only player objects use client and clientr flags so it seems redundant to me.

xXziroXx 02-18-2012 06:39 PM

Quote:

Originally Posted by Skyld (Post 1684932)
I personally encourage player.clientr.foo.

I personally found that more annoying than helpful.

cbk1994 02-19-2012 02:18 AM

Quote:

Originally Posted by Skyld (Post 1684932)
I personally encourage player.clientr.foo.

I prefer this as well, for the same reason I use player.setLevel2 or this.func() instead of func().


All times are GMT +2. The time now is 01:47 PM.

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