Quote:
Originally Posted by JaKe Elite
I have tried understanding what you have just explained above and this is what happens, I coded & followed your instruction exceptions to some parts.
PHP Code:
stock ShowPlayerObjective(playerid, color, string[], time)
{
PlayerTextDrawSetString(playerid, player_Textdraw[playerid][0], string);
PlayerTextDrawColor(playerid, player_Textdraw[playerid][0], color);
PlayerTextDrawShow(playerid, player_Textdraw[playerid][0]);
PlayerInfo[playerid][ptdTimer] = SetTimerEx("TextdrawFadeOut", 100, true, "ddds", playerid, color, time, string);
print("ShowPlayerObjective");
return 1;
}
public TextdtawFadeOut(playerid, color, time, string[])
{
PlayerInfo[playerid][ptdCount] += 100;
PlayerTextDrawColor(playerid, player_Textdraw[playerid][0], color + 255 - floatround(float(100) / float(time) * 255.0));
if(floatround((time / 100)) >= floatround(PlayerInfo[playerid][ptdCount]))
{
PlayerTextDrawHide(playerid, player_Textdraw[playerid][0]);
KillTimer(PlayerInfo[playerid][ptdTimer]);
}
return 1;
}
// EG
ShowPlayerObjective(playerid, 0x33AA3300, "Test my nigga", 4000);
And it just displayed a black colored textdraw.
|
Code:
float(100) / float(time)
is not quite correct. This will indeed always give a low value, and after the full calculation it will be black. You must replace 100 with the time already passed, which will result in
Code:
float(PlayerInfo[playerid][ptdCount]) / float(time)
You should also make sure that
PlayerInfo[playerid][ptdCount] never grows higher than
time before inserting it into that calculation, that will result in a totally different color.