SA-MP Forums Archive
Bug in my FPS kicker - 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: Bug in my FPS kicker (/showthread.php?tid=236922)



Bug in my FPS kicker - OldDirtyBastard - 08.03.2011

I am trying to make a FPS kicker with the stock GetPlayerFPS function from [FeK]DraKiNs

Quote:
Originally Posted by [FeK]DraKiNs
Посмотреть сообщение
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;
}
My code:

pawn Код:
if(GetPlayerFPS(playerid) < 22)
{
    fpswarning(playerid);
    SendClientMessage(playerid,COLOR_RED,"WARNING: Your FPS is lower then the minimum ammount of circa 25 FPS, you have 10 seconds to establish your FPS or else you will get kicked.");
}
The bug is that it keeps kicking me at connecting and at class selection even tho my FPS is 40+ all the time.
Anyone plase give me some advices how to fix this bug.
Thanks regards.


Re: Bug in my FPS kicker - Fool - 08.03.2011

set it to about 10 FPs. and change it to OnplayerUpdate. That Would Be better.


Re: Bug in my FPS kicker - Stigg - 08.03.2011

You could try using the function after a player connects. Set a timer or something.


Re: Bug in my FPS kicker - OldDirtyBastard - 08.03.2011

Quote:
Originally Posted by Porsche911
Посмотреть сообщение
set it to about 10 FPs. and change it to OnplayerUpdate. That Would Be better.
I dislike to set things at OnplayerUpdate since the callback gets called like 30 times per second,
also dont wanna lower the minimum FPS since the fpslimit 20 gets abused.


Re: Bug in my FPS kicker - Stigg - 08.03.2011

Cant you just start calling the function with a timer set to go off 1 min after players connects ?
It should stop the bugging out.


Re: Bug in my FPS kicker - OldDirtyBastard - 08.03.2011

Like making an Array to the GetPlayerFPS and set the Array to false at OnPlayerConnect and at OnPlayerSpawn set the Array to true?


Re: Bug in my FPS kicker - Mean - 08.03.2011

Actually OnPlayerUpdate gets called 100+ times a sec.
You can make an EX update
pawn Код:
public OnPlayerConnect( playerid )
{
    SetTimerEx( "OnPlayerUpdateEx", 1000, 1, "i", playerid );
    return 1;
}
later, replace your OnPlayerUpdate with this
pawn Код:
forward OnPlayerUpdateEx( playerid );
public OnPlayerUpdateEx( playerid )
{
    // Your OnPlayerUpdate code.
    return 1;
}