Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-23-2012, 02:40 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
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?
Reply With Quote
  #2  
Old 06-23-2012, 02:49 PM
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
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.
Reply With Quote
  #3  
Old 06-23-2012, 02:53 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 ffcmike View Post
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.
Reply With Quote
  #4  
Old 06-23-2012, 04:40 PM
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 ffcmike View Post
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.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:12 PM.


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