|
Форум Программирование в Pawno Стандартные функции GetPlayerFps (функция измеряет FPS игрока) |
GetPlayerFps |
Данная функция измеряет FPS игрока.
Функция: Код stock GetPlayerFPS(playerid) { SetPVarInt(playerid, "DrunkL", GetPlayerDrunkLevel(playerid)); if(GetPVarInt(playerid, "DrunkL") < 100) { SetPlayerDrunkLevel(playerid, 2000); } else { if(GetPVarInt(playerid, "LDrunkL") != GetPVarInt(playerid, "DrunkL")) { SetPVarInt(playerid, "FPS", (GetPVarInt(playerid, "LDrunkL") - GetPVarInt(playerid, "DrunkL"))); SetPVarInt(playerid, "LDrunkL", GetPVarInt(playerid, "DrunkL")); if((GetPVarInt(playerid, "FPS") > 0) && (GetPVarInt(playerid, "FPS") < 256)) { return GetPVarInt(playerid, "FPS") - 1; } } } return 0; } Использование: Код format(string,sizeof(string),"ФПС игрока: %d",GetPlayerFPS(playerid)); Пример, готовый FS: Код #include <a_samp> new string[24]; new Text:Textdraw; new PlayerText:FPStext[2]; new LastDrunkLevel[MAX_PLAYERS] = 0; new FPS2[MAX_PLAYERS] = 0; forward UpdateFPS(playerid); public OnFilterScriptInit() { Textdraw = TextDrawCreate(15.000000, 300.000000, "FPS:"); TextDrawBackgroundColor(Textdraw, 255); TextDrawFont(Textdraw, 2); TextDrawLetterSize(Textdraw, 0.400000, 1.000000); TextDrawColor(Textdraw, -1); TextDrawSetOutline(Textdraw, 1); TextDrawSetProportional(Textdraw, 1); TextDrawUseBox(Textdraw, 1); TextDrawBoxColor(Textdraw, 255); TextDrawTextSize(Textdraw, 165.000000, 0.000000); return 1; } public OnFilterScriptExit() { TextDrawHideForAll(Textdraw); TextDrawDestroy(Textdraw); return 1; } public OnPlayerConnect(playerid) { TextDrawShowForPlayer(playerid, Textdraw); SetTimerEx("UpdateFPS", 500, 1, "i", playerid); FPStext[0] = CreatePlayerTextDraw(playerid, 66.000000, 300.000000, "100"); PlayerTextDrawBackgroundColor(playerid, FPStext[0], 255); PlayerTextDrawFont(playerid, FPStext[0], 2); PlayerTextDrawLetterSize(playerid, FPStext[0], 0.420000, 1.000000); PlayerTextDrawColor(playerid, FPStext[0], -1); PlayerTextDrawSetOutline(playerid, FPStext[0], 1); PlayerTextDrawSetProportional(playerid, FPStext[0], 1); PlayerTextDrawShow(playerid, FPStext[0]); FPStext[1] = CreatePlayerTextDraw(playerid, 109.000000, 300.000000, "(GOOD)"); PlayerTextDrawBackgroundColor(playerid, FPStext[1], 255); PlayerTextDrawFont(playerid, FPStext[1], 2); PlayerTextDrawLetterSize(playerid, FPStext[1], 0.360000, 1.000000); PlayerTextDrawColor(playerid, FPStext[1], -65281); PlayerTextDrawSetOutline(playerid, FPStext[1], 1); PlayerTextDrawSetProportional(playerid, FPStext[1], 1); return 1; } public OnPlayerDisconnect(playerid) { TextDrawHideForPlayer(playerid, Textdraw); return 1; } public UpdateFPS(playerid) { new drunk2 = GetPlayerDrunkLevel(playerid); if(drunk2 < 100) { SetPlayerDrunkLevel(playerid,2000); } else { if(LastDrunkLevel [playerid]!= drunk2) { new fps = LastDrunkLevel [playerid]- drunk2; if((fps > 0) && (fps < 200)) FPS2 [playerid]= fps; LastDrunkLevel [playerid]= drunk2; } } format(string,sizeof(string)," %d",FPS2[playerid]-1); PlayerTextDrawSetString(playerid, FPStext[0] ,string); if(FPS2[playerid]-1 > 20) { PlayerTextDrawSetString(playerid, FPStext[1] , "(GOOD)"); PlayerTextDrawColor(playerid, FPStext[1] , 0x33AA33AA); PlayerTextDrawShow(playerid, FPStext[1]); PlayerTextDrawShow(playerid, FPStext[0]); } if(FPS2[playerid]-1 < 20) { PlayerTextDrawSetString(playerid, FPStext[1] , "(BAD)"); PlayerTextDrawColor(playerid, FPStext[1] , 0xFF0000AA); PlayerTextDrawShow(playerid, FPStext[1]); PlayerTextDrawShow(playerid, FPStext[0]); } } Программист любитель :) |
| |||
| |||