14.05.2013, 15:35
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?
#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;
}
|
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. |