Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   function onPlayerChats() delayed if there is an onTimeout() in the script (https://forums.graalonline.com/forums/showthread.php?t=85579)

Stryke 05-15-2009 07:08 AM

function onPlayerChats() delayed if there is an onTimeout() in the script
 
It seems that if you have the onPlayerChats() event in a script and an onTimeout() event, there is a slight delay when the function is called. It might be just me, but I'm not sure, so I decided to post it here.

If you have just the following below, the player's chat will be set to "" just fine without any delay.
PHP Code:

function onPlayerChats()
{
  if (
player.chat == "/test")
  {
    
player.chat "";
  }


However, if you have this:
PHP Code:

function onCreated()
{
  
setTimer(.05);
}

function 
onTimeout()
{
  
//doesn't even need code here
  
setTimer(.05);
}

function 
onPlayerChats()
{
  if (
player.chat == "/test")
  {
    
player.chat "";
  }


The above code will have a slight delay for onPlayerChats() to be called.

Well, there is a workaround for this by just putting the onPlayerChats event into a different WNPC, however i'd still like this fixed.

Tigairius 05-15-2009 07:09 AM

Yeap, I noticed this several times, I just got used to putting playerchat events in an entirely different script.

I'd love to see this fixed.

Crow 05-15-2009 01:53 PM

Quote:

Originally Posted by Tigairius (Post 1491586)
Yeap, I noticed this several times, I just got used to putting playerchat events in an entirely different script.

I'd love to see this fixed.

Same here.

Admins 05-15-2009 08:41 PM

Could you make some tests, printing the time when the onPlayerchats() event is invoked, with two weapos one with timeout one without?

cbk1994 05-16-2009 01:55 AM

I can also confirm this happens.

Though, as a side note, you can use ChatBar.onAction() and you should be able to catch it before the player chats.

napo_p2p 05-16-2009 05:11 AM

Quote:

Originally Posted by Stefan (Post 1491656)
Could you make some tests, printing the time when the onPlayerchats() event is invoked, with two weapos one with timeout one without?

It's consistently about 50ms apart for an empty timeout loop.

Admins 05-16-2009 05:40 PM

Hmmm it might indeed be a problem of ChatBar.onAction(), which is handled by the -Serverlist script which is then invoking an onPlayerChat event. Scripts that are already active (timeout) receive the event but since their onTimeout was already executed they will have to wait until the next frame. This is not a perfect situation but normally for chat commands it's not important to be executed 0.05 seconds sooner or later, so the question is if this need to be fixed? It might be a bigger problem for other cases, like triggers.

Tigairius 05-16-2009 07:01 PM

Quote:

Originally Posted by Stefan (Post 1491806)
so the question is if this need to be fixed? It might be a bigger problem for other cases, like triggers.

Well, the biggest problem is that if you do
PHP Code:

//#CLIENTSIDE
function onTimeout() {
  
setTimer(0.05);
}
function 
onPlayerChats() {
  if (
player.chat == "test") {
    
player.chat "";
  }


the player's chat won't clear serverside if there is a timeout clientside. So, for example, if you wanted to have a hidden command somewhere, you couldn't because everyone could see your chat anyways.

Just like on GK now, /commands only clear clientside, everyone serverside can still see what you said.

There are of course other problems resulting from this, I think it would be great to have it fixed. It would also be neat to see clientside timeouts sped up a little bit to handle faster times in the new client.

cbk1994 05-16-2009 08:38 PM

For making chat disappear (Tig's problem), you can use either

PHP Code:

shared.chat("");
// or
player.chat " "

but there will still be a delay if there's a timeout. Best to use ChatBar.onAction rather than onPlayerChats() for that anyway.


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

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