aka Blue Posted July 21, 2015 Posted July 21, 2015 Bueno, estuve mirando mis posts viejos (para limitar la creación de personajes) y me ayudó bastante el código que me dieron pero no fue lo que necesitaba. Vengo a preguntar si alguien me podría ayudar en hacer una función la cual sería ocultar la gui de "crear personaje" en paradise cuando tenga un número de 2 personajes ya creados. Supongo que utilizaría la ventana create_character.lua que da paradise así que la dejo aquí abajo. --[[ Copyright (c) 2010 MTA: Paradise This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ]] local selectedSkin = false local messageTimer local messageCount = 0 local timer local function setMessage( text ) windows.create_character[#windows.create_character].text = text if messageTimer then killTimer( messageTimer ) end messageCount = 0 setTimer( function() messageCount = messageCount + 1 if messageCount == 50 then windows.create_character[#windows.create_character].text = "" messageTimer = nil else windows.create_character[#windows.create_character].color = { 255, 255, 255, 5 * ( 50 - messageCount ) } end end, 100, 50 ) end local function tryCreate( key ) local name = destroy["g:createcharacter:name"] and guiGetText( destroy["g:createcharacter:name"] ) local error = verifyCharacterName( name ) or verifySkin( selectedSkin ) if not error then triggerServerEvent( "gui:createCharacter", getLocalPlayer( ), name, selectedSkin ) else setMessage( error ) end end local function cancelCreate( ) if exports.players:isLoggedIn( ) then hide( ) else show( 'characters', true, true, true ) end end windows.create_character = { onCreate = function( ) selectedSkin = false windows.create_character[4].text = "Sube/baja con la rueda para ver más skins." end, { type = "label", text = "Nuevo personaje", font = "bankgothic", alignX = "center", }, { type = "edit", text = "Nombre:", id = "g:createcharacter:name", onAccepted = tryCreate, }, { type = "vpane", lines = 5, panes = { } }, { type = "label", text = "Sube/baja con la rueda para ver más skins.", alignX = "center", }, { type = "button", text = "Crear", onClick = tryCreate, }, { type = "button", text = "Cancelar", onClick = cancelCreate, }, { type = "label", text = "", alignX = "center", } } timer = setTimer( function( ) local skins = exports.players:getSkins( ) if not skins then return end killTimer( timer ) for k, skin in ipairs( skins ) do table.insert( windows.create_character[3].panes, { image = ":players/images/skins/" .. skin .. ".png", onHover = function( cursor, pos ) dxDrawRectangle( pos[1], pos[2], pos[3] - pos[1], pos[4] - pos[2], tocolor( unpack( { 255, 255, 0, 63 } ) ) ) end, onClick = function( ) selectedSkin = skin windows.create_character[4].text = "Skin seleccionado #" .. skin .. "." end, onRender = function( pos ) if selectedSkin == skin then dxDrawRectangle( pos[1], pos[2], pos[3] - pos[1], pos[4] - pos[2], tocolor( unpack( { 0, 255, 0, 63 } ) ) ) end end } ) end end, 500, 0 ) addEvent( "players:characterCreationResult", true ) addEventHandler( "players:characterCreationResult", getLocalPlayer( ), function( code ) if code == 0 then if exports.players:isLoggedIn( ) then show( 'characters', false, false, true ) else show( 'characters', true, true, true ) end elseif code == 1 then setMessage( "Otro jugador con ese nombre existe." ) end end ) Sería hacer algo como cancelar la función onCreate, pero no sé que ¿variable? usar para ello.
Kilfwan Posted July 21, 2015 Posted July 21, 2015 Borra la Gui y saca la IP de XYZ NaciónZ Developing server to the 65 %
Kilfwan Posted July 22, 2015 Posted July 22, 2015 ... Lo siento, Mis comentarios Sin sentido A veces traen ayuda a post que no han tomado en cuenta NaciónZ Developing server to the 65 %
Sticmy Posted July 22, 2015 Posted July 22, 2015 mm en mi opinión utilizaría esta funciones destroyElement guiSetVisible -- (Sí son windows) removeEventHandler("onClientRender", getRootElement(), drawText) -- (Sí es sobre dxDrawText) My name in the game is: Sticmy My discord: Sticmy#3817 My discord community: https://discord.gg/366Y9bB
Sticmy Posted July 22, 2015 Posted July 22, 2015 Comienza a leer tú código para ver si encuentras un código de desaparecer el GUI. PD: Siempre cuando pongas un recurso, debes leer el código en caso que haya un error o olvides otra función que poner. My name in the game is: Sticmy My discord: Sticmy#3817 My discord community: https://discord.gg/366Y9bB
aka Blue Posted July 22, 2015 Author Posted July 22, 2015 Mira, a mí hace tiempo me dieron un código. addCommandHandler("mychars", function(player) local chars = exports.sql:query_assoc("SELECT COUNT(*) AS count FROM characters WHERE userID = ".. exports.players:getUserID(player)) if chars then for key, value in ipairs(chars) do if (value.count < 3) then outputChatBox("Tienes " .. value.count .. " personajes.", player) else outputChatBox("Ya has creado todos los personajes permitidos.", player) triggerClientEvent( player, "players:characterCreationResult", player, 1 ) end end end end Lo que yo quiero hacer es que, con ésta función. local chars = exports.sql:query_assoc("SELECT COUNT(*) AS count FROM characters WHERE userID = ".. exports.players:getUserID(player)) if chars then for key, value in ipairs(chars) do if (value.count < 3) then outputChatBox("Tienes " .. value.count .. " personajes.", player) else outputChatBox("Ya has creado todos los personajes permitidos.", player) triggerClientEvent( player, "players:characterCreationResult", player, 1 ) end Sustituir el TriggerEvent del último por la eliminación de la GUI para crear el personaje.
Recommended Posts