Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Editing a local NPC (https://forums.graalonline.com/forums/showthread.php?t=134270135)

Kirko 11-25-2015 10:57 PM

Editing a local NPC
 
How would I go the way of editing local npcs from a level. I had tried changing the layer of one in clientside but only changed for me and no one else.
I tried doing in serverside but the layer wouldn't change. I had the npcs chat change to the layer it was in and it was chatting correctly but the layer wouldn't actually change.

Elk 11-26-2015 03:32 AM

open the level in texteditor and change it manually

Jakov_the_Jakovasaur 11-26-2015 08:15 AM

hello!

this is probably a case of the 'layer' variable not synchronising from serverside to clientside, you could try either setting it via drawunderplayer()/drawoverplayer() or by triggering its change using npc.trigger('Event', params...);

Kirko 11-26-2015 01:19 PM

So I got it to work some what. In class that the npc is joined to I have
PHP Code:

function onLayerChange(){
  
this.trigger("Update");
  
//this.chat = "test1";//this worked
  //this.layer = params[2];//can only be changed in clientside
  
this.triggeraction(this.x+.5,this.y+.5,"LayerChange2","");//doesnt work
}

//#CLIENTSIDE
function onPlayerEnters()
  
this.layer=this.attr[2]

//doesnt work
function onLayerChange2(){
  
this.trigger("Update");
  
this.chat "test2";
  
onPlayerEnters();


the layer only changes when I update level or reenter level. I tried triggering "Update" for the npc in my weapon script and some other thnigs but no luck

cbk1994 11-26-2015 03:38 PM

Unfortunately you can't trigger clientside like that (it would need to copy the trigger to every player in the level). The best way I remember solving these kind of issues is using a timeout to check an attr, sadly.

You could also hack it by triggering a weapon clientside on each player in the level, but that feels kind of bad too. You can't do point-triggers to clientside, though.

edit: nevermind, this entire post is wrong, see below

Tim_Rocks 11-26-2015 04:08 PM

Chris' method of using attr w/ a timeout makes the most sense.

ffcmike 11-26-2015 04:09 PM

Quote:

Originally Posted by cbk1994 (Post 1737812)
You can't do point-triggers to clientside, though.

You can since V6, I have a lot of scripts which work as follows:

PHP Code:


function onUpdate(temp.val) {
  
this.attr[4] = int(timevar2);
  
this.attr[5] = temp.val;
  
triggeraction(this.1this.1"Update""");
}

//#CLIENTSIDE
function onCreated()
  
this.setshape(13232);

function 
onPlayerEnters()
  if (
this.updatetTime != this.attr[4])
    
this.onActionUpdate();

function 
onActionUpdate() {
  
this.updatetTime this.attr[4];
  echo(
"New value is " this.attr[5]);


Looking at -

Quote:

Originally Posted by Kirko (Post 1737810)
PHP Code:

function onLayerChange(){
  
this.trigger("Update");
  
//this.chat = "test1";//this worked
  //this.layer = params[2];//can only be changed in clientside
  
this.triggeraction(this.x+.5,this.y+.5,"LayerChange2","");//doesnt work



this.triggeraction() won't work as it is not an NPC function, but a level function. Change it to one of just triggeraction(), level.triggeraction() or this.level.triggeraction(). The NPC needs a Clientside setshape() in order to receive the triggeraction as well.

xXziroXx 11-26-2015 04:12 PM

Quote:

Originally Posted by ffcmike (Post 1737814)
You can since V6

Confirmed. Stefan added it after popular demand.

cbk1994 11-26-2015 06:16 PM

Quote:

Originally Posted by ffcmike (Post 1737814)
You can since V6

whoops, thanks for correcting me! clearly I'm a bit behind the times :p.

Kirko 11-26-2015 07:29 PM

Got it to work!! thanks so much!!


All times are GMT +2. The time now is 05:27 PM.

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