Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-18-2012, 04:11 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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?
__________________
Reply With Quote
  #2  
Old 02-18-2012, 04:18 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Emera View Post
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; 
Reply With Quote
  #3  
Old 02-18-2012, 04:18 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by ffcmike View Post
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
__________________
Reply With Quote
  #4  
Old 02-18-2012, 04:19 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
I don't think you need "player.setlevel2".. Shouldn't that be "setlevel2()" since you already focused on the player?
Reply With Quote
  #5  
Old 02-18-2012, 05:10 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by scriptless View Post
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.
__________________
Reply With Quote
  #6  
Old 02-18-2012, 05:57 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by Emera View Post
It's not needed but I think it's good practice.
Why? My mind is going "player.player.blah"... lol
Reply With Quote
  #7  
Old 02-18-2012, 07:10 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by scriptless View Post
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.
__________________
Reply With Quote
  #8  
Old 02-18-2012, 07:35 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
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?
Reply With Quote
  #9  
Old 02-18-2012, 07:56 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by scriptless View Post
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.
__________________
Quote:
Reply With Quote
  #10  
Old 02-18-2012, 09:16 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by fowlplay4 View Post
'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 ?
Reply With Quote
  #11  
Old 02-18-2012, 03:31 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by scriptless View Post
Why not for client/clientr ?
I personally encourage player.clientr.foo.
__________________
Skyld
Reply With Quote
  #12  
Old 02-18-2012, 04:03 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Skyld View Post
I personally encourage player.clientr.foo.
I do that too. It's good practice that's all.
__________________
Reply With Quote
  #13  
Old 02-18-2012, 06:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by scriptless View Post
Why not for client/clientr ?
Because only player objects use client and clientr flags so it seems redundant to me.
__________________
Quote:
Reply With Quote
  #14  
Old 02-18-2012, 06:39 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Skyld View Post
I personally encourage player.clientr.foo.
I personally found that more annoying than helpful.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 02-19-2012, 02:18 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Skyld View Post
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().
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:33 PM.


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