Advertisement
RanggaBS

Auto Attach Helmet

May 3rd, 2023
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.61 KB | Source Code | 0 0
  1. function GetPlayerClothes()
  2.     local CLOTHES = {
  3.     {
  4.         {0, "SP_80Rocker_H"},
  5.         {0, "SP_Alien_H"},
  6.         {0, "C_AngelHalo"},
  7.         {0, "P_Army2"},
  8.         {0, "P_Army1"},
  9.         {0, "P_Army3"},
  10.         {0, "SP_BMXhelmet"},
  11.         {0, "B_BHat2"},
  12.         {0, "B_BHat1"},
  13.         {0, "B_BHat4"},
  14.         {0, "B_BHat3"},
  15.         {0, "B_BHat6"},
  16.         {0, "B_BHat5"},
  17.         {0, "P_Bandana3"},
  18.         {0, "P_Bandana1"},
  19.         {0, "P_Bandana2"},
  20.         {0, "SP_Zorromask"},
  21.         {0, "SP_Basshat"},
  22.         {0, "B_Bucket1"},
  23.         {0, "SP_BikeHelmet"},
  24.         {0, "SP_Ninja_H"},
  25.         {0, "S_BHat1"},
  26.         {0, "S_BHat3"},
  27.         {0, "S_BHat2"},
  28.         {0, "S_Sunvisor1"},
  29.         {0, "S_Sunvisor3"},
  30.         {0, "S_Sunvisor2"},
  31.         {0, "SP_Goldsuit_H"},
  32.         {0, "P_BHat6"},
  33.         {0, "P_BHat1"},
  34.         {0, "P_BHat2"},
  35.         {0, "P_BHat3"},
  36.         {0, "P_BHat4"},
  37.         {0, "P_BHat5"},
  38.         {0, "C_CanadaHat"},
  39.         {0, "C_ClownWig"},
  40.         {0, "SP_Cowboyhat"},
  41.         {0, "B_Various5"},
  42.         {0, "SP_GK_Helmet"},
  43.         {0, "C_DevilHorns"},
  44.         {0, "SP_Duncehat"},
  45.         {0, "SP_EdnaMask"},
  46.         {0, "SP_EiffelHat"},
  47.         {0, "SP_Elf_H"},
  48.         {0, "SP_Colum_H"},
  49.         {0, "SP_Firehat"},
  50.         {0, "SP_Fries_H"},
  51.         {0, "SP_Einstein"},
  52.         {0, "SP_Gnome_H"},
  53.         {0, "SP_MortarBhat"},
  54.         {0, "SP_NinjaW_H"},
  55.         {0, "SP_Hazmat"},
  56.         {0, "SP_GymDisguise"},
  57.         {0, "B_Various1"},
  58.         {0, "R_Hat3"},
  59.         {0, "R_Hat2"},
  60.         {0, "R_Hat1"},
  61.         {0, "SP_MBand_H"},
  62.         {0, "SP_Mascot_H"},
  63.         {0, "SP_Nerd_H"},
  64.         {0, "B_Hunter1"},
  65.         {0, "SP_Nutcrack_H"},
  66.         {0, "B_Hunter2"},
  67.         {0, "R_Hat4"},
  68.         {0, "SP_Panda_H"},
  69.         {0, "SP_PigMask"},
  70.         {0, "SP_PirateHat"},
  71.         {0, "SP_PithHelmet"},
  72.         {0, "R_Hat5"},
  73.         {0, "SP_Pumpkin_head"},
  74.         {0, "SP_Nascar_H"},
  75.         {0, "SP_NinjaR_H"},
  76.         {0, "SP_Antlers"},
  77.         {0, "B_Various2"},
  78.         {0, "SP_Ween_H"},
  79.         {0, "C_StrangeHat"},
  80.         {0, "R_Hat6"},
  81.         {0, "B_Various3"},
  82.         {0, "B_Various4"},
  83.         {0, "SP_Pophat"},
  84.         {0, "B_Hunter3"},
  85.         {0, "B_Bucket2"},
  86.         {0, "SP_VHelmet"},
  87.         {0, "SP_Werewolf"},
  88.         {0, "SP_Wrestling_H"},
  89.     },
  90.     {
  91.         {1, "B_LSleeves3"},
  92.         {1, "SP_80Rocker_T"},
  93.         {1, "R_SSleeves4"},
  94.         {1, "R_SSleeves6"},
  95.         {1, "R_SSleeves5"},
  96.         {1, "SP_Alien_T"},
  97.         {1, "R_LSleeves1"},
  98.         {1, "R_Sweater5"},
  99.         {1, "R_Sweater1"},
  100.         {1, "P_Jacket5"},
  101.         {1, "P_Jacket4"},
  102.         {1, "P_Sweater3"},
  103.         {1, "P_Sweater2"},
  104.         {1, "S_Sweater1"},
  105.         {1, "SP_BandShirt"},
  106.         {1, "SP_BikeJersey"},
  107.         {1, "P_Jacket1"},
  108.         {1, "B_Jacket2"},
  109.         {1, "SP_Ninja_T"},
  110.         {1, "SP_Boxing_T"},
  111.         {1, "B_Jersey1"},
  112.         {1, "B_Jacket6"},
  113.         {1, "S_LSleeves2"},
  114.         {1, "S_LSleeves1"},
  115.         {1, "S_Jacket3"},
  116.         {1, "S_Jacket4"},
  117.         {1, "S_Sweater5"},
  118.         {1, "SP_XmsSweater"},
  119.         {1, "B_Sweater4"},
  120.         {1, "P_SSleeves2"},
  121.         {1, "B_SSleeves1"},
  122.         {1, "R_Jacket2"},
  123.         {1, "SP_Elf_T"},
  124.         {1, "SP_Colum_T"},
  125.         {1, "P_SSleeves5"},
  126.         {1, "B_Jersey8"},
  127.         {1, "B_Jersey7"},
  128.         {1, "P_Jacket6"},
  129.         {1, "SP_Goldsuit_T"},
  130.         {1, "SP_Gnome_T"},
  131.         {1, "B_Jacket1"},
  132.         {1, "SP_NinjaW_T"},
  133.         {1, "SP_Wrestling_T"},
  134.         {1, "B_SSleeves3"},
  135.         {1, "SP_HipShirt"},
  136.         {1, "B_Jersey10"},
  137.         {1, "B_Jersey9"},
  138.         {1, "P_Sweater4"},
  139.         {1, "P_Sweater5"},
  140.         {1, "P_Sweater6"},
  141.         {1, "B_Jacket3"},
  142.         {1, "R_Jacket5"},
  143.         {1, "R_Sweater4"},
  144.         {1, "R_Sweater3"},
  145.         {1, "P_Jacket2"},
  146.         {1, "B_LSleeves2"},
  147.         {1, "P_LSleeves7"},
  148.         {1, "P_LSleeves2"},
  149.         {1, "P_LSleeves8"},
  150.         {1, "P_LSleeves6"},
  151.         {1, "P_LSleeves3"},
  152.         {1, "P_LSleeves4"},
  153.         {1, "P_LSleeves1"},
  154.         {1, "P_LSleeves5"},
  155.         {1, "SP_MBand_T"},
  156.         {1, "SP_MathShirt"},
  157.         {1, "P_SSleeves1"},
  158.         {1, "SP_Fries_T"},
  159.         {1, "SP_MuscleShirt"},
  160.         {1, "SP_MusicPJ_T"},
  161.         {1, "SP_MusicShirt"},
  162.         {1, "SP_Nerd_T"},
  163.         {1, "P_LSleeves9"},
  164.         {1, "SP_Nutcrack_T"},
  165.         {1, "P_Jacket3"},
  166.         {1, "SP_Orderly_T"},
  167.         {1, "SP_Prison_T"},
  168.         {1, "P_Sweater1"},
  169.         {1, "SP_Nascar_T"},
  170.         {1, "SP_NinjaR_T"},
  171.         {1, "P_Sweater7"},
  172.         {1, "P_Sweater8"},
  173.         {1, "R_SSleeves2"},
  174.         {1, "R_SSleeves1"},
  175.         {1, "B_Jersey6"},
  176.         {1, "B_Jersey5"},
  177.         {1, "S_Sweater2"},
  178.         {1, "B_Sweater3"},
  179.         {1, "SP_PieShirt"},
  180.         {1, "SP_Ween_T"},
  181.         {1, "SP_PJ_T"},
  182.         {1, "B_Jersey4"},
  183.         {1, "B_Jersey3"},
  184.         {1, "C_StpdShrt"},
  185.         {1, "P_SSleeves9"},
  186.         {1, "P_SSleeves4"},
  187.         {1, "P_SSleeves10"},
  188.         {1, "P_SSleeves8"},
  189.         {1, "P_SSleeves6"},
  190.         {1, "P_SSleeves3"},
  191.         {1, "P_SSleeves7"},
  192.         {1, "S_LSleeves3"},
  193.         {1, "S_LSleeves4"},
  194.         {1, "B_SSleeves2"},
  195.         {1, "R_Jacket1"},
  196.         {1, "P_SSleeves12"},
  197.         {1, "P_SSleeves13"},
  198.         {1, "P_SSleeves14"},
  199.         {1, "P_SSleeves11"},
  200.         {1, "R_Sweater2"},
  201.         {1, "B_LSleeves4"},
  202.         {1, "P_LSleeves10"},
  203.         {1, "R_LSleeves2"},
  204.         {1, "R_LSleeves5"},
  205.         {1, "R_LSleeves4"},
  206.         {1, "B_Sweater2"},
  207.     },
  208.     {
  209.         {2, "R_Watch1"},
  210.         {2, "R_Watch3"},
  211.         {2, "R_Watch2"},
  212.         {2, "R_Watch4"},
  213.         {2, "SP_Boxing_G_L"},
  214.         {2, "P_Watch1"},
  215.         {2, "C_PinkWatch"},
  216.         {2, "S_Wristband1"},
  217.         {2, "S_Wristband4"},
  218.         {2, "S_Wristband6"},
  219.     },
  220.     {
  221.         {3, "P_Wristband8"},
  222.         {3, "P_Wristband7"},
  223.         {3, "SP_Boxing_G_R"},
  224.         {3, "R_Wristband1"},
  225.         {3, "R_Wristband4"},
  226.         {3, "R_Wristband2"},
  227.         {3, "R_Wristband3"},
  228.         {3, "B_Wristband1"},
  229.         {3, "P_Wristband6"},
  230.         {3, "P_Wristband2"},
  231.         {3, "SP_NerdWatch"},
  232.         {3, "P_Wristband1"},
  233.         {3, "P_Wristband5"},
  234.         {3, "P_Wristband3"},
  235.         {3, "S_Wristband2"},
  236.         {3, "S_Wristband3"},
  237.         {3, "S_Wristband5"},
  238.         {3, "P_Wristband4"},
  239.         {3, "B_Wristband2"},
  240.         {3, "B_Wristband3"},
  241.         {3, "B_Wristband4"},
  242.         {3, "B_Wristband5"},
  243.     },
  244.     {
  245.         {4, "B_Shorts7"},
  246.         {4, "B_Shorts6"},
  247.         {4, "B_Shorts2"},
  248.         {4, "SP_80Rocker_L"},
  249.         {4, "SP_Alien_L"},
  250.         {4, "R_Pants5"},
  251.         {4, "R_Pants4"},
  252.         {4, "B_Pants1"},
  253.         {4, "B_Shorts1"},
  254.         {4, "SP_BikeShorts"},
  255.         {4, "P_Pants5"},
  256.         {4, "SP_Ninja_L"},
  257.         {4, "SP_Boxing_L"},
  258.         {4, "S_Pants3"},
  259.         {4, "S_Shorts4"},
  260.         {4, "S_Shorts6"},
  261.         {4, "S_Shorts5"},
  262.         {4, "B_Shorts3"},
  263.         {4, "C_ClownPants"},
  264.         {4, "B_Pants4"},
  265.         {4, "B_Pants8"},
  266.         {4, "SP_Elf_L"},
  267.         {4, "SP_Colum_L"},
  268.         {4, "P_Pants6"},
  269.         {4, "SP_Goldsuit_L"},
  270.         {4, "SP_Gnome_L"},
  271.         {4, "SP_NinjaW_L"},
  272.         {4, "SP_Wrestling_L"},
  273.         {4, "P_Pants3"},
  274.         {4, "SP_PJ_L"},
  275.         {4, "B_Pants2"},
  276.         {4, "P_Pants7"},
  277.         {4, "R_Pants3"},
  278.         {4, "R_Pants2"},
  279.         {4, "SP_MBand_L"},
  280.         {4, "SP_Fries_L"},
  281.         {4, "SP_MusicPJ_L"},
  282.         {4, "SP_Nerd_L"},
  283.         {4, "SP_Nutcrack_L"},
  284.         {4, "SP_Orderly_P"},
  285.         {4, "P_Pants4"},
  286.         {4, "P_Pants1"},
  287.         {4, "SP_Prison_L"},
  288.         {4, "SP_Nascar_L"},
  289.         {4, "B_Pants3"},
  290.         {4, "SP_NinjaR_L"},
  291.         {4, "P_Pants2"},
  292.         {4, "R_Shorts1"},
  293.         {4, "R_Shorts5"},
  294.         {4, "R_Shorts2"},
  295.         {4, "R_Shorts3"},
  296.         {4, "R_Shorts4"},
  297.         {4, "SP_Shorts"},
  298.         {4, "S_Shorts1"},
  299.         {4, "S_Pants1"},
  300.         {4, "SP_Ween_L"},
  301.         {4, "B_Shorts5"},
  302.         {4, "B_Shorts4"},
  303.         {4, "SP_Briefs"},
  304.         {4, "SP_Swimsuit"},
  305.         {4, "B_Pants7"},
  306.         {4, "B_Pants6"},
  307.         {4, "R_Pants1"},
  308.     },
  309.     {
  310.         {5, "SP_80Rocker_FT"},
  311.         {5, "R_Boots2"},
  312.         {5, "R_Sneakers4"},
  313.         {5, "P_Boots4"},
  314.         {5, "SP_Ninja_FT"},
  315.         {5, "P_Sneakers16"},
  316.         {5, "SP_Boxing_ft"},
  317.         {5, "B_Sneakers3"},
  318.         {5, "P_Sneakers18"},
  319.         {5, "B_Sneakers12"},
  320.         {5, "S_Sneakers2"},
  321.         {5, "P_Sneakers2"},
  322.         {5, "C_ClownShoes"},
  323.         {5, "R_Boots3"},
  324.         {5, "B_Sneakers2"},
  325.         {5, "B_Boots2"},
  326.         {5, "SP_Elf_FT"},
  327.         {5, "SP_Colum_FT"},
  328.         {5, "B_Boots1"},
  329.         {5, "B_Boots4"},
  330.         {5, "B_Boots3"},
  331.         {5, "P_Sneakers17"},
  332.         {5, "P_Sneakers9"},
  333.         {5, "P_Sneakers14"},
  334.         {5, "P_Sneakers10"},
  335.         {5, "P_Sneakers15"},
  336.         {5, "SP_Goldsuit_ft"},
  337.         {5, "SP_Gnome_ft"},
  338.         {5, "SP_NinjaW_FT"},
  339.         {5, "S_Sneakers1"},
  340.         {5, "R_Sneakers1"},
  341.         {5, "R_Sneakers2"},
  342.         {5, "R_Sneakers3"},
  343.         {5, "P_Sneakers3"},
  344.         {5, "P_Sneakers7"},
  345.         {5, "P_Sneakers4"},
  346.         {5, "P_Sneakers5"},
  347.         {5, "P_Sneakers6"},
  348.         {5, "SP_MBand_FT"},
  349.         {5, "SP_Mascot_B"},
  350.         {5, "P_Boots3"},
  351.         {5, "SP_Nerd_FT"},
  352.         {5, "SP_Nutcrack_FT"},
  353.         {5, "P_Boots1"},
  354.         {5, "SP_Orderly_B"},
  355.         {5, "SP_Panda_B"},
  356.         {5, "SP_Nascar_FT"},
  357.         {5, "SP_NinjaR_FT"},
  358.         {5, "B_Sneakers10"},
  359.         {5, "B_Sneakers8"},
  360.         {5, "B_Sneakers9"},
  361.         {5, "B_Sneakers6"},
  362.         {5, "R_Sneakers5"},
  363.         {5, "P_Sneakers8"},
  364.         {5, "B_Sneakers1"},
  365.         {5, "P_Sneakers19"},
  366.         {5, "P_Sneakers13"},
  367.         {5, "P_Sneakers11"},
  368.         {5, "P_Sneakers12"},
  369.         {5, "SP_Socks"},
  370.         {5, "B_Sneakers5"},
  371.         {5, "B_Sneakers4"},
  372.         {5, "B_Sneakers13"},
  373.         {5, "B_Sneakers11"},
  374.         {5, "P_Sneakers1"},
  375.         {5, "P_Boots2"},
  376.         {5, "B_Boots5"},
  377.         {5, "SP_Wrestling_ft"},
  378.     },
  379. }
  380.     local c = {}
  381.     for i = 0, 5 do
  382.         for _, v in ipairs(CLOTHES[i+1]) do
  383.             if v[1] == i then
  384.                 local index, id = ClothingGetPlayer(i)
  385.                 --if ClothingGetPlayer(i) == ObjectNameToHashID(v[2]) then
  386.                 if index == ObjectNameToHashID(v[2]) then
  387.                     c[i] = v[2]
  388.                 end
  389.             end
  390.         end
  391.         c[i] = c[i] ~= '' and c[i] or ''
  392.     end
  393.     return c
  394. end
  395.  
  396. function main()
  397.     while not SystemIsReady() do
  398.         Wait(0)
  399.     end
  400.     local motor = {[275] = true, [276] = true}
  401.     local pakaian = {}
  402.     local kendaraan
  403.     local udahPakeHelm = false
  404.     while true do
  405.         Wait(0)
  406.         if PlayerIsInAnyVehicle() and motor[VehicleGetModelId(VehicleFromDriver(gPlayer))] then
  407.             kendaraan = VehicleFromDriver(gPlayer)
  408.             while PlayerIsInVehicle(kendaraan) do
  409.                 Wait(0)
  410.                 if not udahPakeHelm then    -- MUST ADD THIS BEFORE THE LINE BELOW TO AVOID CRASH
  411.                     local index, id = ClothingGetPlayer(0)
  412.                     --if ClothingGetPlayer(0) ~= ObjectNameToHashID("SP_BikeHelmet") then       -- CRASH IF THIS STATEMENT IS PLACED DIRECTLY AFTER LOOP
  413.                     if index ~= ObjectNameToHashID("SP_BikeHelmet") then
  414.                         pakaian = GetPlayerClothes()
  415.                         ClothingSetPlayer(0, "SP_BikeHelmet")
  416.                         ClothingBuildPlayer()
  417.                         udahPakeHelm = true
  418.                         --collectgarbage()
  419.                     end
  420.                 end
  421.             end
  422.             while not PedMePlaying(gPlayer, "Default_KEY") do
  423.                 Wait(0)
  424.             end
  425.             ClothingSetPlayerOutfit("Uniform")
  426.             ClothingBuildPlayer()
  427.             for i = 0, 5 do
  428.                 if pakaian[i] ~= '' then
  429.                     ClothingSetPlayer(i, pakaian[i])
  430.                     ClothingBuildPlayer()
  431.                 end
  432.             end
  433.             --ClothingBuildPlayer()
  434.             udahPakeHelm = false
  435.             --collectgarbage()
  436.         end
  437.     end
  438. end
  439.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement