P4rano1a Posted June 5, 2022 Share Posted June 5, 2022 Hola buenas, aclaro que no entiendo mucho sobre programación, he aprendiendo poco a poco viendo tutoriales y modificando una que otra cosa que descargo. El punto es que quiero hacer que este script de TP funcione con autos, que se pueda activar tocando el Claxon del vehículo, para que pueda Tpearme con el mismo vehiculo a un punto en especifico, y así darle un uso para "TP de Garaje", intenté cambiar el BindKey por "horn" y de un interior a otro me lleva a otras cordenadas y de un exterior no se teletransporta, estaría bastante agradecido si me pudiesen ayudar. local interiors = { -- {Ext"X", Ext"Y", Ext"Z", | IDInt, IDDim | IntX, IntY, IntZ | IDInt, IDDim | "Nombre"}, {1177.90234375, -1338.9755859375, 14.912269592285, 0, 0, 447, 2520, -98, 10, 0, "LSMD"}, {1195.3037109375, -1354.92578125, 13.389284133911, 0, 0, 1198.0654296875, -1402.2587890625, 13.257797241211, 0, 0, "Prueba"}, } enterPickup = nil exitPickup = nil local bind = "Enter" local screenW, screenH = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function() for i,v in pairs (interiors) do local enterPickup = createPickup(v[1], v[2], v[3], 3, 1318, 1) setElementInterior(enterPickup, v[4]) setElementDimension(enterPickup, v[5]) local exitPickup = createPickup(v[6], v[7], v[8], 3, 1318, 1) setElementInterior(exitPickup, v[9]) setElementDimension(exitPickup, v[10]) addEventHandler("onClientRender", root, function() if (isElementWithinPickup(localPlayer, enterPickup)) and getElementInterior(localPlayer) == getElementInterior(enterPickup) and getElementDimension(localPlayer) == getElementDimension(enterPickup) then dxDrawHelp("Propiedad : "..v[11], "Presiona "..bind.." para entrar.") elseif (isElementWithinPickup(localPlayer, exitPickup)) and getElementInterior(localPlayer) == getElementInterior(exitPickup) and getElementDimension(localPlayer) == getElementDimension(exitPickup) then dxDrawHelp("Propiedad : "..v[11], "Presiona "..bind.." para salir.") end end) bindKey(bind, "down", function() if (isElementWithinPickup(localPlayer, enterPickup)) and getElementInterior(localPlayer) == getElementInterior(enterPickup) and getElementDimension(localPlayer) == getElementDimension(enterPickup) then triggerServerEvent("warpPlayer", localPlayer, localPlayer, v[6], v[7], v[8], v[9], v[10]) elseif (isElementWithinPickup(localPlayer, exitPickup)) and getElementInterior(localPlayer) == getElementInterior(exitPickup) and getElementDimension(localPlayer) == getElementDimension(exitPickup) then triggerServerEvent("warpPlayer", localPlayer, localPlayer, v[1], v[2], v[3], v[4], v[5]) end end) end end) local blips = { -- blip ekleye bilirsiniz. {810.4853515625, -1616.16015625, 13.546875, 10}, } for i,v in pairs (blips) do createBlip(v[1], v[2], v[3], v[4], 2, 255, 255, 255, 255, 0, 100) end function guiGridListGetSelectedItemText ( gridList, column ) local item = guiGridListGetSelectedItem ( gridList ) if item then return guiGridListGetItemText ( gridList, item, column or 1 ) end return false end -- function isElementWithinPickup(theElement, thePickup) if (isElement(theElement) and getElementType(thePickup) == "pickup") then local x, y, z = getElementPosition(theElement) local x2, y2, z2 = getElementPosition(thePickup) if (getDistanceBetweenPoints3D(x2, y2, z2, x, y, z) <= 1) then return true end end return false end function round(num) if ( num >= 0 ) then return math.floor( num + .5 ) else return math.ceil( num - .5 ) end end function convertNumber( number ) local formatted = number while true do formatted, k = string.gsub( formatted, "^(-?%d+)(%d%d%d)", '%1 %2' ) if ( k==0 ) then break end end return formatted end function guiComboBoxAdjustHeight ( combobox, itemcount ) if getElementType ( combobox ) ~= "gui-combobox" or type ( itemcount ) ~= "number" then error ( "Invalid arguments @ 'guiComboBoxAdjustHeight'", 2 ) end local width = guiGetSize ( combobox, false ) return guiSetSize ( combobox, width, ( itemcount * 20 ) + 20, false ) end Link to comment
alex17" Posted June 10, 2022 Share Posted June 10, 2022 (edited) Te dejo un pequeño ejemplo para que pruebes y cuando lo entiendas lo adaptas a lo que quieres hacer PD: en los bindkey tambien puedes usar los controles de mta en vez de teclas, en este caso coloque el claxón con bind ------ CLIENT ----- local interiors = { {1177.90234375, -1338.9755859375, 14.912269592285, 0, 0, 447, 2520, -98, 10, 0, "LSMD"}, {1195.3037109375, -1354.92578125, 13.389284133911, 0, 0, 1198.0654296875, -1402.2587890625, 13.257797241211, 0, 0, "Prueba"}, } bindKey("horn", "down", function() local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then -- interiors[1] = es la primera fila de datos de tu tabla, si quisieras obtener la posicion x,y,z de esa fila seria interiors[1][1], interiors[1][2], interiors[1][3] -- interiors[2] = es la segunda fila de datos de tu tabla, si quisieras obtener la posicion x,y,z de esa fila seria interiors[2][1], interiors[2][2], interiors[2][3] triggerServerEvent("warpVehicle", vehicle, interiors[1]) end end ) ------ SERVER ----- addEvent("warpVehicle", true) addEventHandler("warpVehicle", root) function(data) setElementPosition(source, data[1], data[2], data[3]) setElementRotation(source, data[4], data[5], data[6]) end ) Edited June 10, 2022 by alex17" 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now