Jump to content

Bad TriggerServerEvent


haybail

Recommended Posts

Hello,

I have a script that uses heavily triggerServerEvent, so often so I have to put a delay, as it can go twice so fast nothing will happen. And I think it may be hurting the server. And its players.

When I first tried the script, it caused network trouble and dropped players, even the entire server couple times.

I did a test and this is what I have: Bit funny, one of the results. No crashes or network trouble but the only thing I really changed was 450 ms to 550 ms and some checks and outputs :?

Worst offender:

Time elapsed: 481 milliseconds by hrco

Active admin: [NR]PhAnToM7!! [Car] stretch

Time elapsed: 383 milliseconds by THURTH

Time elapsed: 57 milliseconds by THURTH

Time elapsed: 242 milliseconds by [NL:BRUS]=TAB

Time elapsed: 184 milliseconds by THURTH

Time elapsed: 276 milliseconds by THURTH

Time elapsed: 50 milliseconds by THURTH

Time elapsed: 287 milliseconds by THURTH

Time elapsed: 45 milliseconds by NoLimited

Time elapsed: 155 milliseconds by THURTH

Time elapsed: 50 milliseconds by THURTH

In sync ( majority of players, vast majority ):

Time elapsed: 4776 milliseconds by [NR]PhAnToM7!!

Time elapsed: 497 milliseconds by [NR]PhAnToM7!!

Time elapsed: 657 milliseconds by [NR]PhAnToM7!!

Time elapsed: 472 milliseconds by [NR]PhAnToM7!!

Time elapsed: 568 milliseconds by [NR]PhAnToM7!!

Time elapsed: 572 milliseconds by [NR]PhAnToM7!!

Time elapsed: 585 milliseconds by [NR]PhAnToM7!!

Time elapsed: 570 milliseconds by [NR]PhAnToM7!!

Time elapsed: 560 milliseconds by [NR]PhAnToM7!!

Time elapsed: 1807 milliseconds by [NR]PhAnToM7!!

Time elapsed: 430 milliseconds by [NR]PhAnToM7!!

Time elapsed: 568 milliseconds by [NR]PhAnToM7!!

Time elapsed: 559 milliseconds by [NR]PhAnToM7!!

OUT_of_Range: admin give mi hydra pls

Time elapsed: 559 milliseconds by [NR]PhAnToM7!!

Time elapsed: 550 milliseconds by [NR]PhAnToM7!!

Time elapsed: 568 milliseconds by [NR]PhAnToM7!!

Time elapsed: 242 milliseconds by SammyS

Time elapsed: 4154 milliseconds by kraumik

Time elapsed: 931 milliseconds by kraumik

Time elapsed: 565 milliseconds by kraumik

Time elapsed: 541 milliseconds by kraumik

Time elapsed: 546 milliseconds by kraumik

Time elapsed: 564 milliseconds by kraumik

Time elapsed: 211 milliseconds by OUT_of_Range

Time elapsed: 1584 milliseconds by MtaSeVeR

Time elapsed: 553 milliseconds by OUT_of_Range

Time elapsed: 560 milliseconds by OUT_of_Range

Time elapsed: 27 milliseconds by MtaSeVeR

Time elapsed: 574 milliseconds by OUT_of_Range

Time elapsed: 492 milliseconds by OUT_of_Range

Time elapsed: 545 milliseconds by OUT_of_Range

Time elapsed: 545 milliseconds by OUT_of_Range

* MtaSeVeR killed IIA(RUS). (Sniper)

Tiny offset:

Time elapsed: 869 milliseconds by OUT_of_Range

Time elapsed: 1476 milliseconds by SammyS

Time elapsed: 486 milliseconds by SammyS

Time elapsed: 374 milliseconds by SammyS

Time elapsed: 3891 milliseconds by elvis

Time elapsed: 65 milliseconds by SammyS

Time elapsed: 1529 milliseconds by SammyS

Time elapsed: 224 milliseconds by SammyS

Time elapsed: 265 milliseconds by Reaper38

Time elapsed: 712 milliseconds by SammyS

Note: you look at the players in a row and how often they trigger. Below 450ms ( the minimum delay ) is unusual. Because there bypassing the delay.

This is my code on the triggers:

  
if not count then 
        triggerServerEvent ( "onPlayerH", getLocalPlayer(), hE, 1 ) 
  
        count = 0 
  
        setTimer ( onPlayerDelay, 450, 1 ) 
end 

And my delay:

function onPlayerDelay ( ) 
    if count > 0 then 
        triggerServerEvent ( "onH", getLocalPlayer(), p, c ) 
        setTimer ( onPlayerDelay, 550, 1 ) 
        count = 0 
    else 
        --outputChatBox ( "CLEAR" ) 
        count = nil 
    end 
end 

Link to comment

Oh um, the problem is, as I use it so heavily so often, it becomes unreliable and damaging to the server. And the reason I use it so much is to tell the server exactly what the client is doing. I thought it would be ok since its such a tiny peice of data.

Like the server updating the players position.

Is there a better way of transferring data between the client and the server so often without hurting it so much?

Link to comment

I think gamesnert was asking; what specifically are you trying to do? I say that because 'what the client is doing' is a pretty vague response.

Most important information is already available to the server.. synced player controls, player and vehicle health, transform and velocity info, etc. I can't imagine what you are trying to do that requires so many updates, since most information regarding 'what the client is doing' is already available to the server anyway.

The only thing I can think of is that perhaps you are trying to compare the client and server side data as a form of anti cheat but I highly doubt that is realistically achievable through event calls, considering latency and the slowness of lua.

Link to comment

I dont want to say, its stupid. You will laugh at me :P

But not that. There are some events I use clientSide that arn't serverSide but there not completly necessary. Just if you can, see if you can help me with this question, if not its ok. I'll figure something out :oops:

If I wanted to, what is the best way of retrieving data from clients as fast and smoothly as possible? Regular data, pretend the player is walking and I want to send information back everytime the player walks so far a distance, sometimes twice or three times faster than 450ms. What is the best way of getting that data from the client to the server everytime he passes that distance? Would it be what I have now?

Link to comment

Just useless data. :oops:

Don't make me so what it is. :cry:

I can think of four ways to do it, what do you guys think?

1. triggerServerEvent.

2. triggerClientEvent > triggerServerEvent.

3. setElementData ( element, key, true )

4. output to xml and read the data server side.

Any good, any of them? :?

Link to comment
Just useless data. :oops:

Don't make me so what it is. :cry:

I can think of four ways to do it, what do you guys think?

1. triggerServerEvent.

2. triggerClientEvent > triggerServerEvent.

3. setElementData ( element, key, true )

4. output to xml and read the data server side.

Any good, any of them? :?

I'd DEFINITELY choose for option 3. Is my answer correct? What do I win? :D

Not another fridge... Right..? :?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...