Connection bar -
Lokii - 04.05.2018
CREDITS
SA-MP TEAM for a_samp
ME for Connection bars
ADRI1 for His text draw editor
GAMMIX for Helping
POTTUS for Helping
Re: Connection bar -
CrystalGamer - 04.05.2018
wow such a good job
Re: Connection bar -
Matz - 04.05.2018
Looks good! Though, I would prefer something like going from green to red (with accent colours)
Re: Connection bar -
Gammix - 04.05.2018
Why create PlayerTextDraws? You know you can achieve this with global textdraws!
Whenever you change a property of any textdraw (global or player), property like color, fontsize etc. all expect string, the effect is shown when you reshow the textdraw to player.
So if you change color and reshow to one player, the property is only changed for that player only (according to wiki).
PHP Code:
// example
TextDrawColor(textdraw, 0xFF0000FF);
TextDrawShowForAll(textdraw); // red color is shown for all players
TextDrawColor(textdraw, 0x00FF00FF);
// above: only id 0 and 15 will have green color
TextDrawShowForPlayer(0, textdraw);
TextDrawShowForPlayer(15, textdraw);
Re: Connection bar -
AzaMx - 05.05.2018
Good job!
Re: Connection bar -
Pottus - 05.05.2018
1.) Ping does not determine packet consistency (health) of a connection so this is a misleading conception of a players connection status. Maybe you should look at multiple factors and characteristics to sum up a better image of connection status.
2.) You are already aware of the textdraw type issue but there is also something else to look at. Why bother doing any updates if the players ping is still in the range of the last check? You are always updating regardless if the result was the same as last time.
Consider the following it needs to be finished/implemented some more that is your job
Code:
// Define different ping level states
#define PING_LEVEL_UPDATE -1
#define PING_LEVEL_1 0
#define PING_LEVEL_2 1
#define PING_LEVEL_3 3
#define PING_LEVEL_4 4
#define PING_LEVEL_5 5
// Keep track of the players current level
static PingLevel[MAX_PLAYERS] = { -1, ...};
// Ping level color table (finish updating this)
static PingLevelColors[][5] = {
{ 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF },
{ 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF },
{ 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF },
{ 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF },
{ 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF, 0x3692EDFF }
};
// Set the last update to an arbitrary update value forcing an auto-update
// no matter what
public OnPlayerDisconnect(playerid)
{
PingLevel[playerid] = PING_LEVEL_UPDATE;
return 1;
}
public WifiCheck()
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
// Only update IF the pings were different
if(GetPlayerPing(i) >= 0 && GetPlayerPing(i) < 201 && PingLevel[i] != PING_LEVEL_1)
{
PingLevel[i] = PING_LEVEL_1;
// No need to repeat code over and over when all we need is one versile function!
UpdateConnectionStatus(i, PING_LEVEL_1);
}
else if(GetPlayerPing(i) >= 201 && GetPlayerPing(i) < 401 && PingLevel[i] != PING_LEVEL_2)
{
PingLevel[i] = PING_LEVEL_2;
UpdateConnectionStatus(i, PING_LEVEL_2);
}
else if(GetPlayerPing(i) >= 401 && GetPlayerPing(i) < 551 && PingLevel[i] != PING_LEVEL_3)
{
PingLevel[i] = PING_LEVEL_3;
UpdateConnectionStatus(i, PING_LEVEL_3);
}
else if(GetPlayerPing(i) >= 551 && GetPlayerPing(i) < 701 && PingLevel[i] != PING_LEVEL_4)
{
PingLevel[i] = PING_LEVEL_4;
UpdateConnectionStatus(i, PING_LEVEL_4);
}
// Dont need to check if it is greater than 701 since WE KNOW IT IS!
else if(PingLevel[i] != PING_LEVEL_5)
{
PingLevel[i] = PING_LEVEL_5;
UpdateConnectionStatus(i, PING_LEVEL_5);
}
}
return 1;
}
static UpdateConnectionStatus(playerid, level)
{
PlayerTextDrawHide(playerid, Bar1[playerid]);
PlayerTextDrawHide(playerid, Bar2[playerid]);
PlayerTextDrawHide(playerid, Bar3[playerid]);
PlayerTextDrawHide(playerid, Bar4[playerid]);
PlayerTextDrawHide(playerid, Bar5[playerid]);
// Reference color array again no repeat code!
PlayerTextDrawBoxColor(playerid, Bar1[playerid], PingLevelColors[level][0]);
PlayerTextDrawBoxColor(playerid, Bar2[playerid], PingLevelColors[level][1]);
PlayerTextDrawBoxColor(playerid, Bar3[playerid], PingLevelColors[level][2]);
PlayerTextDrawBoxColor(playerid, Bar4[playerid], PingLevelColors[level][3]);
PlayerTextDrawBoxColor(playerid, Bar5[playerid], PingLevelColors[level][4]);
PlayerTextDrawShow(playerid, Bar1[playerid]);
PlayerTextDrawShow(playerid, Bar2[playerid]);
PlayerTextDrawShow(playerid, Bar3[playerid]);
PlayerTextDrawShow(playerid, Bar4[playerid]);
PlayerTextDrawShow(playerid, Bar5[playerid]);
return 1;
}
Re: Connection bar -
jlalt - 05.05.2018
I m p r e s s i v e. Btw pottus why to call a function over 90 times per a check while you can store it in a var and use that var?
new pping = GetPlayerPing(i);
And later... pping >= x...
Won't that make it a bit more optimized?
Re: Connection bar -
xMoBi - 05.05.2018
repeating code is awful that is why pottus said that
Re: Connection bar -
Lokii - 05.05.2018
Thanks all
UPDATE:
CREDITS
GAMMIX for helping
POTTUS for helping
@pottus i changed
PHP Code:
// Dont need to check if it is greater than 701 since WE KNOW IT IS!
else if(PingLevel[i] != PING_LEVEL_5)
to
PHP Code:
else if(GetPlayerPing(i) > 700 && PingLevel[i] != PING_LEVEL_5)
it conflict!
it would show 5 bars and a sec later 1 bar over and over again
DOWNLOAD
max bars are in blue
@Matz
max bars are in green color as u asked
DOWNLOAD
Re: Connection bar -
Pottus - 05.05.2018
Okay all good I didn't test! But it's good you fixed it good training for you.