Advertisement
ZumeZero

[Filterscript] Catalog vehicle on TextDraw

Jul 14th, 2014
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.98 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new Text:TextDrawBuyCars[10],
  4.         PlayerText:TextDrawBuyCarsPlayer[MAX_PLAYERS][3],
  5.         SeeCar[MAX_PLAYERS];
  6.  
  7. stock VehicleAvailable[][] =
  8. {
  9.         {0, 0, "Desconocido"},
  10.         {2000, 451, "Turismo"},
  11.         {5000, 412, "Savana"},
  12.         {6000, 445, "Admiral"},
  13.         {7000, 541, "Bullet"},
  14.         {4500, 467, "Oceanic"}
  15. };
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.         TextDrawBuyCars[0] = TextDrawCreate(651.000000, -10.000000, "_");
  20.         TextDrawBackgroundColor(TextDrawBuyCars[0], 255);
  21.         TextDrawFont(TextDrawBuyCars[0], 1);
  22.         TextDrawLetterSize(TextDrawBuyCars[0], 0.400000, 51.000000);
  23.         TextDrawColor(TextDrawBuyCars[0], -1);
  24.         TextDrawSetOutline(TextDrawBuyCars[0], 0);
  25.         TextDrawSetProportional(TextDrawBuyCars[0], 1);
  26.         TextDrawSetShadow(TextDrawBuyCars[0], 1);
  27.         TextDrawUseBox(TextDrawBuyCars[0], 1);
  28.         TextDrawBoxColor(TextDrawBuyCars[0], 255);
  29.         TextDrawTextSize(TextDrawBuyCars[0], -21.000000, 0.000000);
  30.         TextDrawSetSelectable(TextDrawBuyCars[0], 0);
  31.  
  32.         TextDrawBuyCars[1] = TextDrawCreate(651.000000, 447.000000, "_");
  33.         TextDrawBackgroundColor(TextDrawBuyCars[1], 255);
  34.         TextDrawFont(TextDrawBuyCars[1], 1);
  35.         TextDrawLetterSize(TextDrawBuyCars[1], 0.400000, 3.699998);
  36.         TextDrawColor(TextDrawBuyCars[1], -1);
  37.         TextDrawSetOutline(TextDrawBuyCars[1], 0);
  38.         TextDrawSetProportional(TextDrawBuyCars[1], 1);
  39.         TextDrawSetShadow(TextDrawBuyCars[1], 1);
  40.         TextDrawUseBox(TextDrawBuyCars[1], 1);
  41.         TextDrawBoxColor(TextDrawBuyCars[1], -16776961);
  42.         TextDrawTextSize(TextDrawBuyCars[1], -21.000000, 0.000000);
  43.         TextDrawSetSelectable(TextDrawBuyCars[1], 0);
  44.  
  45.         TextDrawBuyCars[2] = TextDrawCreate(60.000000, 50.000000, "VEHICLES SELECTION");
  46.         TextDrawBackgroundColor(TextDrawBuyCars[2], 255);
  47.         TextDrawFont(TextDrawBuyCars[2], 1);
  48.         TextDrawLetterSize(TextDrawBuyCars[2], 0.600000, 4.000000);
  49.         TextDrawColor(TextDrawBuyCars[2], -1);
  50.         TextDrawSetOutline(TextDrawBuyCars[2], 0);
  51.         TextDrawSetProportional(TextDrawBuyCars[2], 1);
  52.         TextDrawSetShadow(TextDrawBuyCars[2], 1);
  53.         TextDrawSetSelectable(TextDrawBuyCars[2], 0);
  54.  
  55.         TextDrawBuyCars[3] = TextDrawCreate(651.000000, -33.000000, "_");
  56.         TextDrawBackgroundColor(TextDrawBuyCars[3], 255);
  57.         TextDrawFont(TextDrawBuyCars[3], 1);
  58.         TextDrawLetterSize(TextDrawBuyCars[3], 0.400000, 3.699998);
  59.         TextDrawColor(TextDrawBuyCars[3], -1);
  60.         TextDrawSetOutline(TextDrawBuyCars[3], 0);
  61.         TextDrawSetProportional(TextDrawBuyCars[3], 1);
  62.         TextDrawSetShadow(TextDrawBuyCars[3], 1);
  63.         TextDrawUseBox(TextDrawBuyCars[3], 1);
  64.         TextDrawBoxColor(TextDrawBuyCars[3], -16776961);
  65.         TextDrawTextSize(TextDrawBuyCars[3], -21.000000, 0.000000);
  66.         TextDrawSetSelectable(TextDrawBuyCars[3], 0);
  67.  
  68.         TextDrawBuyCars[4] = TextDrawCreate(87.000000, 397.000000, "~G~BUY");
  69.         TextDrawAlignment(TextDrawBuyCars[4], 2);
  70.         TextDrawBackgroundColor(TextDrawBuyCars[4], 255);
  71.         TextDrawFont(TextDrawBuyCars[4], 3);
  72.         TextDrawLetterSize(TextDrawBuyCars[4], 0.730000, 3.299999);
  73.         TextDrawColor(TextDrawBuyCars[4], -1);
  74.         TextDrawSetOutline(TextDrawBuyCars[4], 1);
  75.         TextDrawSetProportional(TextDrawBuyCars[4], 1);
  76.         TextDrawTextSize(TextDrawBuyCars[4], 30.000000, 30.000000);
  77.         TextDrawSetSelectable(TextDrawBuyCars[4], true);
  78.  
  79.         TextDrawBuyCars[5] = TextDrawCreate(581.000000, 398.000000, "~R~EXIT");
  80.         TextDrawAlignment(TextDrawBuyCars[5], 2);
  81.         TextDrawBackgroundColor(TextDrawBuyCars[5], 255);
  82.         TextDrawFont(TextDrawBuyCars[5], 3);
  83.         TextDrawLetterSize(TextDrawBuyCars[5], 0.730000, 3.299999);
  84.         TextDrawColor(TextDrawBuyCars[5], -1);
  85.         TextDrawSetOutline(TextDrawBuyCars[5], 1);
  86.         TextDrawSetProportional(TextDrawBuyCars[5], 1);
  87.         TextDrawTextSize(TextDrawBuyCars[5], 30.000000, 30.000000);
  88.         TextDrawSetSelectable(TextDrawBuyCars[5], true);
  89.  
  90.         TextDrawBuyCars[6] = TextDrawCreate(409.000000, 88.000000, "Use the arrows on the screen to move!");
  91.         TextDrawAlignment(TextDrawBuyCars[6], 2);
  92.         TextDrawBackgroundColor(TextDrawBuyCars[6], 255);
  93.         TextDrawFont(TextDrawBuyCars[6], 2);
  94.         TextDrawLetterSize(TextDrawBuyCars[6], 0.220000, 1.800000);
  95.         TextDrawColor(TextDrawBuyCars[6], -1);
  96.         TextDrawSetOutline(TextDrawBuyCars[6], 0);
  97.         TextDrawSetProportional(TextDrawBuyCars[6], 1);
  98.         TextDrawSetShadow(TextDrawBuyCars[6], 1);
  99.         TextDrawSetSelectable(TextDrawBuyCars[6], 0);
  100.  
  101.         TextDrawBuyCars[7] = TextDrawCreate(471.000000, 274.000000, "~>~");
  102.         TextDrawAlignment(TextDrawBuyCars[7], 2);
  103.         TextDrawBackgroundColor(TextDrawBuyCars[7], 255);
  104.         TextDrawFont(TextDrawBuyCars[7], 1);
  105.         TextDrawLetterSize(TextDrawBuyCars[7], 0.800000, 4.000000);
  106.         TextDrawColor(TextDrawBuyCars[7], -1);
  107.         TextDrawSetOutline(TextDrawBuyCars[7], 0);
  108.         TextDrawSetProportional(TextDrawBuyCars[7], 1);
  109.         TextDrawSetShadow(TextDrawBuyCars[7], 1);
  110.         TextDrawTextSize(TextDrawBuyCars[7], 35.000000, 35.000000);
  111.         TextDrawSetSelectable(TextDrawBuyCars[7], true);
  112.  
  113.         TextDrawBuyCars[8] = TextDrawCreate(173.000000, 276.000000, "~<~");
  114.         TextDrawAlignment(TextDrawBuyCars[8], 2);
  115.         TextDrawBackgroundColor(TextDrawBuyCars[8], 255);
  116.         TextDrawFont(TextDrawBuyCars[8], 1);
  117.         TextDrawLetterSize(TextDrawBuyCars[8], 0.800000, 4.000000);
  118.         TextDrawColor(TextDrawBuyCars[8], -1);
  119.         TextDrawSetOutline(TextDrawBuyCars[8], 0);
  120.         TextDrawSetProportional(TextDrawBuyCars[8], 1);
  121.         TextDrawSetShadow(TextDrawBuyCars[8], 1);
  122.         TextDrawTextSize(TextDrawBuyCars[8], 40.000000, 40.000000);
  123.         TextDrawSetSelectable(TextDrawBuyCars[8], true);
  124.  
  125.         TextDrawBuyCars[9] = TextDrawCreate(541.000000, 89.000000, "_");
  126.         TextDrawBackgroundColor(TextDrawBuyCars[9], 255);
  127.         TextDrawFont(TextDrawBuyCars[9], 1);
  128.         TextDrawLetterSize(TextDrawBuyCars[9], 0.400000, -0.300001);
  129.         TextDrawColor(TextDrawBuyCars[9], -1);
  130.         TextDrawSetOutline(TextDrawBuyCars[9], 0);
  131.         TextDrawSetProportional(TextDrawBuyCars[9], 1);
  132.         TextDrawSetShadow(TextDrawBuyCars[9], 1);
  133.         TextDrawUseBox(TextDrawBuyCars[9], 1);
  134.         TextDrawBoxColor(TextDrawBuyCars[9], -16776961);
  135.         TextDrawTextSize(TextDrawBuyCars[9], 59.000000, 0.000000);
  136.         TextDrawSetSelectable(TextDrawBuyCars[9], 0);
  137.         return 1;
  138. }
  139.  
  140. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  141. {
  142.     new string[128];
  143.     if(_:clickedid != INVALID_TEXT_DRAW)
  144.     {
  145.  
  146.         if(clickedid == TextDrawBuyCars[4]) // COMPRAR
  147.         {
  148.  
  149.             #define Distancia 2.0
  150.             new Float:APosX,Float:APosY,Float:APosZ;
  151.             #pragma unused APosX
  152.             #pragma unused APosY
  153.             GetPlayerPos(playerid, APosX, APosY, APosZ);
  154.  
  155.             new Float:Pos[3]; /* 0: X - 1: Y - 2: A - */
  156.             GetPlayerPos(playerid, Pos[0], Pos[1], APosZ);
  157.             GetPlayerFacingAngle(playerid, Pos[2]);
  158.             if(GetPlayerVehicleID(playerid))
  159.             {
  160.  
  161.                 GetVehicleZAngle(GetPlayerVehicleID(playerid), Pos[2]);
  162.             }
  163.             Pos[0] += (Distancia * floatsin(-Pos[2], degrees));
  164.             Pos[1] += (Distancia * floatcos(-Pos[2], degrees));
  165.  
  166.             CreateVehicle(VehicleAvailable[SeeCar[playerid]][1], Pos[0] , Pos[1], APosZ, 0.0, 0, 0, 60000);
  167.  
  168.             for(new Dibujos = 0; Dibujos < 3; Dibujos++){
  169.                 PlayerTextDrawHide(playerid, TextDrawBuyCarsPlayer[playerid][Dibujos]);
  170.             }
  171.  
  172.             for (new Dibujos = 0; Dibujos < 10; Dibujos++){
  173.                 TextDrawHideForPlayer(playerid, TextDrawBuyCars[Dibujos]);
  174.             }
  175.             SeeCar[playerid] = 0;
  176.             CancelSelectTextDraw(playerid);
  177.             SendClientMessage(playerid, -1, "You have a new car!");
  178.         }
  179.         else if(clickedid == TextDrawBuyCars[5]) // SALIR
  180.         {
  181.  
  182.             for(new Dibujos = 0; Dibujos < 3; Dibujos++){
  183.                 PlayerTextDrawHide(playerid, TextDrawBuyCarsPlayer[playerid][Dibujos]);
  184.             }
  185.  
  186.             for (new Dibujos = 0; Dibujos < 10; Dibujos++){
  187.                 TextDrawHideForPlayer(playerid, TextDrawBuyCars[Dibujos]);
  188.             }
  189.             SeeCar[playerid] = 0;
  190.             CancelSelectTextDraw(playerid);
  191.             SendClientMessage(playerid, -1, "You have not bought anything!");
  192.         }
  193.         else if(clickedid == TextDrawBuyCars[7]) // >
  194.         {
  195.  
  196.             if(SeeCar[playerid] > sizeof(VehicleAvailable)-1) return SendClientMessage(playerid, -1, "No more cars!");
  197.             SeeCar[playerid]++;
  198.             format(string, sizeof(string), "~W~Price: ~R~$%d", VehicleAvailable[SeeCar[playerid]][0]);
  199.             PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][0], string);
  200.  
  201.             PlayerTextDrawSetPreviewModel(playerid, TextDrawBuyCarsPlayer[playerid][1], VehicleAvailable[SeeCar[playerid]][1]);
  202.  
  203.             format(string, sizeof(string), "%s", VehicleAvailable[SeeCar[playerid]][2]);
  204.             PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][2], string);
  205.  
  206.             for(new Dibujos = 0; Dibujos < 3; Dibujos++)
  207.             {
  208.  
  209.                 PlayerTextDrawShow(playerid, TextDrawBuyCarsPlayer[playerid][Dibujos]);
  210.             }
  211.         }
  212.         else if(clickedid == TextDrawBuyCars[8]) // <
  213.         {
  214.  
  215.             if(SeeCar[playerid] <= 1) return SendClientMessage(playerid, -1, "No more cars!");
  216.             SeeCar[playerid]--;
  217.             format(string, sizeof(string), "~W~Price: ~R~$%d", VehicleAvailable[SeeCar[playerid]][0]);
  218.             PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][0], string);
  219.  
  220.             PlayerTextDrawSetPreviewModel(playerid, TextDrawBuyCarsPlayer[playerid][1], VehicleAvailable[SeeCar[playerid]][1]);
  221.  
  222.             format(string, sizeof(string), "%s", VehicleAvailable[SeeCar[playerid]][2]);
  223.             PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][2], string);
  224.  
  225.             for(new Dibujos = 0; Dibujos < 3; Dibujos++)
  226.             {
  227.  
  228.                 PlayerTextDrawShow(playerid, TextDrawBuyCarsPlayer[playerid][Dibujos]);
  229.             }
  230.         }
  231.     }
  232.     return 1;
  233. }
  234.  
  235. main()
  236. {
  237.         print("\n----------------------------------");
  238.         print(" Blank Gamemode by your name here");
  239.         print("----------------------------------\n");
  240. }
  241.  
  242. public OnPlayerConnect(playerid)
  243. {
  244.     SeeCar[playerid] = 0;
  245.     TextDrawBuyCarsPlayer[playerid][0] = CreatePlayerTextDraw(playerid,337.000000, 327.000000, "~W~Price: ~R~$50.000");
  246.     PlayerTextDrawAlignment(playerid,TextDrawBuyCarsPlayer[playerid][0], 2);
  247.     PlayerTextDrawBackgroundColor(playerid,TextDrawBuyCarsPlayer[playerid][0], 255);
  248.     PlayerTextDrawFont(playerid,TextDrawBuyCarsPlayer[playerid][0], 3);
  249.     PlayerTextDrawLetterSize(playerid,TextDrawBuyCarsPlayer[playerid][0], 0.730000, 3.299999);
  250.     PlayerTextDrawColor(playerid,TextDrawBuyCarsPlayer[playerid][0], -1);
  251.     PlayerTextDrawSetOutline(playerid,TextDrawBuyCarsPlayer[playerid][0], 1);
  252.     PlayerTextDrawSetProportional(playerid,TextDrawBuyCarsPlayer[playerid][0], 1);
  253.     PlayerTextDrawSetSelectable(playerid,TextDrawBuyCarsPlayer[playerid][0], 0);
  254.  
  255.     TextDrawBuyCarsPlayer[playerid][1] = CreatePlayerTextDraw(playerid,257.000000, 101.000000, "412");
  256.     PlayerTextDrawBackgroundColor(playerid,TextDrawBuyCarsPlayer[playerid][1], 255);
  257.     PlayerTextDrawFont(playerid,TextDrawBuyCarsPlayer[playerid][1], 5);
  258.     PlayerTextDrawLetterSize(playerid,TextDrawBuyCarsPlayer[playerid][1], 0.700000, 12.000000);
  259.     PlayerTextDrawColor(playerid,TextDrawBuyCarsPlayer[playerid][1], -1);
  260.     PlayerTextDrawSetOutline(playerid,TextDrawBuyCarsPlayer[playerid][1], 0);
  261.     PlayerTextDrawSetProportional(playerid,TextDrawBuyCarsPlayer[playerid][1], 1);
  262.     PlayerTextDrawSetShadow(playerid,TextDrawBuyCarsPlayer[playerid][1], 1);
  263.     PlayerTextDrawUseBox(playerid,TextDrawBuyCarsPlayer[playerid][1], 1);
  264.     PlayerTextDrawBoxColor(playerid,TextDrawBuyCarsPlayer[playerid][1], 255);
  265.     PlayerTextDrawTextSize(playerid,TextDrawBuyCarsPlayer[playerid][1], 160.000000, 210.000000);
  266.     PlayerTextDrawSetPreviewModel(playerid, TextDrawBuyCarsPlayer[playerid][1], 412);
  267.     PlayerTextDrawSetPreviewRot(playerid, TextDrawBuyCarsPlayer[playerid][1], -16.000000, 0.000000, -55.000000, 1.000000);
  268.     PlayerTextDrawSetSelectable(playerid,TextDrawBuyCarsPlayer[playerid][1], 0);
  269.  
  270.     TextDrawBuyCarsPlayer[playerid][2] = CreatePlayerTextDraw(playerid,339.000000, 282.000000, "GREENWOOD");
  271.     PlayerTextDrawAlignment(playerid,TextDrawBuyCarsPlayer[playerid][2], 2);
  272.     PlayerTextDrawBackgroundColor(playerid,TextDrawBuyCarsPlayer[playerid][2], 255);
  273.     PlayerTextDrawFont(playerid,TextDrawBuyCarsPlayer[playerid][2], 3);
  274.     PlayerTextDrawLetterSize(playerid,TextDrawBuyCarsPlayer[playerid][2], 0.549999, 2.800000);
  275.     PlayerTextDrawColor(playerid,TextDrawBuyCarsPlayer[playerid][2], -1);
  276.     PlayerTextDrawSetOutline(playerid,TextDrawBuyCarsPlayer[playerid][2], 1);
  277.     PlayerTextDrawSetProportional(playerid,TextDrawBuyCarsPlayer[playerid][2], 1);
  278.     PlayerTextDrawSetSelectable(playerid,TextDrawBuyCarsPlayer[playerid][2], 0);
  279.     return 1;
  280. }
  281.  
  282. public OnPlayerDisconnect(playerid, reason)
  283. {
  284.     for(new Dibujos = 0; Dibujos < 3; Dibujos++){ PlayerTextDrawDestroy(playerid, TextDrawBuyCarsPlayer[playerid][Dibujos]); }
  285.     return 1;
  286. }
  287.  
  288. public OnFilterScriptExit()
  289. {
  290.     for (new Dibujos = 0; Dibujos < 10; Dibujos++) { TextDrawDestroy(TextDrawBuyCars[Dibujos]); }
  291.     return 1;
  292. }
  293.  
  294. public OnPlayerCommandText(playerid, cmdtext[])
  295. {
  296.     if (strcmp("/vehicles", cmdtext, true, 10) == 0)
  297.     {
  298.         new string[64];
  299.         SeeCar[playerid] = 1;
  300.         format(string, sizeof(string), "~W~Price: ~R~$%d", VehicleAvailable[SeeCar[playerid]][0]);
  301.         PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][0], string);
  302.         PlayerTextDrawSetPreviewModel(playerid, TextDrawBuyCarsPlayer[playerid][1], VehicleAvailable[SeeCar[playerid]][1]);
  303.         format(string, sizeof(string), "%s", VehicleAvailable[SeeCar[playerid]][2]);
  304.         PlayerTextDrawSetString(playerid, TextDrawBuyCarsPlayer[playerid][2], string);
  305.         for(new x = 0; x < 3; x++) { PlayerTextDrawShow(playerid, TextDrawBuyCarsPlayer[playerid][x]); }
  306.         for(new Dibujos = 0; Dibujos < 10; Dibujos++) { TextDrawShowForPlayer(playerid, TextDrawBuyCars[Dibujos]); }
  307.         for(new i = 0; i < 10; i++) { SendClientMessage(playerid,-1, " "); }
  308.         SelectTextDraw(playerid, 0xFFA800FF);
  309.         return 1;
  310.     }
  311.     return 0;
  312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement