#What can be optimized here?

26 messages ยท Page 1 of 1 (latest)

scarlet hatch
#

i can do my magic without profiling if i had your code

rancid coral
#

wdym

scarlet hatch
#

what i touch is optimised after

rancid coral
#

can you touch Red Dead Redemption 2 code please

scarlet hatch
#

unfortunately no, but lets be on-topic, post here an image with that html file viewed on an browser because i really can't view that on phone

urban shell
#

30% of total time is spent in OnPlayerUpdate and OnPlayerKeyStateChange, so start there

scarlet hatch
#

what you have in OnPlayerUpdate

rancid coral
#

public OnPlayerUpdate(playerid)
{

TimerAFK[playerid] = gettime();
return 1;

}

scarlet hatch
#

is not really bad, but u call gettime() everytime a player is sending packets to the server, and is calling every ~30ms, differs when the player is moving/idling

rancid coral
#

Yes, but I can't think another way to see if the player is AFK or not

scarlet hatch
#

a 1 sec timer will be good enough

rancid coral
#

But with 1 sec timer there is no way to see if the player is online or not, OnPlayerUpdate is not called when the player is AFK that's how can i see if the player is AFK or not

scarlet hatch
#

you can check if the player stays in a position more than 10 seconds or so, and if it stays, is afk (shit cooldown)

finite prairie
#

If you use weapon-config,just use it's IsPlayerPaused function, basically the same as your check you are doing it twice if you have WC

rancid coral
#

That may be a solution, but it can't guarantee if he's afk or not, btw I don't think a gettime uses a lot of resources.

Another solution I was thinking now is that in a 1 second timer I can gettime() and in OnPlayerUpdate TimerAFK[playerid] = gettimeVariable;

#

That way I dont have to call gettime a lot of times in a second.

I dont use WC.

scarlet hatch
#

no

that is not really bad for your server, gettime() isn't an resource eater, maybe you have some includes which are hooking OnPlayerUpdate, which can do a lot more

urban shell
#

that one line of code can't cause a self time of 20% and a total time of 30%

rancid coral
#

I think the only include hooking OnPlayerUpdate is Nex-AC

scarlet hatch
#

bingo, i looked in nex-ac some times ago, and yeah, is doing a lot of operations in OnPlayerUpdate

rancid coral
#

Uhmm

#

So, nothing that I can do to optimize more.

scarlet hatch
#

well, look at your code

rancid coral
#

I'm only using 5 or 6 nex-ac anticheats, I think if I write them in my gamemode and stop using nex-ac can reduce onplayerupdate usage?

scarlet hatch
#

write them in a better way

rancid coral
#

Yes, AFAIK nex-ac is "very" optimized