Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Ping (https://forums.graalonline.com/forums/showthread.php?t=85096)

fowlplay4 04-11-2009 09:24 PM

Ping
 
Stumbled upon this today, Enjoy! Although a player.ping variable that would auto-update itself would be niftier but this can get us pretty close.

Scripthelp Docs: TServerPlayer.sendping() - returns object - pings the player, returns a request object which will get an onReceivePing(time) event (use catchevent() on the object)

PHP Code:


function onGPing(acct) {
  
temp.obj findplayer(acct).sendping();
  
this.catchevent(obj"onReceivePing""onGPingReply");
}

function 
onGPingReply(objplyrtime) {
  echo(
plyr.account SPC int(time 1000) @ "ms");



napo_p2p 04-11-2009 09:38 PM

That's pretty neat. I actually wasn't aware of sendping();

Cloven 04-11-2009 09:45 PM

Yeah, nice find. :)

fowlplay4 04-11-2009 10:44 PM

Stumbled upon it when i was looking for the docs for catchevent.

I guess Stefan snuck it in during the NPC-Server update but the documentation for is a little over since it has 3 parameters instead of 1.

GULTHEX 11-02-2009 06:12 PM

Nice job Dude.

cbk1994 11-02-2009 11:26 PM

Quote:

Originally Posted by GULTHEX (Post 1535843)
Nice job Dude.

http://img180.imageshack.us/img180/9193/nobumphd7.png

oo_jazz_oo 11-03-2009 12:47 AM

I thought thread bumping was allowed in the code gallery?

Since some people might find an old thread useful.

salesman 11-03-2009 12:51 AM

Quote:

Originally Posted by oo_jazz_oo (Post 1535992)
I thought thread bumping was allowed in the code gallery?

Since some people might find an old thread useful.

"Nice job dude" isn't really a good reason to bump the thread. If he had a question or something, then that's different.

Deas_Voice 11-03-2009 06:07 PM

pinging yourself should be available to all server :)
i already added it to Testbed (Shared/Ping) and UN already has it.

sssssssssss 12-11-2009 05:33 AM

So how exactly do you set this up? :x

Tried using player chat to trigger to server, then echo it in rc with those 2 functions, sending it to the first one first, nothing is happening. Help this simpleton out plz.

fowlplay4 12-11-2009 05:39 AM

Something like this should work.. You'll need to modify it to your needs though.

PHP Code:

function onActionServerSide() {
  switch (
params[0]) {
    case 
"ping":
      
getPing();
      break;
  }
}

function 
getPing() { 
  
temp.obj player.sendping(); 
  
this.catchevent(obj"onReceivePing""onGPingReply"); 


function 
onGPingReply(objplyrtime) { 
  
plyr.chat int(time 1000) @ "ms";
}

//#CLIENTSIDE

function onCreated() {
  
getPing(player.account);
}

function 
getPing() {
  
triggerserver("gui"name"ping");



sssssssssss 12-11-2009 05:49 AM

cool, thanksers.

Jiroxys7 05-02-2010 02:56 AM

Still trying to get the hang of this. So i gotta ask.
where are the results stored so i can send them to the clientside? sending temp.obj doesnt seem to be it.

xAndrewx 05-02-2010 09:53 AM

HTML Code:

function onGPingReply(obj, plyr, time) { 
  plyr.chat = int(time * 1000) @ "ms";
}

Here is your reply, change the plyr.chat to a var and send it to the clientside using triggerclient()

Jiroxys7 05-03-2010 08:20 AM

Quote:

Originally Posted by xAndrewx (Post 1573432)
Here is your reply, change the plyr.chat to a var and send it to the clientside using triggerclient()

thanks that helped a lot :D


All times are GMT +2. The time now is 08:37 PM.

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