DanielZ3RO Posted January 26, 2014 Share Posted January 26, 2014 Hola, tengo 2 preguntas, agradeceria la ayuda 1° Este pedazo de codigo sirve para privatizar cualquier resource o script, o cual se usa for _, group in ipairs ({"Admin", "Supermoderator"}) do local playerAccount = getPlayerAccount(source) if (not playerAccount) then return end local accountName = getAccountName(playerAccount) if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then 2° como se hace para centrar un gui en todas las resoluciones, es decir dxDrawText Que 800x600 Se Vea Tambien Centrado En 1368x768 u otra resolucion Link to comment
Cocodrilo Posted January 26, 2014 Share Posted January 26, 2014 Checa este ejemplo: Client Side: --Crear una Ventana y ocultarla PANEL = guiCreateWindow(0.27, 0.27, 0.47, 0.58, "", true) guiSetVisible ( PANEL, false ) --Evento para abrir la ventana function open_gui() if guiGetVisible(PANEL) == false then guiSetVisible(PANEL, true) showCursor (true) else guiSetVisible(PANEL, false) showCursor (false) end end addEvent("showGUI", true) addEventHandler("showGUI", getRootElement(), open_gui) Server Side: --Funcion para limitar la GUI mediante un grupo ACL function abrir(thePlayer) accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then triggerClientEvent(thePlayer, "showGUI", getRootElement()) end end --Funcion para activar un bind a la GUI cuando se inicia este resource function inicio() for index, player in ipairs(getElementsByType("player")) do bindKey(player, "F5", "down", abrir) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), inicio) --Funcion para activar un bind cuando un player entra al servidor function entrar() bindKey(source, "F5", "down", abrir) end addEventHandler("onPlayerJoin", getRootElement(), entrar) --Function para desactivar el bind cuando el resource es detenido function unbin(player) for index, player in ipairs(getElementsByType("player")) do unbindKey(player, "F5", "down", abrir) end end addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), unbind) Y para las resoluciones te recomiendo usar variables relativas y no absolutas. 1 Link to comment
MTA Team 0xCiBeR Posted January 26, 2014 MTA Team Share Posted January 26, 2014 for _, group in ipairs ({"Admin", "Supermoderator"}) do local playerAccount = getPlayerAccount(source) if (not playerAccount) then return end local accountName = getAccountName(playerAccount) if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then Eso privatizaria algo solo para los grupos Admin, y Supermoderator. Link to comment
Arsilex Posted January 26, 2014 Share Posted January 26, 2014 2º revisa esta funcion:: https://wiki.multitheftauto.com/wiki/GuiGetScreenSize Link to comment
DanielZ3RO Posted January 26, 2014 Author Share Posted January 26, 2014 2ºrevisa esta funcion:: https://wiki.multitheftauto.com/wiki/GuiGetScreenSize Muchas gracias AsuS si me sirvio y si tu eres el mismo de youtube, me ayudaste a iniciar muy bien en el scripting , en serio gracias Link to comment
DanielZ3RO Posted January 26, 2014 Author Share Posted January 26, 2014 disculpen, no ahy alguna funcion para mantener centradas las ventanas, por que la funcion guiGetScreenSize, Me Sirvio Para mantener Ciertas Cosas En Su Lugar En Cualquier Resolucion pero si quiero simplemente mantener centrada una ventana en cuanquier resolucion sin que se cambien los tamaños de los gui, es que tengo 2 paneles con varios botones e intente cambiarles a todos pero algunos quedaban mal, seria mucho mejor solo mantener la ventana centrada Link to comment
MTA Team 0xCiBeR Posted January 26, 2014 MTA Team Share Posted January 26, 2014 Por favor, no hagas doble post. Usa el botón de EDIT. Esto Te puede ser de utilidad. Link to comment
DanielZ3RO Posted January 26, 2014 Author Share Posted January 26, 2014 y lo de privatizar es para privatizar este comando solo para staff function boss() Nemesis = exports [ "slothBot" ]:spawnBot ( -21, 2339, 24.149, 90, 312, 0, 0, Nemesis, 38,"hunting", true ) exports.extra_health:setElementExtraHealth ( Nemesis, 2500 ) outputChatBox ("NEMESIS A APARECIDO!!", getRootElement(), 103, 0, 0, true ) myBlip = (createBlipAttachedTo ( Nemesis, 23 )) setElementData ( Nemesis, "nemesis", true ) x,y,z = getElementPosition( thePlayer ) setElementModel(nemesis, 312) end addCommandHandler("nemesis", boss) Link to comment
MTA Team 0xCiBeR Posted January 26, 2014 MTA Team Share Posted January 26, 2014 function boss() local cuenta = getAccountName(getPlayerAccount(source)) if not isGuestAccount(cuenta) and isObjectInACLGroup("user." .. cuenta, aclGetGroup("Admin")) then Nemesis = exports [ "slothBot" ]:spawnBot ( -21, 2339, 24.149, 90, 312, 0, 0, Nemesis, 38,"hunting", true ) exports.extra_health:setElementExtraHealth ( Nemesis, 2500 ) outputChatBox ("NEMESIS A APARECIDO!!", getRootElement(), 103, 0, 0, true ) myBlip = (createBlipAttachedTo ( Nemesis, 23 )) setElementData ( Nemesis, "nemesis", true ) x,y,z = getElementPosition( thePlayer ) setElementModel(nemesis, 312) end end addCommandHandler("nemesis", boss) Link to comment
DanielZ3RO Posted January 26, 2014 Author Share Posted January 26, 2014 Ahh otra pregunta, se puede hacer que digamos con un comando se cambie lo que se muestra en un dxDrawText por decir /anuncio Hola function Anuncios() addEventHandler("onClientRender", getRootElement(), function () local sWidth, sHeight = guiGetScreenSize ( ) dxDrawRectangle(sWidth * 0,sHeight * 0.95,sWidth * 1,sHeight* 0.05, tocolor(0, 0, 0, 150), true) dxDrawText("LOL PRUEBA LOL",sWidth * 1,sHeight * 0.933,sWidth * 0.05,sHeight * 1.01, tocolor(255, 255, 0, 255), 2.20, "default", "center", "center", false, false, true, false, false) end ) end addCommandHandler("anuncio", Anuncios) tambien me gustaria hacer que el anuncio se retire despues de unos segundos se que es un setTimer pero no se como configurarlo en esos Link to comment
DanielZ3RO Posted January 26, 2014 Author Share Posted January 26, 2014 ciber no me sirvio me sale Bad argument @ "getPlayerAccount" Bad argument @ "getAccountName" Bad argument @ "isGuestAccount" Link to comment
MTA Team 0xCiBeR Posted January 26, 2014 MTA Team Share Posted January 26, 2014 Estas seguro que es ese script?.. Y no definiste source en otro lado? ..prueba asi: function boss(yo) local cuenta = getAccountName(getPlayerAccount(yo)) if not isGuestAccount(cuenta) and isObjectInACLGroup("user." .. cuenta, aclGetGroup("Admin")) then Nemesis = exports [ "slothBot" ]:spawnBot ( -21, 2339, 24.149, 90, 312, 0, 0, Nemesis, 38,"hunting", true ) exports.extra_health:setElementExtraHealth ( Nemesis, 2500 ) outputChatBox ("NEMESIS A APARECIDO!!", getRootElement(), 103, 0, 0, true ) myBlip = (createBlipAttachedTo ( Nemesis, 23 )) setElementData ( Nemesis, "nemesis", true ) x,y,z = getElementPosition( thePlayer ) setElementModel(nemesis, 312) end end addCommandHandler("nemesis", boss) En cuanto al dxDrawText usa esto: Server: function mandar(yo,cmd,texto) for _,v in ipairs(getElementsByType("players")) do triggerClientEvent("recibir",v,texto) end end addCommandHandler("anuncio",mandar) Client: addEvent("recibir",true) addEventHandler("recibir",localPlayer, function Anuncios(texto) texto = texto addEventHandler("onClientRender", getRootElement(), function () local sWidth, sHeight = guiGetScreenSize ( ) dxDrawRectangle(sWidth * 0,sHeight * 0.95,sWidth * 1,sHeight* 0.05, tocolor(0, 0, 0, 150), true) dxDrawText(texto,sWidth * 1,sHeight * 0.933,sWidth * 0.05,sHeight * 1.01, tocolor(255, 255, 0, 255), 2.20, "default", "center", "center", false, false, true, false, false) end ) end) Link to comment
Recommended Posts