Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Pedido by: Shinjuku, fórum sa-mp.
- Coded by: Willian_Luigi.
- --------------
- função: Pegar o PacketLoss do player e exibi-lo em um textdraw.
- */
- #include <a_samp>
- main() print("Initialization.");
- new Text: Draw[MAX_PLAYERS];
- stock Float:GetPlayerPacketLoss(playerid)
- {
- new stats[401], stringstats[70];
- GetPlayerNetworkStats(playerid, stats, sizeof(stats));
- new len = strfind(stats, "Packetloss: ");
- new Float:packetloss = 0.0;
- if(len != -1)
- {
- strmid(stringstats, stats, len, strlen(stats));
- new len2 = strfind(stringstats, "%");
- if(len != -1)
- {
- strdel(stats, 0, strlen(stats));
- strmid(stats, stringstats, len2-3, len2);
- packetloss = floatstr(stats);
- }
- }
- return packetloss;
- }
- public OnGameModeInit()
- {
- for (new i = 0, j = GetMaxPlayers(); i < j; ++i)
- Draw[i] = TextDrawCreate(250, 30, "packet loss loading...");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TogglePlayerClock(playerid, 1);
- TextDrawShowForPlayer(playerid, Draw[playerid]);
- }
- public OnPlayerUpdate(playerid)
- {
- new
- sStr[10],
- Float:sPacketLoss[MAX_PLAYERS];
- sPacketLoss[playerid] = GetPlayerPacketLoss(playerid);
- format(sStr, 10, "%0.1f", sPacketLoss[playerid]);
- TextDrawSetString(Draw[playerid], sStr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement