Posts: 775
Threads: 78
Joined: Dec 2014
Just saying, by the code you made, you will have a message saying that you're desynced all the time.
Because the drunk level is adjusted by the clients FPS, which is dynamic and changes all the time depending on how many frames there's.
So using the drunk level to check this is not a great idea.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Yes, but if you are desynced then SetPlayerDrunkLevel shouldn't work, means that drunklevel will be either the same or smaller when checking.
Posts: 775
Threads: 78
Joined: Dec 2014
Quote:
Originally Posted by GoldenLion
Yes, but if you are desynced then SetPlayerDrunkLevel shouldn't work, means that drunklevel will be either the same or smaller when checking.
|
You don't understand..
If I got 120 fps, which I do have, I will probably trigger your deysnced, because I will got -120 drunk level each second.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Uh, how else could I do that then? One guy on my Skype made that with drunk level and it worked perfectly.
Posts: 775
Threads: 78
Joined: Dec 2014
Quote:
Originally Posted by GoldenLion
Uh, how else could I do that then? One guy on my Skype made that with drunk level and it worked perfectly.
|
What's his FPS? If it's low, it'll work for him, but for people with like 100fps, like I have, they'll trigger it.
Try using some of the netstat functions.
https://sampwiki.blast.hk/wiki/Category:NetStats_Functions
But, if you make the timer 999 it might work, because the drunk level go down each second.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Uh, he was a scripter on a server, it didn't only work for him, but everyone including me.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Anyone? I really need that. :P Are there any other ways to detect desync? I don't want to set health or armor, etc. Also I think netstat functions have nothing to do with it. Or maybe someone knows how to fix my code?
Posts: 694
Threads: 2
Joined: Oct 2012
Reputation:
0
Well your code is pretty alright, only 1 thing is too much here,
drunklevel = GetPlayerDrunkLevel(playerid);
in the timer's public function makes it go too high, as a player would lose like 100 tops, then he would have 100 extra, these can easily add up to 2000 drunk level, which is the point which the screen starts shaking if a player is dysnced.
so remove the else clause, change the next line to
drunklevel = GetPlayerDrunkLevel(playerid)-200;
And it will be fixed.
Note that I'm just checking technical problems, I have no idea if this method will actually work for finding dysnced players.
Oh and btw using set and then get after that has a high chance of giving the old value since it's not updated for the player yet I guess.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Uh, seems to be good now, at least drunk level is not going high. Not sure if it works though.
Posts: 1,506
Threads: 13
Joined: Jun 2015
The best way to check for Desync or lagging players is to get their packet loss + ping.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Yes, but you may have high ping for a few seconds then back good again and you won't be desynced, that won't work I guess.
Posts: 1,506
Threads: 13
Joined: Jun 2015
but packetloss will work, if the packetloss reaches 0.5%+ then the player is going to be desync-ed or is desync.
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Is that true? If yes I'll do that.
Posts: 1,506
Threads: 13
Joined: Jun 2015
Yes it is, try searching for the function to get the packetloss of the player.
EDIT:
https://sampwiki.blast.hk/wiki/NetStats_PacketLossPercent
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
How much ping would a player have with 0.5%+ packet loss? I tried warning player of being desynced when their packetloss is 0.5%+, but when I spawn it tells me that while I'm not lagging at all. So I guess adding GetPlayerPing will fix it?
Posts: 1,506
Threads: 13
Joined: Jun 2015
Quote:
Originally Posted by GoldenLion
How much ping would a player have with 0.5%+ packet loss? I tried warning player of being desynced when their packetloss is 0.5%+, but when I spawn it tells me that while I'm not lagging at all. So I guess adding GetPlayerPing will fix it?
|
Packetloss is caused by not receiving the packets at the right time and causes the server to resend the packet. packetloss causes the desync, packetloss is caused by extreme ping or server lag. Go in a testing server which is hosted and download some stuff via torrent, steam or your browser or just simply, open all the wi-fi devices, press and hold F5 and you will see your connection info. There's not any specific ping where player will loose packet, its up to their connection and (or) or the server
Posts: 1,506
Threads: 13
Joined: Jun 2015
Quote:
Originally Posted by GoldenLion
How can I fix this then?
Here's the part of PlayerCheck, the timer repeats every second.
Code:
forward PlayerCheck();
public PlayerCheck()
{
foreach (new i : Player)
{
if (NetStats_PacketLossPercent(i) >= 0.5 && !PlayerData[i][pDesynced])
PlayerData[i][pDesynced] = true;
if (PlayerData[i][pDesynced])
GameTextForPlayer(i, "~w~You are desynced~n~Please relog as soon~n~as possible", 1200, 3);
}
}
|
A friend of mine runs a CoD server and he has scripted complete de-synchronization checker, I will ask him how he did that and run the timer every 5-10 seconds, packetloss doesn't increase that much in a second. Have you tried testing it on a hosted server and running some downloads or services which use internet?.
Testing code for debugging: using printf if the message is not sent.
Code:
forward PlayerCheck();
public PlayerCheck()
{
foreach (new i : Player)
{
if (NetStats_PacketLossPercent(i) >= 0.5 && !PlayerData[i][pDesynced])
PlayerData[i][pDesynced] = true;
if(PlayerData[i][pDesynced] && GetPlayerPing(i) >= 500)
SendClientMessage(playerid, -1, "Lost bravo");
printf("%d has lost bravo", i);
if(NetStats_PacketLossPercent(i) >= 1.0)
SendClientMessage(playerid, -1, "Lost alpha");
printf("%d has lost alpha", i);
if (PlayerData[i][pDesynced])
GameTextForPlayer(i, "~w~You are desynced~n~Please relog as soon~n~as possible", 1200, 3);
printf("%d has lost junior", i);
}
}
Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
Uh, how could I slow down connection? I got new internet it's 5x faster than the old one... Also when doing that with drunk level I had a separate timer at OnPlayerSpawn, but it was causing random lag.