11.04.2012, 19:45
Ta ae :
pawn Код:
#include <a_samp>
new Text: textFPS[MAX_PLAYERS];
new Text:FPS[MAX_PLAYERS];
new DLlast[MAX_PLAYERS];
new FPS2[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(FPS[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,FPS[playerid]);
return 1;
}
public OnFilterScriptInit()
{
SetTimer("fpsCheck", 100, true);
for(new i=0; i<MAX_PLAYERS; i++)
{
textFPS[i] = TextDrawCreate(199.000000, 375.000000, " ");
TextDrawAlignment(textFPS[i], 3);
TextDrawBackgroundColor(textFPS[i], 0xFF8000FF);
TextDrawFont(textFPS[i], 3);
TextDrawLetterSize(textFPS[i], 0.389999, 0.899999);
TextDrawColor(textFPS[i], 0x000000f6);
TextDrawSetOutline(textFPS[i], 1);
TextDrawSetProportional(textFPS[i], 1);
}
return 1;
}
public OnPlayerUpdate(playerid)
{
new drunk2 = GetPlayerDrunkLevel(playerid);
if(drunk2 < 100)
{
SetPlayerDrunkLevel(playerid,2000);
}
else
{
if(DLlast[playerid] != drunk2)
{
new fps = DLlast[playerid] - drunk2;
if((fps > 0) && (fps < 200))
FPS2[playerid] = fps;
DLlast[playerid] = drunk2;
}
}
return 1;
}
forward fpsCheck();
public fpsCheck()
{
for(new i; i != GetMaxPlayers(); ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
if(GetPVarInt(i, "spawned"))
{
SetPVarInt(i, "drunkLevel", GetPlayerDrunkLevel(i));
if(GetPVarInt(i, "drunkLevel") < 100)
{
SetPlayerDrunkLevel(i, 2000);
}
else
{
if(GetPVarInt(i, "lastDrunkLevel") != GetPVarInt(i, "drunkLevel"))
{
SetPVarInt(i, "fps", (GetPVarInt(i, "lastDrunkLevel") - GetPVarInt(i, "drunkLevel")));
SetPVarInt(i, "lastDrunkLevel", GetPVarInt(i, "drunkLevel"));
if((GetPVarInt(i, "fps") > 0) && (GetPVarInt(i, "fps") < 256))
{
new string[24];
format(string, sizeof(string),"FPS: %d", GetPVarInt(i, "fps") - 1);
TextDrawSetString(textFPS[i], string);
TextDrawShowForPlayer(i, textFPS[i]);
}
}
}
}
else
{
TextDrawHideForPlayer(i, textFPS[i]);
}
}
}
return 1;
}