new Text:FPS; FPS = TextDrawCreate(497.000000, 163.000000, "FPS:"); TextDrawBackgroundColor(FPS, 255); TextDrawFont(FPS, 3); TextDrawLetterSize(FPS, 0.500000, 1.000000); TextDrawColor(FPS, -65281); TextDrawSetOutline(FPS, 0); TextDrawSetProportional(FPS, 1); TextDrawSetShadow(FPS, 1); public OnPlayerUpdate(playerid) { new string[128]; new fps; fps = GetPlayerFPS(playerid); format(string, sizeof string, "FPS: %d", fps); TextDrawSetString(FPS, string); return 1; }
Show the function that's getting the players FPS - and also... Don't use OnPlayerUpdate for anything really, unless absolutely necessary.
|
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; }
stock GetPlayerFPS(playerid)
{
new
drunk = GetPlayerDrunkLevel(playerid),
fps = (GetPVarInt(playerid, "DrunkLevel") - drunk);
if(drunk < 100) {
SetPlayerDrunkLevel(playerid, 2000);
SetPVarInt(playerid, "DrunkLevel", 2000);
} else {
SetPVarInt(playerid, "DrunkLevel", drunk);
}
return fps;
}
new Text:FPS[MAX_PLAYERS];
FPS[playerid] = TextDrawCreate(497.000000, 163.000000, "FPS:");
The guy who wrote that rly likes pvar
pawn Код:
|
I tried this and it shows the FPS 2000 and it keeps changing to 0 every second like before. Do I have to use something else instead of OnPlayerUpdate?
|
stock GetPlayerFPS(playerid)
{ // forum.sa-mp.com/showpost.php?p=1167812&postcount=7
new
drunk = GetPlayerDrunkLevel(playerid);
if(GetPVarInt(playerid, "DrunkLevel") != drunk) {
SetPVarInt(playerid, "FPS", (GetPVarInt(playerid, "DrunkLevel") - drunk));
}
if(drunk < 100) {
SetPlayerDrunkLevel(playerid, 2000);
SetPVarInt(playerid, "DrunkLevel", 2000);
} else {
SetPVarInt(playerid, "DrunkLevel", drunk);
}
return GetPVarInt(playerid, "FPS");
}
Yeah I forgot something important
pawn Код:
|
Well it kind of works it shows FPS for a second then it shows 2000 and it goes back and forth any more ideas?And also someone said not to use OnPlayerUpdate do i change it? and if so to what.
|
stock GetPlayerFPS(playerid) //no one time usage (needs to be in a timer)
{ //forum.sa-mp.com/showpost.php?p=1167870&postcount=9
new
drunk = GetPlayerDrunkLevel(playerid);
if(GetPVarInt(playerid, "DrunkLevel") != drunk) {
if(GetPVarInt(playerid, "DrunkLevel") == 2000) {
if(drunk > 100) {
SetPVarInt(playerid, "DrunkLevel", drunk);
}
return GetPVarInt(playerid, "FPS");
} else {
SetPVarInt(playerid, "FPS", (GetPVarInt(playerid, "DrunkLevel") - drunk));
}
}
if(drunk < 100) {
SetPlayerDrunkLevel(playerid, 2000);
SetPVarInt(playerid, "DrunkLevel", 2000);
} else {
SetPVarInt(playerid, "DrunkLevel", drunk);
}
return GetPVarInt(playerid, "FPS");
}
//To start the timer
SetTimer("MyTimer", 1000, true);
forward MyTimer();
public MyTimer()
{
for(new i; i != MAX_PLAYERS; ++i)
{ //foreach if possible
if(IsPlayerConnected(i))
{
//your code
}
}
}
Also make a textdraw for every player.
pawn Код:
pawn Код:
|