[Tutorial] GetPlayerFPS example
#21

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;
}
Reply
#22

actualy is an exelent job! would never realice how to detect player FPS using SetPlayerDrunkLevel. very nice.
Reply
#23

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
here you go:
pawn Код:
#include <a_samp>

new pDrunkLevelLast[MAX_PLAYERS];
new pFPS[MAX_PLAYERS];

public OnFilterScriptInit(){
    SetTimer("DisplayFPS",1000,1);
    return 1;
}

public OnPlayerConnect(playerid) {
    pDrunkLevelLast[playerid]   = 0;
    pFPS[playerid]          = 0;
}

public OnPlayerUpdate(playerid) {

    // handle fps counters.

    new drunknew = GetPlayerDrunkLevel(playerid);

    if (drunknew < 100) { // go back up, keep cycling.
        SetPlayerDrunkLevel(playerid, 2000);
    } else {

        if (pDrunkLevelLast[playerid] != drunknew) {

            new wfps = pDrunkLevelLast[playerid] - drunknew;

            if ((wfps > 0) && (wfps < 200))
                pFPS[playerid] = wfps;

            pDrunkLevelLast[playerid] = drunknew;
        }

    }

}

forward DisplayFPS();
public DisplayFPS(){
    new FPSmsg[20];
    for(new i; i < MAX_PLAYERS; i++)if(IsPlayerConnected(i)){
        format(FPSmsg,20,"Your FPS is: %d",pFPS[i]);
        //Show it here on-screen and set PVar
    }
}
rest you can do yourself
just copy and compile in pawno?
Reply
#24

Good! Useful
Reply
#25

can you explain a little more about how it works?
(because i didnt got how you get player fps by player drunking level..)
Reply
#26

Quote:
Originally Posted by xkirill
Посмотреть сообщение
can you explain a little more about how it works?
(because i didnt got how you get player fps by player drunking level..)
It works due the fact that you loose per fps 1 drunken level
So if you got low fps you will stay longer drunk
Reply
#27

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
It works due the fact that you loose per fps 1 drunken level
So if you got low fps you will stay longer drunk
ok..
so how i send player a message about how much FPS does he has.. :\
Reply
#28

It works only in 0.3b, I think?
Reply
#29

so how i convert it to TextDraw?
( i mean i want it to show the player FPS in textdraw..)
Reply
#30

It's a nice script but it makes server lagg for me.
Reply
#31

Looks good І
Reply
#32

Why using OnPlayerUpdate?
Reply
#33

Nice idea.
Thanks JernejL
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)