11.01.2014, 21:38
pawn Код:
#include <a_samp>
enum PlayerVariables
{
DLlast,
FPS,
bool:OptionFPS
}
new Player[MAX_PLAYERS][PlayerVariables], Text3D:PingFPS[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("FPSupdate", 1000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
Player[playerid][OptionFPS] = false;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
Delete3DTextLabel(PingFPS[playerid]);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/pfp", cmdtext, true, 4) == 0)
{
switch(Player[playerid][OptionFPS])
{
case false:
{
SendClientMessage(playerid, -1, "You have enabled the FPS.");
Player[playerid][OptionFPS] = true;
PingFPS[playerid] = Create3DTextLabel("_", 0x00FF00FF, 0, 0, 0, 10.0, 0, 1);
}
case true:
{
SendClientMessage(playerid, -1, "You have disabled the FPS.");
Player[playerid][OptionFPS] = false;
Delete3DTextLabel(PingFPS[playerid]);
}
}
return 1;
}
return 0;
}
forward FPSupdate();
public FPSupdate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Player[i][OptionFPS] == true)
{
GetPlayerFPS(i);
new iString[256];
new pPing = GetPlayerPing(i);
format(iString, sizeof(iString), "Ping: {FFFFFF}%i\nFPS: {FFFFFF}%i", pPing, Player[i][FPS]);
Update3DTextLabelText(PingFPS[i], 0x00FF00FF, iString);
Attach3DTextLabelToPlayer(PingFPS[i], i, 0.0, 0.0, -0.745);
}
}
}
stock GetPlayerFPS(playerid)
{
new drunk2 = GetPlayerDrunkLevel(playerid);
if(drunk2 < 100)
{
SetPlayerDrunkLevel(playerid,2000);
}
else
{
if(Player[playerid][DLlast] != drunk2)
{
new fps = Player[playerid][DLlast] - drunk2;
if((fps > 0) && (fps < 200))
Player[playerid][FPS] = fps;
Player[playerid][DLlast] = drunk2;
}
}
}