#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;
}
|
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?
|
|
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. |
|
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. |