Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*- CODE -*--
- colMaletero = {}
- colEsferaMaletero = {}
- function maletero(thePlayer)
- local x, y, z = getElementPosition(thePlayer)
- local dim = getElementDimension(thePlayer)
- local int = getElementInterior(thePlayer)
- colMaletero[thePlayer] = createColSphere(x, y, z, 5)
- setElementInterior(colMaletero[thePlayer], int)
- setElementDimension(colMaletero[thePlayer], dim)
- local vehiculos = getElementsWithinColShape(colMaletero[thePlayer], "vehicle")
- for k,veh in ipairs(vehiculos) do -- This checks every vehicle that is close to the player
- if veh and (veh ~= nil) and (getElementType(veh) == "vehicle") then -- This checks if its really an vehicle
- if (colEsferaMaletero[veh]) then
- destroyElement(colEsferaMaletero[veh])
- colEsferaMaletero[veh] = nil
- end
- local x, y, z = getElementPosition(veh)
- local pos = getVehicleHandlingProperty(veh, "centerOfMass")
- colEsferaMaletero[veh] = createColSphere(0, 0, 0, 2.5)
- attachElements(colEsferaMaletero[veh], veh, pos[1], pos[2]-2.5, pos[3])
- outputChatBox("x = "..x.." | y = "..y.." | z = "..z.." (veh)", thePlayer)
- --[[local x, y, z = getElementPosition(colEsferaMaletero[veh]) -- If you delete this comment, the script would work
- destroyElement(colEsferaMaletero[veh])
- colEsferaMaletero[veh] = createColSphere(x, y, z, 2.5)]]
- if colEsferaMaletero[veh] then -- If there is an sphere created then
- setTimer(function() -- This timer was created to check if it was a delay problem, it wasnt
- players = getElementsWithinColShape(colEsferaMaletero[veh], "player") -- Gets all the players inside the sphere
- if players and #players > 0 then -- If there are players then do fancy stuff
- for k,plr in ipairs(players) do
- x, y, z = getElementPosition(colEsferaMaletero[veh])
- outputChatBox("x = "..x.." | y = "..y.." | z = "..z.." (2)", thePlayer)
- if (plr ~= nil) and (plr == thePlayer) then
- if (getElementData(veh, "maletero")) then
- setVehicleDoorOpenRatio(veh, 1, 0)
- setElementData(veh, "maletero", false)
- triggerClientEvent(root, "sonidoMaletero2", veh)
- else
- if (getElementData(veh, "dueno") == plr) then
- setVehicleDoorOpenRatio(veh, 1, 1)
- setElementData(veh, "maletero", true)
- triggerClientEvent(root, "sonidoMaletero", veh)
- else
- if not (getElementData(thePlayer, "msg-mal")) then
- --outputChatBox("#FF3232[MALETERO] #FFFFFFDebes ser el dueño del vehículo para abrir el maletero.", thePlayer, 0,0,0,true)
- end
- end
- end
- else
- if isElement(plr) then
- 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.
- else
- outputChatBox("#FF3232Error: "..#players.." jugadores", thePlayer, 0,0,0,true)
- end
- end
- end
- end
- destroyElement(colEsferaMaletero[veh])
- colEsferaMaletero[veh] = nil -- This deletes it
- end, 250, 1)
- end
- end
- end
- end
- addCommandHandler("maletero", maletero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement