Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem (
/showthread.php?tid=260489)
Problem -
Face9000 - 09.06.2011
Hi guys,i've created a textdraw to show my FPS but i've got a problem.
The Textdraw shows only: Your FPS: 0.
Here is the code:
new Text:FPSTD;
OnGameModeInit
pawn Код:
FPSTD = TextDrawCreate(500.000000, 101.000000, "Your FPS:");
TextDrawBackgroundColor(FPSTD, 255);
TextDrawFont(FPSTD, 1);
TextDrawLetterSize(FPSTD, 0.449999, 1.799999);
TextDrawColor(FPSTD, -16776961);
TextDrawSetOutline(FPSTD, 1);
TextDrawSetProportional(FPSTD, 1);
OnPlayerConnect
pawn Код:
new newtext[128];
format(newtext, sizeof(newtext), "Your FPS: %d", GetPlayerFPS(playerid));
TextDrawSetString(FPSTD, newtext);
TextDrawShowForPlayer(playerid, FPSTD);
The stock:
pawn Код:
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;
}
Thanks.
Re: Problem -
*IsBack - 09.06.2011
Quote:
Originally Posted by Logitech90
a huge quotation
|
Make a repeating timer (every 1sec (1000ms)) and put it OnPlayerSpawn/Connect callback. Don't forget to destroy it on OnPlayerDisconnect callback!
Put this code in it:
pawn Код:
new newtext[128];
format(newtext, sizeof(newtext), "Your FPS: %d", GetPlayerFPS(playerid));
TextDrawSetString(FPSTD[playerid], newtext);
And also (very important):
You got this on your script:
new Text:FPSTD;
but you must change it to
new Text:FPSTD[MAX_PLAYERS];
and use it as FPSTD[playerid] (like in my code above) or else it will show the same string to all the players!