Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   TriggerServer Issue (https://forums.graalonline.com/forums/showthread.php?t=134264209)

blackbeltben 08-15-2011 01:06 AM

TriggerServer Issue
 
I have this script in a class with a npc joining it in the level. I am making a character custimization screen, but for some reason, when you click, it is not triggering the server and setting the clientr change. Ive tried clientr.race, player.clientr.race, this.player.clientr.race, just about everything. Ive even tried it with other variables changing that increase numbers. With that, Ive came to the conclusion that it is not triggering the server. Please help

PHP Code:

function onActionServerside() {
 if (
params[0] == "Change")
{
 
player.clientr.race "Human";
}
}

//#CLIENTSIDE
function onCreated()
{
 
setimg("runa_races_human.png");
 }
 
 function 
onMouseDown()
{
 if (
mousescreenx in |this.x,this.x+810| &&
     
mousescreeny in |this.y,this.y+211|)
          {
          
play("runa_click");
          
triggerserver("weapon"this.name"Change");
          }
 } 


ffcmike 08-15-2011 01:16 AM

Quote:

Originally Posted by blackbeltben (Post 1663587)
I have this script in a class with a npc joining it in the level. I am making a character custimization screen, but for some reason, when you click, it is not triggering the server and setting the clientr change. Ive tried clientr.race, player.clientr.race, this.player.clientr.race, just about everything. Ive even tried it with other variables changing that increase numbers. With that, Ive came to the conclusion that it is not triggering the server. Please help

PHP Code:

function onActionServerside() {
 if (
params[0] == "Change")
{
 
player.clientr.race "Human";
}
}

//#CLIENTSIDE
function onCreated()
{
 
setimg("runa_races_human.png");
 }
 
 function 
onMouseDown()
{
 if (
mousescreenx in |this.x,this.x+810| &&
     
mousescreeny in |this.y,this.y+211|)
          {
          
play("runa_click");
          
triggerserver("weapon"this.name"Change");
          }
 } 


I believe this is due to a mix up in level coordinates and screen coordinates, mousescreenx and mousescreeny are the positions of your mouse in pixels relevant to your screen, whereas this.x and this.y are the level coordinates measured in tiles (1 tile is 16 pixels in height and width).

Try this?:

PHP Code:

if (mousex in |this.x,this.x+widthintiles| &&
     
mousey in |this.y,this.y+heightintiles|)
          { 


blackbeltben 08-15-2011 01:31 AM

That can't be it, because it DOES play the sound which is after the "if" statement. so the problem must be somewhere else cause it is reconizing the click.

ffcmike 08-15-2011 01:43 AM

Quote:

Originally Posted by blackbeltben (Post 1663591)
That can't be it, because it DOES play the sound which is after the "if" statement. so the problem must be somewhere else cause it is reconizing the click.

Ah in that case if this is a level NPC you cannot use triggerserver, this can only be used for local NPCs/putnpc2 objects, database NPCs and weapons.
You can accomplish the same thing by using triggeraction:

PHP Code:

function onCreated(){
  
//define area inwhich to receive the trigger
  
this.setshape(1widthinpixelsheightinpixels);
}

function 
onActionSomething(params){
  
//stuff
}

//#CLIENTSIDE
function onMouseDown(){
  if(
mousewithinregionblahblah){
    
triggeraction(this.1this.1"Something"params);
  }


The click however may still have only worked through some form of numerical fluke as a result of the large range you are checking for, it would probably still work if you clicked somewhere away from your target.

fowlplay4 08-15-2011 01:48 AM

Quote:

Originally Posted by blackbeltben (Post 1663591)
That can't be it, because it DOES play the sound which is after the "if" statement.

You are confusing the two though.

this.x is a level coordinate (in your scripts case) and mousescreenx is a screen coordinate.


All times are GMT +2. The time now is 09:14 AM.

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