Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Warped NPC will not show after being hidden (https://forums.graalonline.com/forums/showthread.php?t=134266713)

Emera 06-23-2012 02:40 PM

Warped NPC will not show after being hidden
 
I'm working on warping a car from one point to another after they leave the car, but for some reason, the NPC will successfully warp to the point I'd like it to warp to, but because the NPC is hidden after the player gets in the car, using show() to make it visible again will not work, and the NPC remains invisible.

Here's a condensed version of what I'm doing.

Class Script - Joined to the car

PHP Code:

function onCreated() {
  
this.setshape(11616);
}

function 
onActionGrab() {
  if (
player.client.incar != true && player.account == this.owner) {
    
player.client.incar true;
    
player.client.carlevel this.level.name;
    
player.client.carid this.id;
    
    
//Hide the car
    
this.hide();
  }
}

/*Called when the player leaves the car, and is triggered from a
control weapon. The car is warped to the correct position, but
the car still remains hidden, and using show() will not show it*/

public function outOfCar() {
  
//Attempt to show the car
  
this.show();


Weapon Script - Warping process

PHP Code:

function onActionServerside() {
  switch(
params[0]) {
    case 
"getoutofcar": {
      
temp.car_level findlevel(client.carlevel);
      
      for (
ln temp.car_level.npcs) {
        if (
ln.id == player.client.carid) {
          
ln.warpto(player.level.nameplayer.yplayer.y);
          
//Trigger the attempt to show the car
          
ln.outOfCar();
        }
      }
      break;
    }
  }
}

//#CLIENTSIDE

function leaveCar() {
  
triggerserver("gui"name"getoutofcar");


Does anybody have any ideas?

ffcmike 06-23-2012 02:49 PM

This is because of serverside to clientside synchronisation not occurring outside of triggers/events.
Try using a .trigger() on the NPC rather than a public function.

It's also a bad idea to be using client. variables this way.

Emera 06-23-2012 02:53 PM

Quote:

Originally Posted by ffcmike (Post 1698196)
This is because of serverside to clientside synchronisation not occurring outside of triggers/events.
Try using a .trigger() on the NPC rather than a public function.

It's also a bad idea to be using client. variables this way.

I'll convert them to clientr. variables when I'm done then. Thanks for pointing that out.

cbk1994 06-23-2012 04:40 PM

Quote:

Originally Posted by ffcmike (Post 1698196)
This is because of serverside to clientside synchronisation not occurring outside of triggers/events.
Try using a .trigger() on the NPC rather than a public function.

Alternatively you can just do this.trigger("update"); and leave everything else as it is.


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

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