#ping js

1 messages · Page 1 of 1 (latest)

orchid canopy
#

hello! I need help with javascript, the fact is that I have a ping of 100-120 on my server and I need to fix the case with a fake ping. that is, could you tell me how to make a code in which the ping number will be minus 50 and sent to the scoreboard, via %JavaScript_ping%.

sly saffron
#

Get your host to move your server to closer location if one is available.

orchid canopy
#

ping 120 is felt at 40

sly saffron
orchid canopy
orchid canopy
#

Please, no questions asked

winged berry
#

Create new Js, add:
placeholder = %player_ping%;
And
return(placeholder-50);

#

Do you need full code?

orchid canopy
#

I only java launguage

#

(

sinful kestrel
#

math expansion could do this

#

%math_0:_{player_ping}-50%

#
/papi reload```
orchid canopy
sinful kestrel
#

O.o

#

did you put it inside a javascript?

#

or just /papi parse me %math_0:_{player_ping}-50%

#

because you should do this this

#

no javascript

orchid canopy
sinful kestrel
#

okay, make sure you downloaded the expansion

orchid canopy
glossy martenBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

sinful kestrel
#

woops

glossy martenBOT
#
FAQ Answer:

PAPI Dump
To generate a PAPI dump, execute the command /papi dump. Then you can copy the link by clicking on it in chat and selecting the COPY LINK button.

orchid canopy
#

@winged berry

orchid canopy
winged berry
#

5min

sinful kestrel
#

/papi dump gives me information to see why math isn't working

#

you really don't need javascript for this

#

and javascript is a lot slower than using the math expansion

winged berry
#

Do you have placeholders API?
No - install, and go to the Yes step
Yes - turn on your server, and use /papi ecloud download Player
Now stop your server;
Find \plugins\PlaceholderAPI\javascript_placeholders.yml
and add this:
pingfix: file: pingfix.js
now goto \plugins\PlaceholderAPI\javascripts
and create just new .txt file. Rename it to pingfix.js so it will change it's format to .js open it in notepad++ or sublime text... and add this code:

var placeholder = "%player_ping%"; function placeholderCheck(){ return placeholder-50; } placeholderCheck();

save file. Now start your server and i hope you should be able to use %javascript_pingfix% placegolder

#

but in general, yes, strange

sinful kestrel
#

You can do as you please, but this is very overcomplicated

winged berry
#

js laggy but sometimes i use it(

sinful kestrel
#

just remember every single time that %javascript_pingfix% is parsed, it will create a new instance of the engine

#

it's good to use in small quantities

#

for something like ping, I would advise against it

#

especially when it's something that can be done using another placeholder, such as math

orchid canopy
#

hm

#

27.0

#

delete .0

#

;/

winged berry
#

sorry

#

wrong reply....

winged berry
sinful kestrel
#

not as bad as ping, but not great

#

You might be able to use changeoutput instead?

winged berry
#

what is it?

sinful kestrel
winged berry
#

interesting

sinful kestrel
#

you can do like %utils_parse_changeoutput_equals_input:{luckperms_has_permission_color.red}_matcher:yes_ifmatch:&c_else:{changeoutput...}%

#

using the utils expansion to parse nested placeholders

#

if that makes sense

sinful kestrel
winged berry
#

okay but ywhy do we need utils?

sinful kestrel
#

for the nested placeholders

#

you will have {changeoutput_{changeoutput_{changeoutput}}} for example

winged berry
#

ah okaaay

#

il try

#

it should be better then js?

orchid canopy
#

Help me, I need the number to be without a zero at the end.

sinful kestrel
orchid canopy
#

no

winged berry
# sinful kestrel yes

how can "else" emty string? changeoutput_equals_input:{vault_group}_matcher:mygroup_ifmatch:&7_else:?

sinful kestrel
#

like that

#

placeholder just ends

winged berry
winged berry
winged berry
sinful kestrel
sinful kestrel
sinful kestrel
#

i still advise against doing this

#

but 🤷‍♂️

orchid canopy
#
var placeholder = "%player_ping%";

function placeholderCheck() {
  return ~~(placeholder - 50);
}

placeholderCheck();
sinful kestrel
#

you do whatever you want

orchid canopy
#

I add ~~

winged berry
#

i got my longest placeholder ) %utils_parse_changeoutput_equals_input:{vault_group}_matcher:commander_ifmatch:&6_else:{changeoutput_equals_input:{vault_group}_matcher:warlord_ifmatch:&4_else:{changeoutput_equals_input:{vault_group}_matcher:dragon_ifmatch:&x&a&d&0&0&f&f_else:{changeoutput_equals_input:{vault_group}_matcher:creator_ifmatch:&f&l_else:}}}%

winged berry
sinful kestrel
#

changeoutput and utils

#

and vault

#

if you need more help, maybe ask in #placeholder-api or make your own thread, best not to keep using this one