SA-MP Forums Archive
How to get Fps - 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)
+--- Thread: How to get Fps (/showthread.php?tid=437175)



How to get Fps - DetoNater - 14.05.2013

How to get our own Fps in the screen with textdraw's, i know it could be done using drunk levels but SetPlayerDrunkLevel(Playerid, 2000) is accurate only for 0.3b but how to get it accurate for 0.3x?


AW: How to get Fps - [AK]Nazgul - 14.05.2013

I have been using the SetPlayerDrunkLevel way for a while and it always perfectly matched with fraps's fps. It's accurate for me


Re: How to get Fps - DeMoX - 14.05.2013

pawn Код:
#include <a_samp>

new Text:FPS[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(523.000000, 1.000000, "FPS : Loading");
    TextDrawBackgroundColor(FPS[playerid], 255);
    TextDrawFont(FPS[playerid], 1);
    TextDrawLetterSize(FPS[playerid], 0.500000, 1.000000);
    TextDrawColor(FPS[playerid], 16711935);
    TextDrawSetOutline(FPS[playerid], 1);
    TextDrawSetProportional(FPS[playerid], 1);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    TextDrawHideForPlayer(playerid, FPS[playerid]);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, FPS[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    new string[128];
    format(string, sizeof(string), "FPS: %d", GetPlayerFPS(playerid));
    TextDrawSetString(FPS[playerid], string);
    return 1;
}

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;
}



Re: How to get Fps - Pottus - 14.05.2013

Don't use PVARS in that function since it's called a lot from OnPlayerUpdate() it's a bad idea it will be very inefficient.


Re: How to get Fps - DeMoX - 14.05.2013

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Don't use PVARS in that function since it's called a lot from OnPlayerUpdate() it's a bad idea it will be very inefficient.
IDK, it's working perfectly for me, what do you suggest? :/ what i must modify?


Re: How to get Fps - Kwarde - 14.05.2013

Quote:
Originally Posted by DeMoX
Посмотреть сообщение
IDK, it's working perfectly for me, what do you suggest? :/ what i must modify?
Well, PVars are just slower then variables. I've ever seen a topic of ****** where he's explaining that PVars mostly are usefull either for very big strings (which doesn't happen alot) or for using it in extern scripts too.
So you could use, for example, static variables.


Re: How to get Fps - DeMoX - 14.05.2013

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Well, PVars are just slower then variables. I've ever seen a topic of ****** where he's explaining that PVars mostly are usefull either for very big strings (which doesn't happen alot) or for using it in extern scripts too.
So you could use, for example, static variables.
Can you give me the link of that topic?


Re: How to get Fps - Pottus - 14.05.2013

Basically.....

SetPVarInt(playerid, "DrunkL", GetPlayerDrunkLevel(playerid)); becomes....

new DrunkL = GetPlayerDrunkLevel(playerid);

and

GetPVarInt(playerid, "LDrunkL") becomes

new LDrunkL[MAX_PLAYERS]; // Defined above the function

Your simply swapping the PVars with variables.


Re: How to get Fps - DeMoX - 14.05.2013

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Basically.....

SetPVarInt(playerid, "DrunkL", GetPlayerDrunkLevel(playerid)); becomes....

new DrunkL = GetPlayerDrunkLevel(playerid);

and

GetPVarInt(playerid, "LDrunkL") becomes

new LDrunkL[MAX_PLAYERS]; // Defined above the function

Your simply swapping the PVars with variables.
Thanks a lot i'll try it


Re: How to get Fps - Kwarde - 15.05.2013

Quote:
Originally Posted by DeMoX
Посмотреть сообщение
Can you give me the link of that topic?
Well off course: forum.sa-mp.com/showthread.php?t=268499