jeffry4 Posted September 8, 2013 Share Posted September 8, 2013 Hola, estoy montando un server con MTA Paradise, y va todo genial, pero tengo algunas dudas, y un problema con una resource, bueno, empezemos. 1. Cuando te metes al sv, esta en ingles todo eso, donde edito eso, lo de new chartacter y todo eso, es que no se donde. 2. Lo de la resource: local rbWindow, rbList, bUse, bClose, tempObject, tempObjectID, tempObjectRot = nil local tempObjectPosX, tempObjectPosY, tempObjectPosZ, tempObjectPosRot = nil local roadblockID = { "978", "981", "3578", "1228", "1282", "1422", "1424", "1425", "1459", "3091" } -- objectid local roadblockTypes = { "Bloqueo pequeño", "Bloqueo grande", "Barrera amarilla", "Pequeña barrera de aviso", "Pequeña barrera de aviso con luz", "Barrera fea pequeña", "Bloqueo de paso", "Desvio ->", "Barrera de aviso","Vehiculos ->" } -- name local roadblockRot = { "180", "0", "0", "90", "90", "0", "0", "0", "0", "0" } -- rotation needed to face to player local thePlayer = getLocalPlayer() function enableRoadblockGUI(enable) if not (rbWindow) then local width, height = 300, 400 local scrWidth, scrHeight = guiGetScreenSize() local x = scrWidth*0.8 - (width/2) local y = scrHeight*0.75 - (height/2) rbWindow = guiCreateWindow ( x, y, width, height, "Crear bloqueos", false) rbList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, rbWindow) addEventHandler("onClientGUIDoubleClick", rbList, selectRoadblockGUI, false) local column = guiGridListAddColumn(rbList, "ID", 0.2) local column2 = guiGridListAddColumn(rbList, "Tipo", 0.6) local column3 = guiGridListAddColumn(rbList, "Rot", 0.1) for key, value in ipairs(roadblockID) do local newRow = guiGridListAddRow(rbList) guiGridListSetItemText(rbList, newRow, column, roadblockID[key], true, false) guiGridListSetItemText(rbList, newRow, column2, roadblockTypes[key], false, false) guiGridListSetItemText(rbList, newRow, column3, roadblockRot[key], false, false) end bUse = guiCreateButton(0.05, 0.85, 0.45, 0.1, "Usar", true, rbWindow) addEventHandler("onClientGUIClick", bUse, selectRoadblockGUI, false) bClose = guiCreateButton(0.5, 0.85, 0.45, 0.1, "Cerrar", true, rbWindow) addEventHandler("onClientGUIClick", bClose, cancelRoadblockGUI, false) outputChatBox("Selecciona una barrera y ponla donde tu quieras.", 0, 255, 0) outputChatBox("Pulsa alt izda para poner el objeto.", 0, 255, 0) showCursor(true) else cleanupRoadblockGUI() end end function cleanupRoadblockGUI() cleanupRoadblock() destroyElement(rbWindow) rbWindow = nil showCursor(false) end function cleanupRoadblock() if (isElement(tempObject)) then destroyElement(tempObject) tempObjectPosX, tempObjectPosY, tempObjectPosZ, tempObjectPosRot = nil tempObjectID, tempObjectRot = nil unbindKey ( "lalt", "down", convertTempToRealObject) end removeEventHandler("onClientPreRender",getRootElement(),updateRoadblockObject) end function selectRoadblockGUI(button, state) if (source==bUse) and (button=="left") or (source==rbList) and (button=="left") then local row, col = guiGridListGetSelectedItem(rbList) if (row==-1) or (col==-1) then outputChatBox("¡Por favor elige un tipo!", 255, 0, 0) else if (isElement(tempObject)) then destroyElement(tempObject) end local objectid = tonumber(guiGridListGetItemText(rbList, guiGridListGetSelectedItem(rbList), 1)) local objectrot = tonumber(guiGridListGetItemText(rbList, guiGridListGetSelectedItem(rbList), 3)) spawnTempObject(objectid, objectrot) showCursor(false) end end end function spawnTempObject(objectid, objectrot) -- create temporary object tempObjectID = objectid tempObjectRot = objectrot tempObject = createObject( objectid, 0, 0, 0, 0, 0, 0) setElementAlpha(tempObject, 150) setElementInterior ( tempObject, getElementInterior ( thePlayer ) ) setElementDimension ( tempObject, getElementDimension ( thePlayer ) ) bindKey ( "lalt", "down", convertTempToRealObject) updateRoadblockObject() addEventHandler("onClientPreRender",getRootElement(),updateRoadblockObject) end function convertTempToRealObject(key, keyState) if (isElement(tempObject)) then triggerServerEvent("roadblockCreateWorldObject", thePlayer, tempObjectID, tempObjectPosX, tempObjectPosY, tempObjectPosZ, tempObjectPosRot) cleanupRoadblock() showCursor(true) end end function updateRoadblockObject(key, keyState) if (isElement(tempObject)) then local distance = 6 local px, py, pz = getElementPosition ( thePlayer ) local rz = getPedRotation ( thePlayer ) local x = distance*math.cos((rz+90)*math.pi/180) local y = distance*math.sin((rz+90)*math.pi/180) local b2 = 15 / math.cos(math.pi/180) local nx = px + x local ny = py + y local nz = pz - 0.5 local objrot = rz + tempObjectRot if (objrot > 360) then objrot = objrot-360 end setElementRotation ( tempObject, 0, 0, objrot ) moveObject ( tempObject, 10, nx, ny, nz) tempObjectPosX = nx tempObjectPosY = ny tempObjectPosZ = nz tempObjectPosRot = objrot end end function cancelRoadblockGUI(button, state) if (source==bClose) and (button=="left") then cleanupRoadblockGUI() end end addEvent( "enableRoadblockGUI", true ) addEventHandler( "enableRoadblockGUI", getRootElement(), enableRoadblockGUI ) addCommandHandler("bloqueos", enableRoadblockGUI) Todo va bien, pero cuando le doy ya al lalt para ponerlo, el srv en la consola me da el siguiente error: but event is not added serverside. Espero respuestas. Link to comment
Recommended Posts