Problem
#1

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.
Reply
#2

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)