Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Player x y Serverside (https://forums.graalonline.com/forums/showthread.php?t=74336)

Angel_Light 06-01-2007 09:01 PM

Player x y Serverside
 
How can I detect "a" player's x y coordinates on serverside, I've tried a few method none to seem to work properly.

Skyld 06-01-2007 09:04 PM

The X and Y attributes of a player are accessible through the player's object, like on the clientside, i.e. player.x, findPlayer("Skyld").x, etc.

Angel_Light 06-01-2007 09:32 PM

right, but I'm talking about if the player just walks by the NPC (it's a Class actually) I tried FindNearestPlayer but had no luck

xAndrewx 06-01-2007 10:32 PM

Hmm, I'd do it this way...
HTML Code:

function onCreated()
{
  this.setShape(1, 32, 32);
}
function onActionDetected()
{
  //Your thing, use actionPlayer to find out whom did it
}
//#CLIENTSIDE
function onPlayerEnters()
{
  this.onTimeout();
}
function onTimeout()
{
  if (player.x in |this.x - 5, this.x + 5| && player.y in |this.y - 5, this.y + 5|)
  {
    triggeraction(this.x, this.y, "Detected", "");
  }
  setTimer(0.05);
}


xXziroXx 06-01-2007 10:33 PM

setShaoe xD

xAndrewx 06-01-2007 10:33 PM

rawr, setShape *edits
thanks ***** x

Novo 06-01-2007 10:45 PM

And try to prevent it from sending a trigger every 0.05 seconds...
PHP Code:

if ( inrange )
  {
  if ( !
wasinrange )
    
trigger...
  
wasinrange true;
  } else 
wasinrange false


xAndrewx 06-01-2007 10:47 PM

Yes, I do recommend doing that

Angel_Light 06-02-2007 02:04 AM

Thanks guys! :D I'll go test this now

EDIT: No, not working still :/

Novo 06-02-2007 03:56 AM

triggeraction(this.x+0.5, this.y+0.5, "Detected", ""); ?
I don't know if the trigger is inclusive or exclusive on the border region.

Angel_Light 06-02-2007 04:40 AM

well, it's a class so triggeraction act different I think, O.o Eh, it's beyond my knowledge :[

killerogue 06-02-2007 05:31 AM

Triggeractions don't act differently. You just can't use triggerserver or triggerclient inside of classes.

Angel_Light 06-02-2007 05:52 AM

so triggeraction ( 0, 0, "serverside", this.name, "Foo"); Would send "Foo" to the serverside of a class? :/ If so, it doesnt for me.

DustyPorViva 06-02-2007 05:59 AM

Can't communicate server<>client with classes. Only with weapons/gui's.

Angel_Light 06-02-2007 06:03 AM

Quote:

Originally Posted by DustyPorViva (Post 1314397)
Can't communicate server<>client with classes. Only with weapons/gui's.

Thought so, but, you can save vars to this.attr[#]; and communicate that way but takes alot CPU sometimes.

Novo 06-02-2007 06:08 AM

Quote:

Originally Posted by DustyPorViva (Post 1314397)
Can't communicate server<>client with classes. Only with weapons/gui's.

NPCs can... Using the x/y coordinates of the NPC on the level. It requires setShape to be set, however.

DustyPorViva 06-02-2007 06:10 AM

Ya, I wanted to create a bomb that exploded and shook the screen, but because the managing of the timer had to be serverside(destroy has to be serverside for it to delete for everyone), and the focus had to be clientside, I never managed to finish it. Sucks, and maybe communication for NPCs will be added soon.

Quote:

Originally Posted by Novo (Post 1314401)
NPCs can... Using the x/y coordinates of the NPC on the level. It requires setShape to be set, however.

Hmm, I never considered actually triggering itself like that. Does that actually work, confirmed? I've heard a lot of theories on how to do it and I've tried many different ways, and nothing ever worked. And if it is true, can you do so from serverside > clientside?

Novo 06-02-2007 11:22 AM

Quote:

Originally Posted by DustyPorViva (Post 1314402)
Ya, I wanted to create a bomb that exploded and shook the screen, but because the managing of the timer had to be serverside(destroy has to be serverside for it to delete for everyone), and the focus had to be clientside, I never managed to finish it. Sucks, and maybe communication for NPCs will be added soon.


Hmm, I never considered actually triggering itself like that. Does that actually work, confirmed? I've heard a lot of theories on how to do it and I've tried many different ways, and nothing ever worked. And if it is true, can you do so from serverside > clientside?

I'm quite sure you can't do the inverse... But from client to server, yes, it works... From server to client, I'm not quite sure.

killerogue 06-02-2007 11:35 AM

Uh, you can use triggeractions and catch the events with a clientside or serverside in classes.

Like:

PHP Code:

function onActionServerside() {
}

//#CLIENTSIDE
function onCreated() {
  
triggeraction(x,y,"Serverside",NULL);



cbk1994 06-02-2007 06:45 PM

Try something like this
PHP Code:

function onCreated()
{
  
setshape13232 );
}
function 
onActionNearacc )
{
  
chat acc SPC "is near me!";
}
//#CLIENTSIDE
function onCreated()
{
  
setTimer.1 );
}
function 
onTimeOut()
{
  if ( 
player.x in this.1this.| && player.y in this.2this.| )
  {
    
triggeractionthis..5this..5"Near"player.account );
  }
  
setTimer.1 );




All times are GMT +2. The time now is 05:28 AM.

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