Graal Forums

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

blackbeltben 05-24-2012 04:27 PM

Serverside Sleeping
 
How can I make a working sleep/Timer in a script with out using Timeouts/schedule events to change a value you twice in a script?

PHP Code:

function onActionServerside()
{
 
blah
 blah
 player
.clientr.testvalue = 0
blah
sleep
(5);   <--I thought this would work but no :(
 
player.clientr.testvalue = 1; 


fowlplay4 05-24-2012 04:35 PM

Why can't you use schedule event?

PHP Code:

function onActionServerSide() {
  
blah();
  
blah();
  
clientr.testvalue = 0;
  
this.scheduleevent(5, "ChangeTestValue", player.account);
}

function 
onChangeTestValue(pl) {
  
pl = findplayer(pl);
  if (
pl != NULL) { 
    
pl.clientr.testvalue = 1;
  }
} 


cbk1994 05-24-2012 10:48 PM

Quote:

Originally Posted by fowlplay4 (Post 1695466)
Why can't you use schedule event?

PHP Code:

function onActionServerSide() {
  
blah();
  
blah();
  
clientr.testvalue = 0;
  
this.scheduleevent(5, "ChangeTestValue", player.account);
}

function 
onChangeTestValue(pl) {
  
pl = findplayer(pl);
  if (
pl != NULL) { 
    
pl.clientr.testvalue = 1;
  }
} 


Even better:

PHP Code:

function onActionServerSide() { 
  
blah(); 
  
blah(); 
  
clientr.testvalue = 0; 
  
this.scheduleevent(5, "ChangeTestValue", player); // send the player object instead of the account
} 

function 
onChangeTestValue(pl) { 
  if (
pl != NULL) {  
    
pl.clientr.testvalue = 1; 
  } 
} 


fowlplay4 05-24-2012 10:55 PM

Quote:

Originally Posted by cbk1994 (Post 1695513)
Even better:

I had that originally I didn't know if objects would be sent properly.

cbk1994 05-24-2012 11:14 PM

Quote:

Originally Posted by fowlplay4 (Post 1695518)
I had that originally I didn't know if objects would be sent properly.

Indeed they are :).

blackbeltben 05-25-2012 04:07 AM

Thanks all! works good :0

DustyPorViva 05-25-2012 04:20 AM

Quote:

Originally Posted by blackbeltben (Post 1695551)
Thanks all! works good :0

But do you know why it works well?


All times are GMT +2. The time now is 10:56 PM.

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