fps with command
#1

Hello,
i want to make this player fps for can active & disable with command /pfp here is code
pawn Код:
#include <a_samp>

enum PlayerVariables
{
DLlast,
FPS
}
new Player[MAX_PLAYERS][PlayerVariables];
new Text3D:PingFPS[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("FPSupdate", 1000, true);
    return 1;
}

public OnPlayerConnect(playerid)
{
    PingFPS[playerid] = Create3DTextLabel("_", 0x00FF00FF, 0, 0, 0, 10.0, 0, 1);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Delete3DTextLabel(PingFPS[playerid]);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
  // Do something here
        return 1;
    }
    return 0;
}
forward FPSupdate();
public FPSupdate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerFPS(i);
new iString[256];
new pPing = GetPlayerPing(i);
format(iString, sizeof(iString), "Ping: {FFFFFF}%i\nFPS: {FFFFFF}%i", pPing, Player[i][FPS]);
Update3DTextLabelText(PingFPS[i], 0x00FF00FF, iString);
Attach3DTextLabelToPlayer(PingFPS[i], i, 0.0, 0.0, -0.745);
}
}
stock GetPlayerFPS(playerid)
{
    new drunk2 = GetPlayerDrunkLevel(playerid);
    if(drunk2 < 100){
        SetPlayerDrunkLevel(playerid,2000);
    }else{
        if(Player[playerid][DLlast] != drunk2){
            new fps = Player[playerid][DLlast] - drunk2;
            if((fps > 0) && (fps < 200))
            Player[playerid][FPS] = fps;
            Player[playerid][DLlast] = drunk2;
        }
    }
}
Reply
#2

bump
Reply
#3

pawn Код:
#include <a_samp>

enum PlayerVariables
{
    DLlast,
    FPS,
    bool:OptionFPS
}

new Player[MAX_PLAYERS][PlayerVariables], Text3D:PingFPS[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("FPSupdate", 1000, true);
    return 1;
}

public OnPlayerConnect(playerid)
{
    Player[playerid][OptionFPS] = false;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Delete3DTextLabel(PingFPS[playerid]);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/pfp", cmdtext, true, 4) == 0)
    {
        switch(Player[playerid][OptionFPS])
        {
            case false:
            {
                SendClientMessage(playerid, -1, "You have enabled the FPS.");
                Player[playerid][OptionFPS] = true;
                PingFPS[playerid] = Create3DTextLabel("_", 0x00FF00FF, 0, 0, 0, 10.0, 0, 1);
            }
            case true:
            {
                SendClientMessage(playerid, -1, "You have disabled the FPS.");
                Player[playerid][OptionFPS] = false;
                Delete3DTextLabel(PingFPS[playerid]);
            }
        }
        return 1;
    }
    return 0;
}

forward FPSupdate();
public FPSupdate()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Player[i][OptionFPS] == true)
        {
            GetPlayerFPS(i);
            new iString[256];
            new pPing = GetPlayerPing(i);
            format(iString, sizeof(iString), "Ping: {FFFFFF}%i\nFPS: {FFFFFF}%i", pPing, Player[i][FPS]);
            Update3DTextLabelText(PingFPS[i], 0x00FF00FF, iString);
            Attach3DTextLabelToPlayer(PingFPS[i], i, 0.0, 0.0, -0.745);
        }
    }
}

stock GetPlayerFPS(playerid)
{
    new drunk2 = GetPlayerDrunkLevel(playerid);
    if(drunk2 < 100)
    {
         SetPlayerDrunkLevel(playerid,2000);
    }
    else
    {
    if(Player[playerid][DLlast] != drunk2)
    {
        new fps = Player[playerid][DLlast] - drunk2;
        if((fps > 0) && (fps < 200))
        Player[playerid][FPS] = fps;
        Player[playerid][DLlast] = drunk2;
    }
    }
}
Reply
#4

it work but have a bug, i need it when i do /pfp to see and another player fps/ping becouse when i do /pfp other player can see my fps/ping but i want if i so /pfp active it for i can see other player not other player can see mine i hope for you understand it.
Reply
#5

This means that if you have enabled the FPS, the label appears in the player, but you can still see the FPS in the label of the other players. I do not understand what you mean.
Reply
#6

it enable it on my boddy not in other player boddy understand?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)