[Ajuda] Textdraw Box Color
#1

Alguйm tem alguma idйia de por que isto nгo funciona como deveria?(Alterar a cor do box da textdraw, sempre fica verde 00FF00)

PHP код:
#include <a_samp>
main() {
    
assert(GetGradientColor(0x00FF00FF0xFF0000FF700200) == 0x49B600FF);
}
GetGradientColor(FromToStepsStep)
{
    new
        
sr,
        
sg,
        
sb,
        
sa,
        
er,
        
eg,
        
eb,
        
ea,
        
r,
        
g,
        
b,
        
a,
        
Float:n
    
;
    
// Macro by AbyssMorgan
    #define ___(%0,%1,%2,%3,%4)    (((%1) = ((%0) >>> 24)),((%2) = (((%0) >>> 16) & 0xFF)),((%3) = (((%0) >>> 8) & 0xFF)),((%4) = ((%0) & 0xFF)))
    
___(Fromsrsgsbsa);
    
___(To,  eregebea);
    
#undef ___
    
float(Step) / float(Steps-1);
    
floatround(float(sr) * (1.0-n) + float(er) * n);
    
floatround(float(sg) * (1.0-n) + float(eg) * n);
    
floatround(float(sb) * (1.0-n) + float(eb) * n);
    
floatround(float(sa) * (1.0-n) + float(ea) * n);
    new 
color;
    
#define ___(%0,%1,%2,%3,%4)    ((%0) = ((%4) & 0xFF) | (((%3) & 0xFF) << 8) | (((%2) & 0xFF) << 16) | ((%1) << 24))
    
___(color,  rgba);
    
#undef ___
    
return color;
}
new 
PlayerText:bar[MAX_PLAYERS][3];
public 
OnPlayerConnect(playerid)
{
/*
*    bar[playerid][0]        --    Fundo (Bordas pretas)
*    bar[playerid][1]        --    Fundo (Parte mais clara do Progresso)
*    bar[playerid][2]        --    Progresso
*/
    
bar[playerid][0] = CreatePlayerTextDraw(playerid484.500000320.666717"_");
    
PlayerTextDrawLetterSize(playeridbar[playerid][0], 0.4450000.608333);
    
PlayerTextDrawTextSize(playeridbar[playerid][0], 582.5000000.000000);
    
PlayerTextDrawUseBox(playeridbar[playerid][0], 1);
    
PlayerTextDrawBoxColor(playeridbar[playerid][0], 0x0000000FF);
    
bar[playerid][1] = CreatePlayerTextDraw(playerid486.500000322.416717"_");
    
PlayerTextDrawLetterSize(playeridbar[playerid][1], 0.4400000.275833);
    
PlayerTextDrawTextSize(playeridbar[playerid][1], 580.5000000.000000);
    
PlayerTextDrawUseBox(playeridbar[playerid][1], 1);
    
PlayerTextDrawBoxColor(playeridbar[playerid][1], (playerid0x99 | (playerid, ~0xFF 0x00FF00FF)));
    
bar[playerid][2] = CreatePlayerTextDraw(playerid486.500000322.416717"_");
    
PlayerTextDrawLetterSize(playeridbar[playerid][2], 0.4400000.275833);
    
PlayerTextDrawTextSize(playeridbar[playerid][2], 580.5000000.000000);
    
PlayerTextDrawUseBox(playeridbar[playerid][2], 1);
    
PlayerTextDrawBoxColor(playeridbar[playerid][2], 0x00FF00FF);
    
SetTimerEx("t"500true"d"playerid);
    
PlayerTextDrawShow(playeridbar[playerid][0]);
    
PlayerTextDrawShow(playeridbar[playerid][1]);
    
PlayerTextDrawShow(playeridbar[playerid][2]);
    
GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
    return 
1;
}
forward t(playerid);
public 
t(playerid)
{
    new 
        
Float:Vida
    
;
    
GetVehicleHealth(GetPlayerVehicleID(playerid), Vida);
    new
        
Float:Progresso = (((Vida 300.0) / 700.0) * 100.0),
        
cor 0xFF0000FF
    
;
    if(
Progresso >= 1.0)
        
cor GetGradientColor(0x00FF00FF0xFF0000FF700floatround(Progresso));
    else
        
Progresso 0.0;
    
PlayerTextDrawHide(playeridbar[playerid][1]);
    
PlayerTextDrawHide(playeridbar[playerid][2]);
    new 
string[128];
    
format(stringsizeof(string), "Progresso: %d Cor: 0x%x-0x%x"floatround(Progresso), cor, (0x77 | (~0xFF cor)));
    
SendClientMessage(playerid, -1string);
    
PlayerTextDrawBoxColor(playeridbar[playerid][1], (0x77 | (~0xFF cor)));
    
PlayerTextDrawBoxColor(playeridbar[playerid][2], cor);
    
PlayerTextDrawTextSize(playeridbar[playerid][2], (486.500000 + ((94.00000 Progresso) / 100)), 0.0);
    
PlayerTextDrawShow(playeridbar[playerid][1]);
    
PlayerTextDrawShow(playeridbar[playerid][2]);
}
public 
OnPlayerSpawn(playerid)
{
    
CreateVehicle(411, -5.1338,15.1673,3.1172,340.79281115);
    
SetPlayerHealth(playerid10000.0);
    
SetPlayerPos(playerid, -5.1338,7.1673,3.1172);
    
SetPlayerInterior(playerid,0);
    
TogglePlayerClock(playerid,0);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
       return 
1;
}
SetupPlayerForClassSelection(playerid)
{
     
SetPlayerInterior(playerid,14);
    
SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    
SetPlayerFacingAngle(playerid270.0);
    
SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    
SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetupPlayerForClassSelection(playerid);
    return 
1;
}
public 
OnPlayerClickMap(playeridFloat:fXFloat:fYFloat:fZ)
{
    
SetPlayerPos(playeridfXfY30.0);
    
SetPlayerHealth(playerid1000.0);
}
public 
OnGameModeInit()
{
    
SetGameModeText("Bare Script");
    
ShowPlayerMarkers(1);
    
ShowNameTags(1);
    return 
1;

Ta no modo bare do sa-mp. a mensagem й apenas para propуsitos de testes, a cor estб gerando normalmente como vocк pode ver no debug.
Reply
#2

muda bem aqui
Код:
#define BOX_COLOR 0xFF0000FF
agora esta vermelho
e sу colocar a cor que vocк quer

Код:
#include <a_samp>
#define BOX_COLOR 0xFF0000FF // coloca aqui a cor que vocк quer
main() {
    assert(GetGradientColor(0x00FF00FF, 0xFF0000FF, 700, 200) == 0x49B600FF);

}
GetGradientColor(From, To, Steps, Step)
{
    new
        sr,
        sg,
        sb,
        sa,
        er,
        eg,
        eb,
        ea,
        r,
        g,
        b,
        a,
        Float:n
    ;
    // Macro by AbyssMorgan
    #define ___(%0,%1,%2,%3,%4)    (((%1) = ((%0) >>> 24)),((%2) = (((%0) >>> 16) & 0xFF)),((%3) = (((%0) >>> 8) & 0xFF)),((%4) = ((%0) & 0xFF)))
    ___(From, sr, sg, sb, sa);
    ___(To,  er, eg, eb, ea);
    #undef ___
    n = float(Step) / float(Steps-1);
    r = floatround(float(sr) * (1.0-n) + float(er) * n);
    g = floatround(float(sg) * (1.0-n) + float(eg) * n);
    b = floatround(float(sb) * (1.0-n) + float(eb) * n);
    a = floatround(float(sa) * (1.0-n) + float(ea) * n);
    new color;
    #define ___(%0,%1,%2,%3,%4)    ((%0) = ((%4) & 0xFF) | (((%3) & 0xFF) << 8) | (((%2) & 0xFF) << 16) | ((%1) << 24))
    ___(color,  r, g, b, a);
    #undef ___
    return color;
}
new PlayerText:bar[MAX_PLAYERS][3];
public OnPlayerConnect(playerid)
{
/*
*    bar[playerid][0]        --    Fundo (Bordas pretas)
*    bar[playerid][1]        --    Fundo (Parte mais clara do Progresso)
*    bar[playerid][2]        --    Progresso
*/
    bar[playerid][0] = CreatePlayerTextDraw(playerid, 484.500000, 320.666717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][0], 0.445000, 0.608333);
    PlayerTextDrawTextSize(playerid, bar[playerid][0], 582.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][0], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][0], BOX_COLOR);

    bar[playerid][1] = CreatePlayerTextDraw(playerid, 486.500000, 322.416717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][1], 0.440000, 0.275833);
    PlayerTextDrawTextSize(playerid, bar[playerid][1], 580.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][1], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][1], BOX_COLOR);

    bar[playerid][2] = CreatePlayerTextDraw(playerid, 486.500000, 322.416717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][2], 0.440000, 0.275833);
    PlayerTextDrawTextSize(playerid, bar[playerid][2], 580.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][2], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][2], BOX_COLOR);
    SetTimerEx("t", 500, true, "d", playerid);
    PlayerTextDrawShow(playerid, bar[playerid][0]);
    PlayerTextDrawShow(playerid, bar[playerid][1]);
    PlayerTextDrawShow(playerid, bar[playerid][2]);
    GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
    return 1;
}
forward t(playerid);
public t(playerid)
{
    new
        Float:Vida
    ;
    GetVehicleHealth(GetPlayerVehicleID(playerid), Vida);
    new
        Float:Progresso = (((Vida - 300.0) / 700.0) * 100.0),
        cor = 0xFF0000FF
    ;
    if(Progresso >= 1.0)
        cor = GetGradientColor(0x00FF00FF, 0xFF0000FF, 700, floatround(Progresso));
    else
        Progresso = 0.0;
    PlayerTextDrawHide(playerid, bar[playerid][1]);
    PlayerTextDrawHide(playerid, bar[playerid][2]);
    new string[128];
    format(string, sizeof(string), "Progresso: %d Cor: 0x%x-0x%x", floatround(Progresso), cor, (0x77 | (~0xFF & cor)));
    SendClientMessage(playerid, -1, string);
    PlayerTextDrawBoxColor(playerid, bar[playerid][1], BOX_COLOR);
    PlayerTextDrawBoxColor(playerid, bar[playerid][2], BOX_COLOR);
    PlayerTextDrawTextSize(playerid, bar[playerid][2], (486.500000 + ((94.00000 * Progresso) / 100)), 0.0);
    PlayerTextDrawShow(playerid, bar[playerid][1]);
    PlayerTextDrawShow(playerid, bar[playerid][2]);
}
public OnPlayerSpawn(playerid)
{
	TextDrawShowForPlayer(playerid, bar[playerid][0]);
    CreateVehicle(411, -5.1338,15.1673,3.1172,340.7928, 1, 1, 15);
    SetPlayerHealth(playerid, 10000.0);
    SetPlayerPos(playerid, -5.1338,7.1673,3.1172);
    SetPlayerInterior(playerid,0);
    TogglePlayerClock(playerid,0);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
       return 1;
}

SetupPlayerForClassSelection(playerid)
{
     SetPlayerInterior(playerid,14);
    SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerFacingAngle(playerid, 270.0);
    SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
    SetupPlayerForClassSelection(playerid);
    return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    SetPlayerPos(playerid, fX, fY, 30.0);
    SetPlayerHealth(playerid, 1000.0);
}
public OnGameModeInit()
{
    SetGameModeText("Bare Script");
    ShowPlayerMarkers(1);
    ShowNameTags(1);
    return 1;
}
Reply
#3

Quote:
Originally Posted by RedMF
Посмотреть сообщение
muda bem aqui
Код:
#define BOX_COLOR 0xFF0000FF
agora esta vermelho
e sу colocar a cor que vocк quer

Код:
#include <a_samp>
#define BOX_COLOR 0xFF0000FF // coloca aqui a cor que vocк quer
main() {
    assert(GetGradientColor(0x00FF00FF, 0xFF0000FF, 700, 200) == 0x49B600FF);

}
GetGradientColor(From, To, Steps, Step)
{
    new
        sr,
        sg,
        sb,
        sa,
        er,
        eg,
        eb,
        ea,
        r,
        g,
        b,
        a,
        Float:n
    ;
    // Macro by AbyssMorgan
    #define ___(%0,%1,%2,%3,%4)    (((%1) = ((%0) >>> 24)),((%2) = (((%0) >>> 16) & 0xFF)),((%3) = (((%0) >>> 8) & 0xFF)),((%4) = ((%0) & 0xFF)))
    ___(From, sr, sg, sb, sa);
    ___(To,  er, eg, eb, ea);
    #undef ___
    n = float(Step) / float(Steps-1);
    r = floatround(float(sr) * (1.0-n) + float(er) * n);
    g = floatround(float(sg) * (1.0-n) + float(eg) * n);
    b = floatround(float(sb) * (1.0-n) + float(eb) * n);
    a = floatround(float(sa) * (1.0-n) + float(ea) * n);
    new color;
    #define ___(%0,%1,%2,%3,%4)    ((%0) = ((%4) & 0xFF) | (((%3) & 0xFF) << 8) | (((%2) & 0xFF) << 16) | ((%1) << 24))
    ___(color,  r, g, b, a);
    #undef ___
    return color;
}
new PlayerText:bar[MAX_PLAYERS][3];
public OnPlayerConnect(playerid)
{
/*
*    bar[playerid][0]        --    Fundo (Bordas pretas)
*    bar[playerid][1]        --    Fundo (Parte mais clara do Progresso)
*    bar[playerid][2]        --    Progresso
*/
    bar[playerid][0] = CreatePlayerTextDraw(playerid, 484.500000, 320.666717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][0], 0.445000, 0.608333);
    PlayerTextDrawTextSize(playerid, bar[playerid][0], 582.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][0], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][0], BOX_COLOR);

    bar[playerid][1] = CreatePlayerTextDraw(playerid, 486.500000, 322.416717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][1], 0.440000, 0.275833);
    PlayerTextDrawTextSize(playerid, bar[playerid][1], 580.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][1], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][1], BOX_COLOR);

    bar[playerid][2] = CreatePlayerTextDraw(playerid, 486.500000, 322.416717, "_");
    PlayerTextDrawLetterSize(playerid, bar[playerid][2], 0.440000, 0.275833);
    PlayerTextDrawTextSize(playerid, bar[playerid][2], 580.500000, 0.000000);
    PlayerTextDrawUseBox(playerid, bar[playerid][2], 1);
    PlayerTextDrawBoxColor(playerid, bar[playerid][2], BOX_COLOR);
    SetTimerEx("t", 500, true, "d", playerid);
    PlayerTextDrawShow(playerid, bar[playerid][0]);
    PlayerTextDrawShow(playerid, bar[playerid][1]);
    PlayerTextDrawShow(playerid, bar[playerid][2]);
    GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
    return 1;
}
forward t(playerid);
public t(playerid)
{
    new
        Float:Vida
    ;
    GetVehicleHealth(GetPlayerVehicleID(playerid), Vida);
    new
        Float:Progresso = (((Vida - 300.0) / 700.0) * 100.0),
        cor = 0xFF0000FF
    ;
    if(Progresso >= 1.0)
        cor = GetGradientColor(0x00FF00FF, 0xFF0000FF, 700, floatround(Progresso));
    else
        Progresso = 0.0;
    PlayerTextDrawHide(playerid, bar[playerid][1]);
    PlayerTextDrawHide(playerid, bar[playerid][2]);
    new string[128];
    format(string, sizeof(string), "Progresso: %d Cor: 0x%x-0x%x", floatround(Progresso), cor, (0x77 | (~0xFF & cor)));
    SendClientMessage(playerid, -1, string);
    PlayerTextDrawBoxColor(playerid, bar[playerid][1], BOX_COLOR);
    PlayerTextDrawBoxColor(playerid, bar[playerid][2], BOX_COLOR);
    PlayerTextDrawTextSize(playerid, bar[playerid][2], (486.500000 + ((94.00000 * Progresso) / 100)), 0.0);
    PlayerTextDrawShow(playerid, bar[playerid][1]);
    PlayerTextDrawShow(playerid, bar[playerid][2]);
}
public OnPlayerSpawn(playerid)
{
	TextDrawShowForPlayer(playerid, bar[playerid][0]);
    CreateVehicle(411, -5.1338,15.1673,3.1172,340.7928, 1, 1, 15);
    SetPlayerHealth(playerid, 10000.0);
    SetPlayerPos(playerid, -5.1338,7.1673,3.1172);
    SetPlayerInterior(playerid,0);
    TogglePlayerClock(playerid,0);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
       return 1;
}

SetupPlayerForClassSelection(playerid)
{
     SetPlayerInterior(playerid,14);
    SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerFacingAngle(playerid, 270.0);
    SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
    SetupPlayerForClassSelection(playerid);
    return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    SetPlayerPos(playerid, fX, fY, 30.0);
    SetPlayerHealth(playerid, 1000.0);
}
public OnGameModeInit()
{
    SetGameModeText("Bare Script");
    ShowPlayerMarkers(1);
    ShowNameTags(1);
    return 1;
}
Pelo oque entendi ele, falou que a cor esta sendo Gerada porem nгo esta trocando a cor do TextDraw, esta ficando sempre VERDE, oque entendi foi isso, me desculpe caso eu esteja errado.
Reply
#4

@RedMF uau, a cor й gerada de acordo com a porcentagem de dano do veiculo assim tornando uma espйcie de "gradient". A funзгo para gerar a cor funciona perfeitamente, porйm ao alterar a cor, sempre continua com a primeira cor usada.

@Carlos001 exato
Reply
#5

Alterei algumas coisas e funcionou perfeitamente:
Код:
forward t(playerid);
public t(playerid)
{
    new
        Float:Vida
    ;
    GetVehicleHealth(GetPlayerVehicleID(playerid), Vida);
    new
        Float:Progresso = (((Vida - 300.0) / 700.0) * 100.0),
        Float:Progresso2 = ((Vida / 100.0) * 100.0),
        cor = 0xFF0000FF
    ;
    if(Progresso >= 1.0)
        cor = GetGradientColor(0xFF0000FF,  0x00FF00FF, 1000, floatround(Progresso2));
    else
        Progresso = 0.0;
    PlayerTextDrawHide(playerid, bar[playerid][1]);
    PlayerTextDrawHide(playerid, bar[playerid][2]);
    new string[128];
    format(string, sizeof(string), "Progresso: %d Cor: 0x%x-0x%x", floatround(Progresso2), cor, (0x77 | (~0xFF & cor)));
    SendClientMessage(playerid, -1, string);
    PlayerTextDrawBoxColor(playerid, bar[playerid][1], (0x77 | (~0xFF & cor)));
    PlayerTextDrawBoxColor(playerid, bar[playerid][2], cor);
    PlayerTextDrawTextSize(playerid, bar[playerid][2], (486.500000 + ((94.00000 * Progresso) / 100)), 0.0);
    PlayerTextDrawShow(playerid, bar[playerid][1]);
    PlayerTextDrawShow(playerid, bar[playerid][2]);
}
Reply
#6

Obrigado a todos, achei meu erro graзas ao RodrigoMSR, eu nem reparei que estava usando ao gerar a cor um valor que vai de 0 a 100, ao invйs do 0 a 700(que seria o da vida) obrigado flw vlw +rep a todos
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)