I haven't looked too much into this code, so it might not be an issue, but otherwise the problem with this method is that it can ruin actual drunk levels.
And also it wont work when you're ethically spectating, it'll just show -1. |
#include <a_samp>
#define function%0(%1) forward%0(%1); public%0(%1)
new Text:tFPS,
PlayerText:ptFPS[2],
pLastDrunkLevel[MAX_PLAYERS],
pFPS[MAX_PLAYERS];
public OnFilterScriptInit()
{
tFPS = TextDrawCreate(15.000000, 300.000000, "FPS:");
TextDrawBackgroundColor(tFPS, 255);
TextDrawFont(tFPS, 2);
TextDrawLetterSize(tFPS, 0.400000, 1.000000);
TextDrawColor(tFPS, -1);
TextDrawSetOutline(tFPS, 1);
TextDrawSetProportional(tFPS, 1);
TextDrawUseBox(tFPS, 1);
TextDrawBoxColor(tFPS, 255);
TextDrawTextSize(tFPS, 165.000000, 0.000000);
return 1;
}
public OnFilterScriptExit()
{
TextDrawHideForAll(tFPS);
TextDrawDestroy(tFPS);
return 1;
}
public OnPlayerConnect(playerid)
{
ptFPS[0] = CreatePlayerTextDraw(playerid, 66.000000, 300.000000, "100");
PlayerTextDrawBackgroundColor(playerid, ptFPS[0], 255);
PlayerTextDrawFont(playerid, ptFPS[0], 2);
PlayerTextDrawLetterSize(playerid, ptFPS[0], 0.420000, 1.000000);
PlayerTextDrawColor(playerid, ptFPS[0], -1);
PlayerTextDrawSetOutline(playerid, ptFPS[0], 1);
PlayerTextDrawSetProportional(playerid, ptFPS[0], 1);
PlayerTextDrawShow(playerid, ptFPS[0]);
ptFPS[1] = CreatePlayerTextDraw(playerid, 109.000000, 300.000000, "(GOOD)");
PlayerTextDrawBackgroundColor(playerid, ptFPS[1], 255);
PlayerTextDrawFont(playerid, ptFPS[1], 2);
PlayerTextDrawLetterSize(playerid, ptFPS[1], 0.360000, 1.000000);
PlayerTextDrawColor(playerid, ptFPS[1], -65281);
PlayerTextDrawSetOutline(playerid, ptFPS[1], 1);
PlayerTextDrawSetProportional(playerid, ptFPS[1], 1);
return 1;
}
public OnPlayerDisconnect(playerid)
{
TextDrawHideForPlayer(playerid, tFPS);
return 1;
}
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, tFPS);
for(new i = 0; i < 2; i ++) PlayerTextDrawShow(playerid, ptFPS[i]);
SetTimerEx("UpdateFPS", 500, true, "i", playerid);
return 1;
}
function UpdateFPS(playerid)
{
new string[10], olddrunklevel = pLastDrunkLevel[playerid], newdrunklevel = GetPlayerDrunkLevel(playerid);
if(newdrunklevel < 100) SetPlayerDrunkLevel(playerid, 2000);
else
{
if(olddrunklevel != newdrunklevel)
{
new temp = olddrunklevel - newdrunklevel;
if(temp > 0 && temp < 100) pFPS[playerid] = temp;
pLastDrunkLevel[playerid] = newdrunklevel;
}
}
format(string, sizeof(string), "%d", pFPS[playerid]);
PlayerTextDrawSetString(playerid, ptFPS[0], string);
if(pFPS[playerid] > 20)
{
PlayerTextDrawSetString(playerid, ptFPS[1] , "(GOOD)");
PlayerTextDrawColor(playerid, ptFPS[1] , 0x33AA33AA);
}
else if(pFPS[playerid] < 20)
{
PlayerTextDrawSetString(playerid, ptFPS[1] , "(BAD)");
PlayerTextDrawColor(playerid, ptFPS[1] , 0xFF0000AA);
}
for(new i = 0; i < 2; i ++) PlayerTextDrawShow(playerid, ptFPS[i]);
return 1;
}