
UserToDelete
Members-
Posts
766 -
Joined
-
Last visited
Everything posted by UserToDelete
-
En server. Este es todo el script de servidor, se que en cliente cuando el trailer desaparezca, no lo hará para todos los jugadores, pero el argumento de fallo es el mismo. Todo server.lua function jobTruckStart(source) outputChatBox("Trabajo de camionero empezado",source, 255, 255, 0, true) playername = getPlayerName(source) camion = createVehicle ( 515,-1571.5654296875, -2745.900390625, 49, 0, 0, 45, tostring(playername)) trailer = createVehicle ( 435, 990, 990, 400, 0, 0, 45, tostring(playername) ) attachTrailerToVehicle ( camion, trailer ) warpPlayerIntoVehicle(source, camion, 0) setVehicleLocked(camion, true) end addEvent("camioneroStart", true) addEventHandler("camioneroStart", root, jobTruckStart) Debo poner el código en server con el argumento de destroy de "camión" y "trailer"? He tenido en cuenta de que "camión" y "trailer" es una global y al hacer un destroy se destruirían todos los camiones que haya en ese momento. Admito que cuando empecé este post el script era en servidor
-
addEventHandler("onClientVehicleExit", root, function (player, seat) if player == localPlayer then if seat == 0 then checkJobCamionero = getElementData(localPlayer, "trabajo") if checkJobCamionero == "camionero" then if isElementAttached then trailerD = getElementAttachedTo(source) outputChatBox(tostring(trailerD)) --outputs False --detachTrailerFromVehicle(source) end destroyElement(trailerD) destroyElement(source) setElementData(localPlayer, "trabajo", "ninguno") outputChatBox("complete") else outputChatBox("checkJob indica ningun trabajo") end else outputChatBox("no eres el conductor") end else outputChatBox("no localPlayer") end end ) Con tu codigo no funciona, ahor alo pase a cliente, y pasa lo mismo, (A veces se buggea con el tema de "setElementData" y dice al bajar del camion que no tengo trabajo El resto de las funciones que varian eso son estas: addEventHandler("onClientResourceStart", root, function () setElementData(localPlayer, "trabajo", "ninguno") end ) function startJob () checkJobL = getElementData(localPlayer, "trabajo") if checkJobL == "ninguno" then triggerServerEvent("camioneroStart", localPlayer, localPlayer) setElementData(localPlayer, "trabajo", "camionero") guiSetInputMode("allow_binds") showCursor(false) destroyElement(ventana) end end Solamente la primera vez me sale "false" y "Complete" , en el resto de los test que hago sin reiniciar el resource me sale "checkJob indica ningun trabajo" Log:
-
Ando creando un trabajo de camionero y al testarlo vi un error que no doy solucionado, trata de que el trailer al que esta sujeto al camion, no desaparece, sino que se queda sin el camion (sin el camion solamente, el trailer no desaparece), Cual puede ser el error? function destroyVehicle (jugador, seat) if seat == 0 then if isElementAttached then trailerD = getElementAttachedTo(source) outputChatBox(tostring(trailerD)) --outputs False destroyElement(trailerD) --Esta es la linea donde echa el error end destroyElement(source) end end addEventHandler("onVehicleExit", root, destroyVehicle) El error que suelta del debugscript 3 es el siguiente WARNING: [Trabajos]/vD_job_trucker/server.lua:18:Bad argument @ 'destroyElement' [Expected element at argument 1,got boolean] El trailer solitario
-
Cual es el evento que maneja esa funcion?
-
[SOLUCIONADO] loginPanel no responde a los botones
UserToDelete replied to UserToDelete's topic in Scripting
Gracias Tomas, habia tenido problemas con GUIs anteriormente por esa linea, no recordaba. -
[SOLUCIONADO] loginPanel no responde a los botones
UserToDelete replied to UserToDelete's topic in Scripting
Ahora el problema es que la GUI se cierra para todos los jugadores que la tienen abierta Server | Creo que aqui es donde esta el problema function onPlayerRegister_ (account, password) account2 = getAccount(account) logged = logIn(source, account2, password) outputChatBox(tostring(account2)..""..tostring(password), source, 0, 255, 0, true) if logged == true then outputChatBox("Te has logeado en el servidor", client, 0, 255, 0, true) state = false triggerClientEvent("closeGUI", source, state) end if logged == false then outputChatBox("No te has podido loggear en el servidor",client) end end addEvent("loginPanel", true) addEventHandler("loginPanel", root, onPlayerRegister_) Client function closeGUI_ (state) destroyElement(ventana) showCursor(state) --local guiSetInputMode("allow_binds") end addEvent("closeGUI", true) addEventHandler("closeGUI", root, closeGUI_) Edito: Si esto addEventHandler("closeGUI", root, closeGUI_) Lo cambio por addEventHandler("closeGUI", resourceRoot, closeGUI_) Deja de funcionar -
[SOLUCIONADO] loginPanel no responde a los botones
UserToDelete replied to UserToDelete's topic in Scripting
Cambiar "localPlayer" por "client" dentro del trigger, , esta "client" predifinido para un triggerServerEvent? Es eso lo que intentas decirme? -
[SOLUCIONADO] loginPanel no responde a los botones
UserToDelete replied to UserToDelete's topic in Scripting
Aun asi, el script sigue sin loggear Nuevo script -
Tengo un problema con un panel de loggeo, mas bien dos Los botones de "login" y "resgister" no funcionan La GUI se abre extrañamente dos veces, y con el tiempo se vuelve a abrir, e y si esta abierta parece que se abre otra vez Client.lua localPlayer = getLocalPlayer() addEventHandler("onClientResourceStart", root, function () local screenW, screenH = guiGetScreenSize() ventana = guiCreateWindow((screenW - 780) / 2, (screenH - 580) / 2, 780, 580, "== Panel de Login - TrosNos RolePlay ==", false) guiWindowSetMovable(ventana, false) guiWindowSetSizable(ventana, false) guiSetAlpha(ventana, 0.75) guiSetProperty(ventana, "CaptionColour", "FF00FF3C") edit_username = guiCreateEdit(10, 65, 331, 35, "", false, ventana) guiEditSetMaxLength (edit_username, 12) label_username = guiCreateLabel(20, 40, 130, 15, "Nombre de usuario", false, ventana) guiSetFont(label_username, "default-bold-small") label_password = guiCreateLabel(20, 110, 130, 15, "Contraseña", false, ventana) guiSetFont(label_password, "default-bold-small") edit_password = guiCreateEdit(10, 135, 331, 35, "", false, ventana) guiEditSetMasked(edit_password, true) guiEditSetMaxLength (edit_password, 12) button_login = guiCreateButton(10, 180, 160, 42, "Login", false, ventana) guiSetProperty(button_login, "NormalTextColour", "FFFFFFFF") button_register = guiCreateButton(180, 180, 160, 42, "Registrarse", false, ventana) guiSetProperty(button_register, "NormalTextColour", "FFFFFFFF") tabPanel = guiCreateTabPanel(11, 238, 759, 332, false, ventana) button_close = guiCreateButton(10, 220, 160, 42, "CERRAR", false, ventana) tab_info = guiCreateTab("Informacion del servidor", tabPanel) showCursor (true) addEventHandler("onClientGUIClick", button_close, closeGUI, false) addEventHandler("onClientGUIClick", button_login, loginb, false) addEventHandler("onClientGUIClick", button_register, loginr, false) end ) function openGUI_ () guiSetVisible(ventana, true) showCursor(true) end addEvent("openGUI",true) addEventHandler("openGUI",localPlayer, openGUI_) function closeGUI () guiSetVisible(ventana, false) end function loginb () triggerServerEvent("loginPanel", localPlayer, edit_username, edit_password) guiSetVisible(ventana, false) showCursor (false) end function loginr () triggerServerEvent("registerPanel", localPlayer, edit_username, edit_password) guiSetVisible(ventana, false) showCursor (false) end Server.lua function onPlayerRegister_ (source, account, password) logged = logIn(source, account, password) if logged == false then triggerClientEvent("openGUI", source) end end addEvent("loginPanel", true) addEventHandler("loginPanel", root, onPlayerRegister_) function onRegister_ (source, username, password) addAccount(username, password) onPlayerRegister_(source, username, password) end addEvent("registerPanel", true) addEventHandler("registerPanel", root, onRegister_)
-
function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function mensajesPrivados (source, _, name, mensaje) player = getPlayerFromPartialName(name) pc = getPlayerName(source) if ps then outputChatBox("PM: Has enviado el PM a: "..player,source,255,255,255,true) outputChatBox("PM: "..pc..": "..mensaje,player, 255,255,255,true) else --Debug outputChatBox("El jugador no existe | "..player,source,255,255,255,true) end end addCommandHandler("pm",mensajesPrivados) E estado probando con varias variantes, pero lo reconoce como "userdata" y no como "jugador" que esta mal ahi? no logro verlo, lo he comparado con otro script que tengo que usa la misma funcion, pero ni aun así
-
[RESUELTO] Como hago para que solo muestre 2 decimales?
UserToDelete replied to UserToDelete's topic in Scripting
Gracias Alexs Steel, funciono a la perfeccion! -
el evento quizas esté mal
-
Si es correcto eso que dices, puede ser un fallo de MTA, yo ahi no veo nada incorrecto Aun asi, eso de "path" y cosas asi, lo puedes poner como "meta.xml" no hace falta especificar la ubicacion si esta en la misma raiz y eso ultimo de userdata es porque estas cogiendo todos los nombres de todos los xmlNode, prueba con xmlFindNode
-
localPlayer = getLocalPlayer() speedx, speedy, speedz = getElementVelocity (localPlayer) actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) kmh = actualspeed * 180 recTotal = tonumber(kmh / 360000) + recTotal recTotalFiltres = recTotal --Esto es lo que tengo que volver a "1.35" guiSetText(textototal_, recTotalFiltres) El problema esque me aparecen numeros like "1.3584879778", y solo quiero que aparezca "1.35". Agradezco cualquier explicacion sobre el uso de string.gsub y consejos y cualquier ayuda! se que es con "string.gsub" pero no entiendo su syntax de http://www.lua.org
-
Solo puedes establecer texto desde servidor. Puedes usar esta funcion textCreateTextItem myDisplay = textCreateDisplay () -- create a display textDisplayAddObserver ( myDisplay, myPlayer ) -- make it visible to a player myTextItem = textCreateTextItem ( "Hola mundo!", 0.5, 0.5 ) -- create text item for the display textDisplayAddText ( myDisplay, myTextItem -- [url=https://wiki.multitheftauto.com/wiki/TextCreateTextItem]https://wiki.multitheftauto.com/wiki/TextCreateTextItem[/url]
-
lo he probado durante 24 horas y nada, tiene un error muy raro, solo registró el primer valor, luego nada function lastLogin_ (_, playerAccount) local tiempo = getRealTime() local dia = tiempo.monthday local mes = tiempo.month playerAccount = getAccountName(playerAccount) local xmlFile if fileExists("lastLogin.xml") then xmlFile = xmlLoadFile("lastLogin.xml") else xmlFile = xmlCreateFile("lastLogin.xml", "lastLogin") end finder = xmlFindChild(xmlFile, tostring(playerAccount), 0) if xmlNodeGetName(finder) == playerAccount then xmlNodeSetValue(finder,""..tostring(dia).." de "..tostring(mes+1)) end if xmlNodeGetName(finder) == false then JugadorChi = xmlCreateChild (xmlFile, playerAccount) xmlNodeSetValue(finder,""..tostring(dia).." de "..tostring(mes)) end xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end addEventHandler("onPlayerLogin",root,lastLogin_) El script es el original de SASU, pero mirad el xml <lastLogin> <venadHD>12 de 1</venadHD> <!--Cuando debia ser 13 de 1 --> <ola123></ola123> <ale400></ale400> <matralix></matralix> <xCr1st1anx></xCr1st1anx> <MapacheTroll_2></MapacheTroll_2> <>Kross<></>Kross<> </lastLogin> Solo me ha registrado a mi, y para eso, de ayer!, que ha pasado? Nose si tiene algo que ver, que haya mas funciones en el mismo archivo, este es el archivo LUA completo: Sigue dando el mismo error que en el anterior post
-
Solucionado! el script de sasu funciona a la perfeccion, nose hasta que punto influye xmlUnloadFile, pero ahora funciona
-
Nada, sigue sin funcionar, hay algo que no funciona bien, pero hay una parte buena, funciona una parte del script, pero no el resto, dejo los errores abajo, porque no soy capaz de solucionarlo en el outputChatBox devuelve esto: "false, false" probe de varias maneras usando el (_,jugador), pero ni aun asi, necesito el script pero ya function lastLogin (_,jugador) tiempo = getRealTime() dia = tiempo.monthday mes = tiempo.month xmlFile = xmlLoadFile("ll.xml") playerAccount = getAccountName (getPlayerAccount(jugador)) finder = xmlFindChild(xmlFile, tostring(playerAccount), 0) finder2 = xmlNodeGetName(finder) if tostring(finder2) == tostring(playerAccount) then xmlNodeSetValue(finder,""..tostring(dia).." de "..tostring(mes)) end if tostring(finder2) == "false" then JugadorChi = xmlCreateChild (xmlFile, playerAccount) xmlNodeSetValue(finder,""..tostring(dia).." de "..tostring(mes)) end xmlSaveFile(xmlFile) outputChatBox(""..tostring(finder2)..", "..tostring(finder).."",root,255,0,0,true) end addEventHandler("onPlayerLogin",root,lastLogin) Supuestamente el outputChatBox tenia que devolver "venadHD, venadHD", pero no, devuelve "false, false" El error: (Supuestamente aqui hay una imagen) Link por si no carga: http://www.trosnos.ga/_i/forum_84132_1.jpg
-
Lo volvi a modificar y nada, sigue sin registrar y sin mostrar ningun error
-
Aun quitandole año, no registra en el archivo XML, y he cambiado varias cosillas para hacerlo funcionar, y nada function lastLogin_ (source,_) tiempo = getRealTime() dia = tiempo.monthday mes = tiempo.month --año = tiempo.year xmlFile = xmlLoadFile("lastLogin.xml") playerAccount = getAccountName (getPlayerAccount(source)) finder = xmlFindChild(xmlFile, tostring(playerAccount), 0) finderContent = xmlNodeGetName(finder) if finderContent == playerAccount then xmlNodeSetValue(finderContent,""..tostring(dia).." de "..tostring(mes)) else --finderContent == false then JugadorChi = xmlCreateChild (xmlFile, playerAccount) if finderContent == playerAccount then xmlNodeSetValue(finderContent,""..tostring(dia).." de "..tostring(mes)) end end xmlSaveFile(xmlFile) end addCommandHandler("ll", lastLogin_) Alguna otra solucion? D: PD: Ahora registra esto: <lastLogin> <venadHD></venadHD> </lastLogin> y no tira ningun error!
-
[SOLUCIONADO] Como pongo separador de miles aqui?
UserToDelete replied to UserToDelete's topic in Scripting
Gracias Solid! -
Quiero poner un script que regitre el dia, el mes, y el año en el que un jugador entra por ultima vez en el sever en un archivo XML, lo unico que logre hacer es esto. Pero en el XML no me registra nada D: function lastLogin_ (source,_) tiempo = getRealTime() dia = tiempo.monthday mes = tiempo.month año = tiempo.year xmlFile = xmlLoadFile("lastLogin.xml") playerAccount = getAccountName (getPlayerAccount(source)) finder = xmlFindChild(xmlFile, playerAccount, 0) if finder == playerAccount then xmlNodeSetAttribute(finder,""..tostring(dia).." de "..tostring(mes).." de "..tostring(año)) end if not finder == playerAccount then JugadorChi = xmlCreateChild (xmlFile, playerAccount) if not JugadorChi == false then xmlNodeSetAttribute(finder,""..tostring(dia).." de "..tostring(mes).." de "..tostring(año)) end else end xmlSaveFile(xmlFile) outputChatBox(""..tostring(playerAccount)..", "..tostring(finder).."",root) outputChatBox(""..tostring(dia).." de "..tostring(mes).." de "..tostring(año).."",root) end addCommandHandler("ll", lastLogin_) y de hecho ni siquiera salta ninguna chatbox y este es el XML D: <lastLogin> </lastLogin>
-
exports [ "scoreboard" ]:addScoreboardColumn ( "Money", 3 ) -- Add the "Money" column to the scoreboard. function updatePlayersMoney ( ) -- Create "updatePlayersMoney" function. for index, player in ipairs ( getElementsByType "player" ) do -- Loop through all online players. setElementData ( player, "Money", getPlayerMoney ( player ) ) -- Set "Money" element data to the player money. end -- End our loop. end -- End our function. setTimer ( updatePlayersMoney, 10000, 0 ) -- Set a infinite 2.5 seconds timer to execute "updatePlayersMoney" function. como puedo hacer para que en vez de "157981", aparezca en su lugar "157.981"? nose hacerlo
-
***client.lua*** function checkTransfer() if isTransferBoxActive() == true then triggerServerEvent("siDL", localPlayer) else triggerServerEvent("noDL", localPlayer) end end setTimer(checkTransfer,2000,1) ***server.lua*** exports.scoreboard:addScoreboardColumn('DL') function onJoin() setElementData ( source, "DL", "Descargando" ) end addEventHandler("onPlayerJoin",root,onJoin) function onDownloadProgress () setElementData(client, "DL", "Descargando") end addEvent("siDL", true) addEventHandler("siDL",root,onDownloadProgress) function onDownloadFinish() setElementData ( client, "DL", "Jugando" ) end addEvent("noDL",true) addEventHandler("noDL",root,onDownloadFinish) he probado a cambiar "client" por "source" y nada, no me tira ningun error y no cambia el status el jodio
-
por ejemplo, hay 3 jugadores venadHD jake paloman si yo escribo "/givem a 100" le da el dinero a 2 jugadores en vez de a 1 Como hago para que solo sea uno? function transfer (source, _, name, dinero) dinero2 = tonumber(dinero) or 0 player = getPlayerFromPartialName(name) takeFromSource = takePlayerMoney(source, dinero2) playerName = getPlayerName(source) if player then if takeFromSource == true then outputChatBox("Dinero transferido", source, 0, 255, 0, true) givePlayerMoney(player ,dinero) outputChatBox("Has recibido: "..dinero2.."$ de: "..playerName, player, 0, 255, 0, true) else outputChatBox("Error") end else outputChatBox("Error") end end addCommandHandler("givem",transfer) Nada , nada, solo coge un jugador