Advertisement
Guest User

client.lua

a guest
Sep 5th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. print('Script loaded')
  2. function changeLivery(vehicle) -- Function to change the livery
  3.         print('changeLivery function loaded')
  4.         -- It changes the livery between the first one (0), to the 10th one (9)
  5.         if livery < 9 then -- If the current livery is between 0 and 8 (we are still able to go further)
  6.             livery = livery + 1 -- So we change to the next one
  7.         else if livery == 9 then -- If the current livery is the last one (9)
  8.             livery = 0 -- Since we can't change to the nexxt one (cause the next is 10, which does not exist), we change it back to 0 (first one)
  9.         end
  10.  
  11.         SetVehicleLivery(vehicle, livery) -- Native function to set the livery of the vehicle to the above specified livery
  12.         print('Livery should''ve been changed now')
  13.         DisplayHelpText("~b~Livery ~g~Changed.") -- Success message
  14.  
  15. end
  16.  
  17. Citizen.CreateThread(function()
  18.     while true do -- Loop that triggers the livery changer function
  19.         print('The script is OK')
  20.         Wait(0)
  21.         ped = GetPlayerPed(-1)
  22.  
  23.         if IsPedInAnyVehicle(ped, false) then -- Only be able to change the livery if the player is in a vehicle
  24.             print('Vehicle enter event TRIGGERED')
  25.             vehicle = GetVehiclePedIsUsing(ped) -- Get the player vehicle's entity
  26.             livery = GetVehicleLivery(vehicle) -- Current livery
  27.  
  28.             if IsControlJustPressed(1, 182) then -- If player presses the L key
  29.                 print('L key press event TRIGGERED')
  30.                 changeLivery(vehicle) -- The livery changer function gets triggered, on the player's vehicle
  31.         else
  32.             DisplayHelpText("~b~You must be in a vehicle in order to change your livery!") -- Error message
  33.         end
  34.     end
  35. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement