#What can be optimized here?
26 messages ยท Page 1 of 1 (latest)
wdym
what i touch is optimised after
can you touch Red Dead Redemption 2 code please
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
30% of total time is spent in OnPlayerUpdate and OnPlayerKeyStateChange, so start there
what you have in OnPlayerUpdate
public OnPlayerUpdate(playerid)
{
TimerAFK[playerid] = gettime();
return 1;
}
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
Yes, but I can't think another way to see if the player is AFK or not
a 1 sec timer will be good enough
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
you can check if the player stays in a position more than 10 seconds or so, and if it stays, is afk (shit cooldown)
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
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.
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
that one line of code can't cause a self time of 20% and a total time of 30%
I think the only include hooking OnPlayerUpdate is Nex-AC
bingo, i looked in nex-ac some times ago, and yeah, is doing a lot of operations in OnPlayerUpdate
well, look at your code
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?
write them in a better way
Yes, AFAIK nex-ac is "very" optimized