My profiler for optimise my script
#1

Hi, i want to optimise my script apparently with my last host my players see other player lag (teleport) with lot of players.

I upload my profiler for you see if my code it's bad on some callback / others...

edit.
Reply
#2

What is your OnPlayerUpdate ? It's a very frequent event, keep it fast.
OnPlayerKeyStateChange too.
Mysql_query is threaded not should give problem to your lag.
Reply
#3

Thanks for your response

My OnPlayerUpdate

PHP код:
public OnPlayerUpdate(playerid)
{
    if(
EscapeTime[playerid] > 0EscapeTime[playerid] = 0;
    if(
PlayerSpawned[playerid] > 0)
    {
        new 
Action GetPlayerSpecialAction(playerid);
        if(
OPUAction[playerid] != ActionOPUAction[playerid] = Action;
        new 
weapons2 GetPlayerWeapon(playerid), ammo GetPlayerAmmo(playerid);
        if(
pAntiCheat[playerid][LastWeapon] != weapons2pAntiCheat[playerid][LastWeapon] = weapons2;
        if(
pAntiCheat[playerid][LastAmmo] != ammopAntiCheat[playerid][LastAmmo] = ammo;
    }
    return 
1;

This script it's very important for my anti cheat and for my anti c-bug, if i use a timer 100ms or 200ms it's better?

And on OnPlayerKeyStateChange i use a lot of code for my Anti-Cbug or Anti Drive By driver and passenger without driver and others script but i can optimise this.

You think my code on OnPlayerUpdate and OnPlayerKeyStateChange it's too bad?
Reply
#4

Often lag reasons:
- Script in OnPlayerUpdate
- A lot of objects or vehicles at one place
- Timers < 500ms
- !! Changing materials or text on objects !!
- frequented asking about player infos GetPlayerPos, Skin, Weapons, Vehicle, Seat.. You can store this serverside, for example create Skin[MAX_PLAYERS] that you will change when you change player skin.. Scripts with variables are much faster than scripts using player getting functions.
Reply
#5

This is a really old script I made once: http://pastebin.com/TCkpwY3R
It doesn't use OnPlayerUpdate to detect someone "c-bugging".
Reply
#6

Quote:
Originally Posted by papedo
Посмотреть сообщение
Often lag reasons:
- Script in OnPlayerUpdate
- A lot of objects or vehicles at one place
- Timers < 500ms
- !! Changing materials or text on objects !!
- frequented asking about player infos GetPlayerPos, Skin, Weapons, Vehicle, Seat.. You can store this serverside, for example create Skin[MAX_PLAYERS] that you will change when you change player skin.. Scripts with variables are much faster than scripts using player getting functions.
- I have just 99 objects i think, 350 vehicles.
- My online timer are 1000 ms, just one 30000 ms.
- I d'ont change the materials but i update a label text all 1 second
- Ok thanks for your advice


Quote:
Originally Posted by BigETI
Посмотреть сообщение
This is a really old script I made once: http://pastebin.com/TCkpwY3R
It doesn't use OnPlayerUpdate to detect someone "c-bugging".
My anti c-bug it's good but i use GetPlayerSpecialAction(playerid) for detect on player crouching on OnPlayerUpdate beacause apparently this function it's wrong on OnPlayerKeyStateChange.

https://sampforum.blast.hk/showthread.php?tid=370810

I will improve my anti c bug with your code thanks.

But for my "LastWeapon" on OnPlayerUpdate it's a bad idea to place it on this callback?
Reply
#7

Your OnPlayerUpdate is not the problem here. It really irritates me that people think putting 20 lines of code inside that callback will completely ruin the server's performance. Those people simply have no clue what they're talking about.

As a reference, GodFather ran relatively stable with 100+ players and it saved every players' stats in OnPlayerUpdate.
Reply
#8

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Your OnPlayerUpdate is not the problem here.
Did you actually look at the output?

Reply
#9

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Did you actually look at the output?

That's after 9625052 calls. mysql_query and fclose are the problem. If you use them very often, the server will lag heavily. I recommend switching to threaded queries (R7) and limiting your file function usage. Also, you should highly optimize your OnPlayerKeyStateChange code because it's being called super often, a little less often than OnPlayerUpdate.
Reply
#10

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
That's after 9625052 calls.
It doesn't really matter here how many times it was called, it took ~25% of the time which is more than any other function in the script, so it has to be optimized first.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)