30.09.2016, 16:02
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)
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.
PHP код:
#include <a_samp>
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], 0x0000000FF);
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], (playerid, 0x99 | (playerid, ~0xFF & 0x00FF00FF)));
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], 0x00FF00FF);
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], (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]);
}
public OnPlayerSpawn(playerid)
{
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;
}