PDA

View Full Version : Ping


fowlplay4
04-11-2009, 10:24 PM
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)



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

function onGPingReply(obj, plyr, time) {
echo(plyr.account SPC int(time * 1000) @ "ms");
}

napo_p2p
04-11-2009, 10:38 PM
That's pretty neat. I actually wasn't aware of sendping();

Cloven
04-11-2009, 10:45 PM
Yeah, nice find. :)

fowlplay4
04-11-2009, 11: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
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
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.


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

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

function onGPingReply(obj, plyr, time) {
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, 03: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, 10:53 AM
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, 09:20 AM
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

Gunderak
10-27-2013, 10:30 AM
Nice job Dude.