[Pedido] Sistema de FPS em TextDraw
#1

Bom Pesquisei aki na Forum Samp Todos q Achei n Funciona queria q se alguem podesse fazer um bem simples mostrando o fps em baixo do mapa

Obrigado..
Reply
#2

Ta ae :
pawn Код:
#include <a_samp>

new Text:FPS[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(240.0, 580.0, "FPS: Carregando");

    TextDrawShowForPlayer(playerid, FPS[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    new string[128];
    format(string, sizeof(string), "Your 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;
}
Reply
#3

Esse Eu Testei e Nгo Funciona
Reply
#4

O que acontece?

@EDITEI o Tуpico anterior tente agora... Mas fale o que acontece antes.
Reply
#5

Quote:
Originally Posted by CidadeNovaRP
Посмотреть сообщение
O que acontece?

@EDITEI o Tуpico anterior tente agora... Mas fale o que acontece antes.
ele neem apareceia a text draw vou testar aqui
@edit

nao funciono ainda n aparece o textdraw
Reply
#6

Tambem quero a FPS De TextDraw
Reply
#7

Ta ae :
pawn Код:
#include <a_samp>

new Text: textFPS[MAX_PLAYERS];
new Text:FPS[MAX_PLAYERS];
new DLlast[MAX_PLAYERS];
new FPS2[MAX_PLAYERS];

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(FPS[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,FPS[playerid]);
    return 1;
}

public OnFilterScriptInit()
{
    SetTimer("fpsCheck", 100, true);
   
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        textFPS[i] = TextDrawCreate(199.000000, 375.000000, " ");
        TextDrawAlignment(textFPS[i], 3);
        TextDrawBackgroundColor(textFPS[i], 0xFF8000FF);
        TextDrawFont(textFPS[i], 3);
        TextDrawLetterSize(textFPS[i], 0.389999, 0.899999);
        TextDrawColor(textFPS[i], 0x000000f6);
        TextDrawSetOutline(textFPS[i], 1);
        TextDrawSetProportional(textFPS[i], 1);
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
        new drunk2 = GetPlayerDrunkLevel(playerid);
        if(drunk2 < 100)
        {
            SetPlayerDrunkLevel(playerid,2000);
        }
        else
        {
            if(DLlast[playerid] != drunk2)
            {
                new fps = DLlast[playerid] - drunk2;

                if((fps > 0) && (fps < 200))
                FPS2[playerid] = fps;
                DLlast[playerid] = drunk2;
            }
        }
        return 1;
}

forward fpsCheck();
public fpsCheck()
{
    for(new i; i != GetMaxPlayers(); ++i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            if(GetPVarInt(i, "spawned"))
            {
                SetPVarInt(i, "drunkLevel", GetPlayerDrunkLevel(i));

                if(GetPVarInt(i, "drunkLevel") < 100)
                {
                    SetPlayerDrunkLevel(i, 2000);
                }
                else
                {
                    if(GetPVarInt(i, "lastDrunkLevel") != GetPVarInt(i, "drunkLevel"))
                    {
                        SetPVarInt(i, "fps", (GetPVarInt(i, "lastDrunkLevel") - GetPVarInt(i, "drunkLevel")));
                        SetPVarInt(i, "lastDrunkLevel", GetPVarInt(i, "drunkLevel"));

                        if((GetPVarInt(i, "fps") > 0) && (GetPVarInt(i, "fps") < 256))
                        {
                            new string[24];
                            format(string, sizeof(string),"FPS: %d", GetPVarInt(i, "fps") - 1);
                            TextDrawSetString(textFPS[i], string);
                            TextDrawShowForPlayer(i, textFPS[i]);
                        }
                    }
                }
            }
            else
            {
                TextDrawHideForPlayer(i, textFPS[i]);
            }
        }
    }
    return 1;
}
Reply
#8

tentei usa esse como fs n de tb
nao aparece a text draw
Reply
#9

Quote:
Originally Posted by Caio_Freeze
Посмотреть сообщение
tentei usa esse como fs n de tb
nao aparece a text draw
Cara ta tudo certinho no FS...
Reply
#10

mais n funciona ¬¬
vc testo ele
e apareceu o fps?
Reply
#11

Fiz um aqui teste
PHP код:

#include <a_samp>
new Text:fpstext1[MAX_PLAYERS];
new 
pFPS[MAX_PLAYERS];
new 
pDrunkLevelLast[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid,fpstext1[playerid]);
return 
1;
}
public 
OnFilterScriptInit()
{
 for(new 
iGetMaxPlayers(); != k; ++i)
 {
    
fpstext1[i] = TextDrawCreate(60.000000323.000000"FPS");
    
TextDrawBackgroundColor(fpstext1[i], -16776961);
    
TextDrawFont(fpstext1[i], 3);
    
TextDrawLetterSize(fpstext1[i], 0.5000001.200000);
    
TextDrawColor(fpstext1[i], -16776961);
    
TextDrawSetOutline(fpstext1[i], 0);
    
TextDrawSetProportional(fpstext1[i], 1);
    
TextDrawSetShadow(fpstext1[i], 0);
}
return 
1;
}
public 
OnPlayerUpdate(playerid)
{

    new 
drunknew;
    
drunknew GetPlayerDrunkLevel(playerid);

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

        if (
pDrunkLevelLast[playerid] != drunknew) {

            new 
wfps pDrunkLevelLast[playerid] - drunknew;

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

            
pDrunkLevelLast[playerid] = drunknew;
        }

    }

new 
stringtextdraw[200];
format(stringtextdrawsizeof(stringtextdraw),"Fps: %i",GetPlayerFPS(playerid));
TextDrawSetString(fpstext1[playerid],stringtextdraw);
return 
1;
}
stock GetPlayerFPS(playerid) return pFPS[playerid]; 
ajudei +rep
Reply
#12

Don
FPS: %d
nao seria? %i
Reply
#13

Quote:
Originally Posted by 4LiSs0N
Посмотреть сообщение
Don
FPS: %d
nao seria? %i
Nгo, pois "d" serve para Nъmero...
Reply
#14

Quote:
Originally Posted by CidadeNovaRP
Посмотреть сообщение
Nгo, pois "d" serve para Nъmero...
Mesma coisa, os 2 sгo pra inteiros...

@Edit

Tente esse...

pawn Код:
#include <a_samp>

new TimerFPS[MAX_PLAYERS];
new Text:FPS[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(577.000000, 9.000000, "FPS: Carregando");
    TextDrawBackgroundColor(FPS[playerid], 255);
    TextDrawFont(FPS[playerid], 1);
    TextDrawLetterSize(FPS[playerid], 0.209999, 1.400000);
    TextDrawColor(FPS[playerid], -1);
    TextDrawSetOutline(FPS[playerid], 0);
    TextDrawSetProportional(FPS[playerid], 1);
    TextDrawSetShadow(FPS[playerid], 1);

    TextDrawShowForPlayer(playerid, FPS[playerid]);
    TimerFPS[playerid] = SetTimerEx("AtualizarFPS", 1000, true, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0..2: KillTimer(TimerFPS[playerid]);
    }
    return 1;
}

forward AtualizarFPS(playerid);
public AtualizarFPS(playerid)
{
    new string[128];
    format(string, sizeof(string), "Seu 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;
}
Reply
#15

Vlw Paulor Funciono Como q eu Mudo a Cor, tipo e o lugar da letra?
Reply
#16

Quote:
Originally Posted by Caio_Freeze
Посмотреть сообщение
Vlw Paulor Funciono Como q eu Mudo a Cor, tipo e o lugar da letra?
https://sampwiki.blast.hk/wiki/TextDrawCreate

nesse link tem as informaзхes sobre textdraw.. informaзхes como cor, tipo, etc.

sу descer a pagina em "Related Functions"
Reply
#17

Tava Desligado Erros Acontece Desculpe-me
Reply
#18

Quote:
Originally Posted by paulor
Посмотреть сообщение
Mesma coisa, os 2 sгo pra inteiros...

@Edit

Tente esse...

pawn Код:
#include <a_samp>

new TimerFPS[MAX_PLAYERS];
new Text:FPS[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(577.000000, 9.000000, "FPS: Carregando");
    TextDrawBackgroundColor(FPS[playerid], 255);
    TextDrawFont(FPS[playerid], 1);
    TextDrawLetterSize(FPS[playerid], 0.209999, 1.400000);
    TextDrawColor(FPS[playerid], -1);
    TextDrawSetOutline(FPS[playerid], 0);
    TextDrawSetProportional(FPS[playerid], 1);
    TextDrawSetShadow(FPS[playerid], 1);

    TextDrawShowForPlayer(playerid, FPS[playerid]);
    TimerFPS[playerid] = SetTimerEx("AtualizarFPS", 1000, true, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0..2: KillTimer(TimerFPS[playerid]);
    }
    return 1;
}

forward AtualizarFPS(playerid);
public AtualizarFPS(playerid)
{
    new string[128];
    format(string, sizeof(string), "Seu 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;
}
Ta aqui :
pawn Код:
public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(577.000000, 9.000000, "FPS: Carregando"); //COORDENADAS DA TELA
    TextDrawBackgroundColor(FPS[playerid], 255);
    TextDrawFont(FPS[playerid], 1); //TIPO
    TextDrawLetterSize(FPS[playerid], 0.209999, 1.400000);
    TextDrawColor(FPS[playerid], -1); //COR
    TextDrawSetOutline(FPS[playerid], 0);
    TextDrawSetProportional(FPS[playerid], 1);
    TextDrawSetShadow(FPS[playerid], 1);

    TextDrawShowForPlayer(playerid, FPS[playerid]);
    TimerFPS[playerid] = SetTimerEx("AtualizarFPS", 1000, true, "i", playerid);
    return 1;
}
Reply
#19

pawn Код:
public OnPlayerConnect(playerid)
{
    FPS[playerid] = TextDrawCreate(577.000000, 9.000000, "FPS: Carregando");//Coordenadas X, Y.
    TextDrawBackgroundColor(FPS[playerid], 255);
    TextDrawFont(FPS[playerid], 1);
    TextDrawLetterSize(FPS[playerid], 0.209999, 1.400000);
    TextDrawColor(FPS[playerid], -1);//Cor Texto - 0x000000FF(Preto), 0xFF0000FF(Vermelho), 0x00FF00FF(Verde), 0x0000FFFF(Azul), 0xFFFFFFFF(Branco).
    TextDrawSetOutline(FPS[playerid], 0);
    TextDrawSetProportional(FPS[playerid], 1);
    TextDrawSetShadow(FPS[playerid], 1);

    TextDrawShowForPlayer(playerid, FPS[playerid]);
    TimerFPS[playerid] = SetTimerEx("AtualizarFPS", 1000, true, "i", playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)