Guest User

LouNGeR

a guest
Dec 30th, 2008
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. --#######################
  2. --### Car lights test ###
  3. --### � 2008 LouNGeR  ###
  4. --#######################
  5.  
  6. KEY = {}
  7. KEY["TAB"] = 9
  8. KEY["0"] = 48
  9. KEY["1"] = 49
  10. KEY["2"] = 50
  11. KEY["3"] = 51
  12. KEY["4"] = 52
  13. KEY["5"] = 53
  14. KEY["6"] = 54
  15. KEY["7"] = 55
  16. KEY["8"] = 56
  17. KEY["9"] = 57
  18.  
  19. --PLAYER_ID, PLAYER_INDEX, PLAYER_CHAR, PLAYER_CAR, IN_CAR = 0
  20.  
  21. function Init()
  22.     Wait(4000)
  23. end
  24.  
  25. function WaitForPlayerPoolCreation()
  26.     while IsPlayerPoolCreated() == 0 do
  27.         Wait(2000)
  28.     end
  29. end
  30.  
  31. function WaitForValidPlayer()
  32.     PLAYER_CHAR = 0
  33.     repeat
  34.         CallNative("GET_PLAYER_ID")
  35.         PLAYER_ID = GetIntResult()
  36.  
  37.         if (PLAYER_ID >= 0) then
  38.             PushInt(PLAYER_ID)
  39.             CallNative("CONVERT_INT_TO_PLAYERINDEX")
  40.             PLAYER_INDEX = GetIntResult()
  41.             PushInt(PLAYER_INDEX)
  42.             PushVarPtr()   
  43.             CallNative("GET_PLAYER_CHAR")
  44.             PLAYER_CHAR = GetIntParam(1)
  45.  
  46.             if (PLAYER_CHAR <= 0) then Wait(1000) end  
  47.         end
  48.     until (PLAYER_CHAR > 0)  
  49. end
  50.  
  51. -- Borrowed from Prince-Link
  52. -- http://www.gtaforums.com/index.php?showtopic=386908&view=findpost&p=1058802175
  53. -- http://insomnia247.nl/~shadowlink/car.lua
  54. function getPlayerCar()
  55.   PLAYER_CAR = 0
  56.   IN_CAR = 0
  57.   repeat
  58.     PushInt(PLAYER_CHAR)
  59.     CallNative("IS_CHAR_IN_ANY_CAR")
  60.     IN_CAR = GetIntResult()
  61.     if(IN_CAR > 0) then
  62.       PushInt(PLAYER_CHAR)
  63.       PushVarPtr()
  64.       CallNative("GET_CAR_CHAR_IS_USING")
  65.       PLAYER_CAR = GetIntParam(1)
  66.     end
  67.     if (PLAYER_CAR <= 0) then
  68.       Wait(1000)
  69.     end
  70.   until (PLAYER_CAR > 0)
  71. end
  72.  
  73. function Main()
  74.     Init()
  75.  
  76.     while true do
  77.         WaitForPlayerPoolCreation()
  78.         WaitForValidPlayer()
  79.         getPlayerCar()
  80.  
  81.         if IsKeyPressed(KEY["TAB"]) == 1 then
  82.             if IsKeyPressed(KEY["1"]) == 1 then
  83.                 PushInt(PLAYER_CAR)
  84.                 PushInt(0)
  85.                 CallNative("SET_VEH_HAZARDLIGHTS")
  86.             end
  87.             if IsKeyPressed(KEY["2"]) == 1 then
  88.                 PushInt(PLAYER_CAR)
  89.                 PushInt(1)
  90.                 CallNative("SET_VEH_HAZARDLIGHTS")
  91.             end
  92.         end
  93.  
  94.         Wait(300)
  95.     end
  96. end
  97.  
  98. Main();
Advertisement
Add Comment
Please, Sign In to add comment