Advertisement
sanellim

Untitled

Jun 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. local towed_vehicle = {}
  2.  
  3. local function ch_tow(player,choice)
  4. vRP.getUserId({player}, function(user_id)
  5. print('userid ch_tow ' .. user_id)
  6. vRPclient.getNearestOwnedVehicle(player,{7},function(ok,vtype,name)
  7. if towed_vehicle[user_id] == nil then
  8. print('tow ' .. ok)
  9. if ok then
  10. vRPclient.getNearestVehicle(player, {5}, function(veh)
  11. print('found car ' .. veh)
  12. vRPclient.towVehicle(player, {})
  13. vRP.closeMenu({player})
  14. end)
  15. else
  16. vRPclient.notify(player, {"No tow truck found."})
  17. end
  18. else
  19. vRPclient.untowVehicle(player, {})
  20. vRP.closeMenu({player})
  21. end
  22. end)
  23. end)
  24. end
  25.  
  26. function vRP.vehicleTowed()
  27. print('vehicle towed')
  28. vRPclient.notify(source, {"Vehicle towed!"})
  29. vRP.getUserId({source}, function(user_id)
  30. towed_vehicle[user_id] = true
  31. end)
  32. end
  33.  
  34. function vRP.vehicleunTowed()
  35. vRPclient.notify(source, {"Vehicle detached!"})
  36. vRP.getUserId({source}, function(user_id)
  37. towed_vehicle[user_id] = nil
  38. end)
  39. end
  40.  
  41. AddEventHandler("vRP:buildMainMenu",function(player)
  42. vRP.getUserId({player}, function(user_id)
  43. print('userid buildMainMenu ' .. user_id .. ' ' .. tostring(towed_vehicle[user_id]))
  44. if user_id ~= nil then
  45. local choices = {}
  46. print('tow menu')
  47. vRP.hasPermission({user_id, "repair.tow"}, function (permission)
  48. if permission then
  49. if (towed_vehicle[user_id] ~= nil) then
  50. choices["UnTow"] = { ch_tow, "Untow vehicle"}
  51. else
  52. choices["Tow"] = { ch_tow, "Tow vehicle"}
  53. end
  54. end
  55.  
  56. vRP.buildMainMenu({player,choices}) -- add choices to the player main menu
  57. end)
  58.  
  59. end
  60. end)
  61. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement