Advertisement
Chip7

[TUT] Criando TextDraw's que pisca

May 13th, 2012
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.82 KB | None | 0 0
  1. /*VISITE NOSSO SITE: http://www.sampknd.com/
  2.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  3. */
  4.  
  5. #include <a_samp>
  6.  
  7. new Cores[8] = //Criamos a varivel que será usada no Random
  8. {
  9.     0xFF0000AA, //VERMELHO
  10.     0xFFFFFFAA, //BRANCO
  11.     0x00FFFFAA, //AZUL MARINHO
  12.     0x88FF9FAA, //VERDE
  13.     0xFF9900AA, //LARANJA
  14.     0xFFFF00AA, //AMARELO
  15.     0x0000FFAA //AZUL
  16. }; //Trocar o "[8]" pelo número de suas cores + 1
  17.  
  18. TrocarCor(playerid); //Definimos aqui para podermos usar a public
  19. forward PararDePiscar(playerid); //Definimos aqui para podermos usar a public
  20.  
  21. new Text:Exemplo; //Necessario para criar a TextDraw
  22. new bool:pText; //Será usado a frente
  23. new TimerForPlayer[MAX_PLAYERS]; //Iremos usar no KillTimer
  24. new TimerForAll; //Iremos usar no KillTimer
  25.  
  26. public OnGameModeInit()
  27. {
  28.     Exemplo = TextDrawCreate(123.0, 123.0, "Tutorial by CidadeNovaRP -q"); //Criando a TetxDraw
  29.     pText = false; //Setamos a variavel/bool pText a false
  30.     return 1;
  31. }
  32.  
  33. public TrocarCor(playerid) //public que troca a Text de cor de acordo com "playerid"
  34. {
  35.     new rand = random(sizeof(Cores)); //Criamos a variavel Random das Cores
  36.     if(playerid == -1)
  37.     {
  38.         if(pText == true) //Verifica se pText = true
  39.         {
  40.             TextDrawHideForAll(Exemplo); //Esconde a TextDraw para o "playerid"
  41.             TextDrawColor(Exemplo, Cores[rand]); //Seta a cor de acordo com o Random
  42.             TextDrawShowForAll(Exemplo); //Mostra a TextDraw pra você
  43.             pText = false;
  44.         }
  45.         else //Se não for true...
  46.         {
  47.             TextDrawHideForAll(Exemplo); //Esconde a TextDraw para o "playerid"
  48.             TextDrawColor(Exemplo, Cores[rand]); //Seta a cor de acordo com o Random
  49.             TextDrawShowForAll(Exemplo); //Mostra a TextDraw pra você
  50.             pText = true;
  51.         }
  52.     }
  53.     if(pText == true) //Verifica se pText = true
  54.     {
  55.         TextDrawHideForPlayer(playerid, Exemplo); //Esconde a TextDraw para o "playerid"
  56.         TextDrawColor(Exemplo, Cores[rand]); //Seta a cor de acordo com o Random
  57.         TextDrawShowForPlayer(playerid, Exemplo); //Mostra a TextDraw pra você
  58.         pText = false;
  59.     }
  60.     else //Se não for true...
  61.     {
  62.         TextDrawHideForPlayer(playerid, Exemplo); //Esconde a TextDraw para o "playerid"
  63.         TextDrawColor(Exemplo, Cores[rand]); //Seta a cor de acordo com o Random
  64.         TextDrawShowForPlayer(playerid, Exemplo); //Mostra a TextDraw pra você
  65.         pText = true;
  66.     }
  67.     return 1;
  68. }
  69.  
  70. public PararDePiscar(playerid) //public que para de piscar de acordo com o "playerid"
  71. {
  72.     if(playerid == -1) return TextDrawHideForAll(Exemplo), KillTimer(TimerForAll); //Esconde a TextDraw para todos e Mata/destroi o Timer se "playerid" == -1
  73.     TextDrawHideForPlayer(playerid, Exemplo), KillTimer(TimerForPlayer[playerid]); //Esconde a TextDraw para o "playerid" e Mata/destroi o Timer
  74.     return 1;
  75. }
  76.  
  77. public OnPlayerCommandText(playerid, cmdtext[])
  78. {
  79.     if (strcmp("/piscarparamim", cmdtext, true, 10) == 0)
  80.     {
  81.         TextDrawShowForPlayer(playerid, Exemplo); //Mostra a TextDraw pra você
  82.         pText = false; //Setamos a variavel/bool pText a false
  83.         TimerForPlayer[playerid] = SetTimerEx("TrocarCor", 1000, true, "i", playerid); //Chama a callback "TrocarCor"
  84.         SetTimerEx("PararDePiscar", 30000, false, "i", playerid); //Timer para fazer parar de piscar para você
  85.         return 1;
  86.     }
  87.     if (strcmp("/piscarparatodos", cmdtext, true, 10) == 0)
  88.     {
  89.         TextDrawShowForAll(Exemplo); //Mostra a TextDraw pra todos
  90.         pText = false; //Setamos a variavel/bool pText a false
  91.         TimerForAll = SetTimerEx("TrocarCor", 1000, true, "i", -1); //Chama a callback "TrocarCor"
  92.         SetTimerEx("PararDePiscar", 30000, false, "i", -1); //Timer para fazer parar de piscar para todos
  93.         return 1;
  94.     }
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement