AdrianoPasoti

Sistema de pintura de veiculos samp!

Jul 6th, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.90 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #define PLAYERS 100 //MAX PLAYERS
  6. #define TXD_PX 40.0 //Pos X
  7. #define TXD_PY 80.0 //Pos Y
  8. #define TXD_DIS_X 70.0 //Distancia entre as Imagens
  9. #define TXD_DIS_Y 70.0 //Distancia entre as Imagens
  10. #define TXD_TAM 70.0 //Tamanho das imagens (textdraw)
  11. #define TXD_COR_SELECAO 0x00FF00AA //Cor de seleção das textdraw
  12. #define TXD_BG_COLOR 0x00000055 //Cor de fundo das textdraw
  13.  
  14. new PlayerText:TextPintura[PLAYERS][36];
  15.  
  16.  
  17. CMD:pintar(playerid)//Unica CMD
  18. {
  19.     IniciarPintura(playerid);
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     printf("Sistema de Pintura Carregado com Sucesso\nby AdrianoStk\nhayllander.ddns.net");
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerDisconnect(playerid, reason)
  35. {
  36.     if(GetPVarInt(playerid, "PaginaPintura") != 0)//Interessante no caso do jogador sofrer queda de conexão!
  37.     {
  38.         CancelSelectTextDraw(playerid);
  39.         RemoverTextDrawPintura(playerid);
  40.     }
  41.     return 1;
  42. }
  43.  
  44. forward IniciarPintura(playerid);
  45. forward PinturaCancela(playerid);
  46. forward PinturaFinalizada(playerid, vcor1, vcor2);
  47.  
  48. public IniciarPintura(playerid)//Chama essa função pra iniciar a pintura
  49. {
  50.     if(GetPVarInt(playerid, "PaginaPintura") != 0)
  51.         SendClientMessage(playerid, -1, "Você já está pintando um veiculo!");
  52.     else if(IsPlayerInAnyVehicle(playerid))
  53.     {
  54.         if(QuantasPinturas(GetVehicleModel(GetPlayerVehicleID(playerid))) != 0)
  55.         {
  56.             SetPVarInt(playerid, "PaginaPintura", 1);//Pagina Inicial das cores
  57.             SetPVarInt(playerid, "Cor1", -1);//Não altere o valor
  58.             SetPVarInt(playerid, "Cor2", -1);//Não altere o valor
  59.             ExibeTextDrawPintura(playerid);
  60.         }
  61.         else
  62.             SendClientMessage(playerid, -1, "Este veiculo não suporta pintura!");
  63.     }
  64.     else
  65.         SendClientMessage(playerid, -1, "Para pintar um veiculo, você deve estar dentro dele!");
  66.     return 1;
  67. }
  68.  
  69. public PinturaCancela(playerid)//Quando o player cancelas, ESC ou clika no X
  70. {
  71.     SendClientMessage(playerid, -1, "Você cancelou a pintura");
  72.     return 1;
  73. }
  74.  
  75. public PinturaFinalizada(playerid, vcor1, vcor2)//Quando o player finaliza a seleção de cores!
  76. {
  77.     ChangeVehicleColor(GetPlayerVehicleID(playerid), vcor1, vcor2);
  78.     GivePlayerMoney(playerid, -250);
  79.     new Str[64];
  80.     if(vcor2 != -1)
  81.         format(Str, 64, "Suas novas cores, Cor1: %d Cor2: %d", vcor1, vcor2);
  82.     else
  83.         format(Str, 64, "Sua nova cor: %d", vcor1);
  84.     SendClientMessage(playerid, -1, Str);
  85.     return 1;
  86. }
  87.  
  88. forward ExibeTextDrawPintura(playerid);
  89. public ExibeTextDrawPintura(playerid)
  90. {
  91.     if(IsPlayerInAnyVehicle(playerid))
  92.     {
  93.         new Float:TX, Float:TY = TXD_PY, i = 0, Cor1, Cor2, ModeloV;//Variavei auxiliares
  94.         new bool:C1;
  95.         ModeloV = GetVehicleModel(GetPlayerVehicleID(playerid));
  96.         C1 = GetPVarInt(playerid, "Cor1") == -1 ? false : true;
  97.         Cor1 = C1 ? GetPVarInt(playerid, "Cor1"): (GetPVarInt(playerid, "PaginaPintura")-1) * 32;
  98.         Cor2 = (GetPVarInt(playerid, "PaginaPintura")-1) * 32;
  99.         for(new l = 0; l < 4; l++)//Linhas
  100.         {
  101.             TX = TXD_PX;
  102.             for(new c = 0; c < 8; c++)//Colunas
  103.             {
  104.                 TextPintura[playerid][i] = CreatePlayerTextDraw(playerid, TX, TY, "_");
  105.                 PlayerTextDrawFont(playerid, TextPintura[playerid][i], TEXT_DRAW_FONT_MODEL_PREVIEW);
  106.                 PlayerTextDrawBackgroundColor(playerid, TextPintura[playerid][i], TXD_BG_COLOR);
  107.                 PlayerTextDrawTextSize(playerid, TextPintura[playerid][i], TXD_TAM, TXD_TAM);
  108.                 PlayerTextDrawSetPreviewRot(playerid, TextPintura[playerid][i], -10.0, 0.0, -20.0, 0.8);
  109.                 PlayerTextDrawSetPreviewVehCol(playerid, TextPintura[playerid][i], Cor1, Cor2);
  110.                 PlayerTextDrawSetPreviewModel(playerid, TextPintura[playerid][i], ModeloV);
  111.                 PlayerTextDrawSetSelectable(playerid, TextPintura[playerid][i], 1);
  112.                 TX += 70.0;
  113.                 i++;
  114.                 Cor2++;
  115.                 Cor1 += C1 ? 0 : 1;
  116.             }
  117.             TY += TXD_DIS_X;
  118.         }
  119.         TextPintura[playerid][32] = CreatePlayerTextDraw(playerid, TXD_PX + 510.0, TXD_PY + 280.0, "LD_BEAT:right");//Proxima Pagina
  120.         PlayerTextDrawFont(playerid, TextPintura[playerid][32], 4);
  121.         PlayerTextDrawTextSize(playerid, TextPintura[playerid][32], TXD_TAM -40.0, TXD_TAM -40.0);
  122.         PlayerTextDrawSetSelectable(playerid, TextPintura[playerid][32], 1);
  123.         PlayerTextDrawAlignment(playerid, TextPintura[playerid][32], 2);
  124.  
  125.         TextPintura[playerid][33] = CreatePlayerTextDraw(playerid, TXD_PX + 15.0, TXD_PY + 280.0, "LD_BEAT:left");//Proxima Pagina
  126.         PlayerTextDrawFont(playerid, TextPintura[playerid][33], 4);
  127.         PlayerTextDrawTextSize(playerid, TextPintura[playerid][33], TXD_TAM -40.0, TXD_TAM -40.0);
  128.         PlayerTextDrawSetSelectable(playerid, TextPintura[playerid][33], 1);
  129.         PlayerTextDrawAlignment(playerid, TextPintura[playerid][33], 2);
  130.        
  131.         TextPintura[playerid][34] = CreatePlayerTextDraw(playerid, TXD_PX + 260, TXD_PY + 280, "LD_BEAT:cross");//Cancelar
  132.         PlayerTextDrawFont(playerid, TextPintura[playerid][34], 4);
  133.         PlayerTextDrawTextSize(playerid, TextPintura[playerid][34], TXD_TAM -42.0, TXD_TAM -42.0);
  134.         PlayerTextDrawSetSelectable(playerid, TextPintura[playerid][34], 1);
  135.         PlayerTextDrawAlignment(playerid, TextPintura[playerid][34], 2);
  136.         PlayerTextDrawShow(playerid, TextPintura[playerid][34]);
  137.        
  138.         TextPintura[playerid][35] = CreatePlayerTextDraw(playerid, TXD_PX + 280.0, TXD_PY + 2.0, "MENU DE PINTURA");//Titulo
  139.         PlayerTextDrawFont(playerid, TextPintura[playerid][35], 1);
  140.         PlayerTextDrawColor(playerid, TextPintura[playerid][35], 0x1E90FFFF);
  141.         PlayerTextDrawSetSelectable(playerid, TextPintura[playerid][35], 0);
  142.         PlayerTextDrawAlignment(playerid, TextPintura[playerid][35], 2);
  143.         PlayerTextDrawLetterSize(playerid, TextPintura[playerid][35], 0.5 ,1.2);
  144.         PlayerTextDrawShow(playerid, TextPintura[playerid][35]);
  145.  
  146.         for(i = 0; i < 32; i++)
  147.             PlayerTextDrawShow(playerid, TextPintura[playerid][i]);
  148.        
  149.         if(GetPVarInt(playerid, "PaginaPintura") != 8)
  150.             PlayerTextDrawShow(playerid, TextPintura[playerid][32]);
  151.            
  152.         if(GetPVarInt(playerid, "PaginaPintura") != 1)
  153.             PlayerTextDrawShow(playerid, TextPintura[playerid][33]);
  154.         SelectTextDraw(playerid, TXD_COR_SELECAO);
  155.     }
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  160. {
  161.     if(_:clickedid == INVALID_TEXT_DRAW)
  162.     {
  163.         if(GetPVarInt(playerid, "PaginaPintura") != 0)//Verifica se ele deu esc na pintura de veiculo!
  164.         {
  165.             DeletePVar(playerid, "PaginaPintura");
  166.             DeletePVar(playerid, "Cor1");
  167.             DeletePVar(playerid, "Cor2");
  168.             RemoverTextDrawPintura(playerid);
  169.             PinturaCancela(playerid);
  170.         }
  171.     }
  172.     return 0;
  173. }
  174.  
  175. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  176. {
  177.     if(GetPVarInt(playerid, "PaginaPintura") != 0)//Significa que ele está pintando um veiculo
  178.     {
  179.         if(TextPintura[playerid][32] == playertextid)//Proxima
  180.         {
  181.             SetPVarInt(playerid, "PaginaPintura", GetPVarInt(playerid, "PaginaPintura") + 1);
  182.             RemoverTextDrawPintura(playerid);
  183.             SetTimerEx("ExibeTextDrawPintura", 150, false, "i", playerid);
  184.         }
  185.         else if(TextPintura[playerid][33] == playertextid)//Anterior
  186.         {
  187.             SetPVarInt(playerid, "PaginaPintura", GetPVarInt(playerid, "PaginaPintura") - 1);
  188.             RemoverTextDrawPintura(playerid);
  189.             SetTimerEx("ExibeTextDrawPintura", 150, false, "i", playerid);
  190.         }
  191.         else if(TextPintura[playerid][34] == playertextid)//Cancelar
  192.         {
  193.             DeletePVar(playerid, "PaginaPintura");
  194.             DeletePVar(playerid, "Cor1");
  195.             DeletePVar(playerid, "Cor2");
  196.             RemoverTextDrawPintura(playerid);
  197.             CancelSelectTextDraw(playerid);
  198.             PinturaCancela(playerid);
  199.         }
  200.         else
  201.         {
  202.             new i = 0;
  203.             while(i < 32 && (TextPintura[playerid][i] != playertextid))
  204.                 i++;
  205.  
  206.             if(TextPintura[playerid][i] == playertextid)
  207.             {
  208.                 RemoverTextDrawPintura(playerid);
  209.                 if(GetPVarInt(playerid, "Cor1") == -1)
  210.                 {
  211.                     SetPVarInt(playerid, "Cor1", (GetPVarInt(playerid, "PaginaPintura")-1) *32 + i);
  212.                     if(QuantasPinturas(GetVehicleModel(GetPlayerVehicleID(playerid))) == 2)
  213.                     {
  214.                         SetTimerEx("ExibeTextDrawPintura", 150, false, "i", playerid);
  215.                     }
  216.                     else
  217.                     {
  218.                         DeletePVar(playerid, "PaginaPintura");
  219.                         RemoverTextDrawPintura(playerid);
  220.                         CancelSelectTextDraw(playerid);
  221.                         PinturaFinalizada(playerid, GetPVarInt(playerid, "Cor1"), -1);
  222.                         DeletePVar(playerid, "Cor1");
  223.                         DeletePVar(playerid, "Cor2");
  224.                     }
  225.                 }
  226.                 else
  227.                 {
  228.                     SetPVarInt(playerid, "Cor2", (GetPVarInt(playerid, "PaginaPintura")-1) *32 + i);
  229.                     DeletePVar(playerid, "PaginaPintura");
  230.                     CancelSelectTextDraw(playerid);
  231.                     RemoverTextDrawPintura(playerid);
  232.                     PinturaFinalizada(playerid, GetPVarInt(playerid, "Cor1"), GetPVarInt(playerid, "Cor2"));
  233.                     DeletePVar(playerid, "Cor1");
  234.                     DeletePVar(playerid, "Cor2");
  235.                 }
  236.             }
  237.         }
  238.         return 1;
  239.     }
  240.     return 0;
  241. }
  242.  
  243. forward RemoverTextDrawPintura(playerid);
  244. public RemoverTextDrawPintura(playerid)
  245. {
  246.     for(new i = 0; i < 36; i++)
  247.     {
  248.         PlayerTextDrawHide(playerid, TextPintura[playerid][i]);
  249.         PlayerTextDrawDestroy(playerid, TextPintura[playerid][i]);
  250.     }
  251.     return 1;
  252. }
  253.  
  254. stock QuantasPinturas(modelo)//Quantidade de cores de cada veiculo samp! (0.3.7 ou versão anterior! (0.3DL também funcina!))
  255. {
  256.     new Contem[212] = {1, 1, 1, 1, 2, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1,
  257.     2, 1, 2, 2, 0, 0, 2, 2, 1, 0, 0, 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 2, 1, 0, 0, 2, 2, 0, 2, 2,
  258.     1, 1, 0, 1, 1, 1, 0, 2, 2, 1, 2, 0, 0, 2, 1, 2, 2, 1, 1, 1, 1, 1, 0, 2, 1, 1, 2, 2, 2, 1, 0, 2, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 0, 0, 0, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 0, 1, 2,
  259.     0, 0, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 1, 0, 0, 1, 2, 0, 2};
  260.     return Contem[modelo-400];
  261. }
Advertisement
Add Comment
Please, Sign In to add comment