Advertisement
Guest User

SA-MP Animated TextDraw

a guest
Jun 21st, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.56 KB | None | 0 0
  1. new PlayerText: txdText[MAX_PLAYERS]; // globalnie
  2.  
  3.  
  4. forward OnAnimatedTextDraw(playerid, tick);
  5. public OnAnimatedTextDraw(playerid, tick)
  6. {
  7.   new pos= GetPVarInt(playerid, "atxd_step");
  8.  
  9.   new c1= GetPVarInt(playerid, "atxd_color");
  10.   new Float: s1= (c1-((c1 >> 8) << 8)) / (tick/3.0); c1= (c1 >> 8) << 8;
  11.  
  12.   new c2= GetPVarInt(playerid, "atxd_color2");
  13.   new Float: s2= (c2-((c2 >> 8) << 8)) / (tick/3.0); c2= (c2 >> 8) << 8;
  14.  
  15.   if (pos < (tick/3))
  16.   {
  17.     c1 += floatround(pos*s1); PlayerTextDrawColor(playerid, txdText[playerid], c1);
  18.     c2 += floatround(pos*s2); PlayerTextDrawBackgroundColor(playerid, txdText[playerid], c2);
  19.     PlayerTextDrawShow(playerid, txdText[playerid]);
  20.   }
  21.   else
  22.   if (pos > ((tick/3)*2))
  23.   {
  24.     c1 += floatround((tick-pos)*s1); PlayerTextDrawColor(playerid, txdText[playerid], c1);
  25.     c2 += floatround((tick-pos)*s2); PlayerTextDrawBackgroundColor(playerid, txdText[playerid], c2);
  26.     PlayerTextDrawShow(playerid, txdText[playerid]);
  27.   }
  28.  
  29.   SetPVarInt(playerid, "atxd_step", ++pos);
  30.  
  31.   if (pos >= tick)
  32.   {
  33.     KillTimer(GetPVarInt(playerid, "atxd_timer"));
  34.     SetPVarInt(playerid, "atxd_timer", -1);
  35.     PlayerTextDrawDestroy(playerid, txdText[playerid]);
  36.   }
  37. }
  38.  
  39.  
  40. stock AnimatedTextDraw(playerid, text[], color1= 0x000000ff, color2= 0xffffff66, time= 3)
  41. {
  42.   if (!IsPlayerValid(playerid)) return 0;
  43.   if (strlen(text) <= 0) return 0;
  44.   if ( (time < 3) || (time > 20) ) return 0;
  45.  
  46.   if (GetPVarInt(playerid, "atxd_timer") >= 0)
  47.   {
  48.     KillTimer(GetPVarInt(playerid, "atxd_timer"));
  49.     PlayerTextDrawDestroy(playerid, txdText[playerid]);
  50.   }
  51.  
  52.   txdText[playerid]= CreatePlayerTextDraw(playerid, 320.0, 200.0, text);
  53.   PlayerTextDrawTextSize(playerid, txdText[playerid], 0.0, 480.0);
  54.   PlayerTextDrawLetterSize(playerid, txdText[playerid], 1.2, 3.2);
  55.   PlayerTextDrawAlignment(playerid, txdText[playerid], 2);
  56.   PlayerTextDrawFont(playerid, txdText[playerid], 3);
  57.   //PlayerTextDrawColor(playerid, txdText[playerid], 0x00000000);
  58.   PlayerTextDrawSetProportional(playerid, txdText[playerid], true);
  59.   //PlayerTextDrawSetShadow(playerid, txdText[playerid], false);
  60.   PlayerTextDrawSetOutline(playerid, txdText[playerid], 1);
  61.   //PlayerTextDrawBackgroundColor(playerid, txdText[playerid], 0x00000000);
  62.  
  63.   PlayerTextDrawShow(playerid, txdText[playerid]);
  64.  
  65.   SetPVarInt(playerid, "atxd_color", color1);
  66.   SetPVarInt(playerid, "atxd_color2", color2);
  67.   SetPVarInt(playerid, "atxd_step", 1);
  68.   SetPVarInt(playerid, "atxd_timer", SetTimerEx("OnAnimatedTextDraw", 10, true, "dd", playerid,((time*1000)/10)));
  69.  
  70.   return 1;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement