Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. --*- CODE -*--
  2.  
  3. colMaletero = {}
  4. colEsferaMaletero = {}
  5. function maletero(thePlayer)
  6. local x, y, z = getElementPosition(thePlayer)
  7. local dim = getElementDimension(thePlayer)
  8. local int = getElementInterior(thePlayer)
  9.  
  10. colMaletero[thePlayer] = createColSphere(x, y, z, 5)
  11. setElementInterior(colMaletero[thePlayer], int)
  12. setElementDimension(colMaletero[thePlayer], dim)
  13.  
  14. local vehiculos = getElementsWithinColShape(colMaletero[thePlayer], "vehicle")
  15. for k,veh in ipairs(vehiculos) do -- This checks every vehicle that is close to the player
  16. if veh and (veh ~= nil) and (getElementType(veh) == "vehicle") then -- This checks if its really an vehicle
  17. if (colEsferaMaletero[veh]) then
  18. destroyElement(colEsferaMaletero[veh])
  19. colEsferaMaletero[veh] = nil
  20. end
  21. local x, y, z = getElementPosition(veh)
  22. local pos = getVehicleHandlingProperty(veh, "centerOfMass")
  23. colEsferaMaletero[veh] = createColSphere(0, 0, 0, 2.5)
  24. attachElements(colEsferaMaletero[veh], veh, pos[1], pos[2]-2.5, pos[3])
  25.  
  26. outputChatBox("x = "..x.." | y = "..y.." | z = "..z.." (veh)", thePlayer)
  27.  
  28. --[[local x, y, z = getElementPosition(colEsferaMaletero[veh]) -- If you delete this comment, the script would work
  29. destroyElement(colEsferaMaletero[veh])
  30. colEsferaMaletero[veh] = createColSphere(x, y, z, 2.5)]]
  31.  
  32. if colEsferaMaletero[veh] then -- If there is an sphere created then
  33. setTimer(function() -- This timer was created to check if it was a delay problem, it wasnt
  34. players = getElementsWithinColShape(colEsferaMaletero[veh], "player") -- Gets all the players inside the sphere
  35.  
  36. if players and #players > 0 then -- If there are players then do fancy stuff
  37. for k,plr in ipairs(players) do
  38. x, y, z = getElementPosition(colEsferaMaletero[veh])
  39. outputChatBox("x = "..x.." | y = "..y.." | z = "..z.." (2)", thePlayer)
  40. if (plr ~= nil) and (plr == thePlayer) then
  41. if (getElementData(veh, "maletero")) then
  42. setVehicleDoorOpenRatio(veh, 1, 0)
  43. setElementData(veh, "maletero", false)
  44. triggerClientEvent(root, "sonidoMaletero2", veh)
  45. else
  46. if (getElementData(veh, "dueno") == plr) then
  47. setVehicleDoorOpenRatio(veh, 1, 1)
  48. setElementData(veh, "maletero", true)
  49. triggerClientEvent(root, "sonidoMaletero", veh)
  50. else
  51. if not (getElementData(thePlayer, "msg-mal")) then
  52. --outputChatBox("#FF3232[MALETERO] #FFFFFFDebes ser el dueño del vehículo para abrir el maletero.", thePlayer, 0,0,0,true)
  53. end
  54. end
  55. end
  56. else
  57. if isElement(plr) then
  58. outputChatBox("#FF3232Error: register "..getPlayerName(plr), thePlayer, 0,0,0,true) -- This thing started triggering when someone logged and i ussed the command, then i checked the other player position and it was 0, 0, 0, but the Sphere position was like 1000 units more south.
  59. else
  60. outputChatBox("#FF3232Error: "..#players.." jugadores", thePlayer, 0,0,0,true)
  61. end
  62. end
  63. end
  64. end
  65.  
  66. destroyElement(colEsferaMaletero[veh])
  67. colEsferaMaletero[veh] = nil -- This deletes it
  68. end, 250, 1)
  69. end
  70. end
  71. end
  72. end
  73. addCommandHandler("maletero", maletero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement