MTASA TÜRK
Türkiye'nin En Güncel MTA Platformu


[YARDIM] Login Panel

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı #Unknown

  • R O Y A L - G A M İ N G
  • Yeni Üye
  • *
    • İleti: 6
  • R O Y A L
: 30 Mayıs 2018, 20:54:27
Arkadaşlar login panel yaptım fakat bu login panelde swye attığımda mesela m de tag panel varsa o açılıyo zor giriş yapıyorum onları nasıl kapatabilirim.

Client taraflı kod burada:
Spoiler for Hiden:
Kod: lua
guiSetInputMode("no_binds_when_editing")
local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1366), (screenH/768)

checkBox1 = guiCreateCheckBox(x*600, y*437, x*15, y*15, "", false, false)
checkBox2 = guiCreateCheckBox(x*600, y*469, x*15, y*15, "", false, false)

guiSetVisible(checkBox1, false)
guiSetVisible(checkBox2, false)

guiSetAlpha(checkBox1, 0)
guiSetAlpha(checkBox2, 0)

userAlpha = 150
passAlpha = 150

cor = {}

local font_Text = dxCreateFont("files/font/font_Text.ttf", 20)
local font_Text2 = dxCreateFont("files/font/font_Text.ttf", 15)

local fontScale = false

editBox = {}
editBox.__index = editBox
editBox.instances = {}

function onClientResourceStart()
local font_EditBox = dxCreateFont("files/font/font_EditBox.ttf", 20)

user = editBox.new()
user:setPosition(x*457, y*200, x*450, y*50)
user.color = {0, 0, 0, 0}
user.font = font_EditBox
user.text = ""
user.visible = true
user.onInput = function()
userAlpha = 255
end
user.onOutput = function()
userAlpha = 150
end

pass = editBox.new()
pass:setPosition(x*457, y*260, x*450, y*50)
pass.color = {0, 0, 0, 0}
pass.font = font_EditBox
pass.masked = true
pass.visible = true
pass.onInput = function()
passAlpha = 255
end
pass.onOutput = function()
passAlpha = 150
end

setTimer(function()
showChat(false)
end, 2500, 1)
showCursor(true)
guiSetVisible(checkBox1, true)
guiSetVisible(checkBox2, true)
        guiSetInputEnabled(guiGetVisible(checkBox1))
        guiSetInputEnabled(guiGetVisible(checkBox2))
addEventHandler("onClientRender", getRootElement(), dxLogin)
addEventHandler("onClientRender", getRootElement(), renderMensagesLogin)

if not fontScale then fontScale = screenH/100 end

local username, password = loadLoginFromXML()

if not(username == "" or password == "") then
guiCheckBoxSetSelected(checkBox1, true)
user.text = tostring(username)
pass.text = tostring(password)
else
guiCheckBoxSetSelected(checkBox1, false)
user.text = tostring(username)
pass.text = tostring(password)
end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onClientResourceStart)

function dxLogin()

cor[1] = tocolor(238, 0, 0, 0)
cor[2] = tocolor(238, 0, 0, 0)

if cursorPosition(x*455, y*359, x*217, y*50) then cor[1] = tocolor(238, 0, 0) end
if cursorPosition(x*693, y*359, x*217, y*50) then cor[2] = tocolor(238, 0, 0) end

dxDrawImage(x*0, y*0, x*1366, y*768, "files/img/arkaplan.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawImage(x*0, y*0, x*1366, y*768, "files/img/editUser.png", 0, 0, 0, tocolor(0, 0, 0, userAlpha), false)
dxDrawImage(x*0, y*0, x*1366, y*768, "files/img/editPass.png", 0, 0, 0, tocolor(0, 0, 0, passAlpha), false)
dxDrawImage(x*0, y*0, x*1366, y*768, "files/img/girisbutton.png", 0, 0, 0, cor[1], false)
dxDrawImage(x*0, y*0, x*1366, y*768, "files/img/kayitbutton.png", 0, 0, 0, cor[2], false)
dxDrawText("Giris", x*457, y*359, x*670, y*407, tocolor(255, 255, 255, 255), x*1.00, font_Text, "center", "center", false, false, false, false, false)
dxDrawText("Kayit Ol", x*695, y*359, x*908, y*407, tocolor(255, 255, 255, 255), x*1.00, font_Text, "center", "center", false, false, false, false, false)
dxDrawText("Beni Hatırla", x*620, y*432, x*765, y*457, tocolor(255, 255, 255, 255), x*1.00, font_Text2, "left", "center", false, false, false, false, false)
dxDrawText("Sifreyi göster", x*620, y*464, x*765, y*489, tocolor(255, 255, 255, 255), x*1.00, font_Text2, "left", "center", false, false, false, false, false)
dxDrawText("#Unknown - #Ramazan ^ © 2009 - 2018 © ROYAL FREEROAM", x*520, y*632, x*855, y*662, tocolor(255, 255, 255, 255), x*1.00, font_Text2, "center", "center", false, false, false, false, false)

dxDrawEmptyRec(x*600, y*437, x*15, y*15, tocolor(255, 255, 255, 255), 1)
dxDrawEmptyRec(x*600, y*469, x*15, y*15, tocolor(255, 255, 255, 255), 1)


if guiCheckBoxGetSelected(checkBox1) == true then
dxDrawText("X", x*597, y*435, x*620, y*454, tocolor(255, 255, 255, 255), x*1.00, font_Text2, "center", "center", false, false, false, false, false)
else
end

if guiCheckBoxGetSelected(checkBox2) == true then
pass.masked = false
dxDrawText("X", x*597, y*467, x*620, y*486, tocolor(255, 255, 255, 255), x*1.00, font_Text2, "center", "center", false, false, false, false, false)
else
pass.masked = true
end

for k, self in pairs(editBox.instances) do
if self.visible then
local px, py, pw, ph = self:getPosition()
local text = self.masked and string.gsub(self.text, ".", "•") or self.text
local alignX = dxGetTextWidth(text, self.scale, self.font) <= pw and "left" or "right"
dxDrawRectangle(px, py, pw, ph, tocolor(unpack(self.color)))
dxDrawText(text, px + x*5, py, px - x*5 + pw, py + ph, tocolor(unpack(self.textColor)), self.scale, self.font, alignX, "center", true)
if self.input and dxGetTextWidth(text, self.scale, self.font) <= pw then
local lx = dxGetTextWidth(text, self.scale, self.font) + px + x*8
local lx = dxGetTextWidth(text, self.scale, self.font) + px + x*8
dxDrawLine(lx, py + y*10, lx, py + ph - y*10, tocolor(255, 255, 255, math.abs(math.sin(getTickCount() / 300))*200), 1)
end
end
end

if getKeyState("backspace") then
for k, self in pairs(editBox.instances) do
if self.visible and self.input then
if not keyState then
keyState = getTickCount() + 400
self.text = string.sub(self.text, 1, string.len(self.text) - 1)
elseif keyState and keyState < getTickCount() then
keyState = getTickCount() + 100
self.text = string.sub(self.text, 1, string.len(self.text) - 1)
end
return
end
end
keyState = nil
end
end

function loginClick(botao, state)
if botao == "left" and state == "down" then
for k, self in pairs(editBox.instances) do
if self.visible then
if self.input then
self.input = nil
self.onOutput()
end
local x, y, w, h = self:getPosition()
if cursorPosition(x, y, w, h) then
self.input = true
self.onInput()
end
end
end
elseif cursorPosition(x*455, y*359, x*217, y*50) then
if guiCheckBoxGetSelected(checkBox1) == true then
checksave = true
else
checksave = false
end
triggerServerEvent("login", getLocalPlayer(), user.text, pass.text, checksave)
elseif cursorPosition(x*693, y*359, x*217, y*50) then
triggerServerEvent("registrar", getLocalPlayer(), user.text, pass.text)
end
end
addEventHandler("onClientClick", getRootElement(), loginClick)

function cursorPosition(x, y, width, height)
if (not isCursorShowing()) then
return false
end
local sx, sy = guiGetScreenSize()
local cx, cy = getCursorPosition()
local cx, cy = (cx*sx), (cy*sy)
if (cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then
return true
else
return false
end
end

function onClientCharacter(character)
if not isCursorShowing() then
return
end
for k, self in pairs(editBox.instances) do
if self.visible and self.input then
if (string.len(self.text)) < self.maxLength then
self.text = self.text..character
end
end
end
end
addEventHandler("onClientCharacter", getRootElement(), onClientCharacter)

function editBox.new()
local self = setmetatable({}, editBox)
self.text = ""
self.maxLength = 30
self.scale = y*0.8
self.state = "normal"
self.font = "sans"
self.color = {255, 255, 255, 255}
self.textColor = {255, 255, 255, 255}
table.insert(editBox.instances, self)
return self
end

function editBox:getPosition()
return self.x, self.y, self.w, self.h
end

function editBox:setPosition(x, y, w,h)
self.x, self.y, self.w, self.h = x, y, w, h
return true
end

function dxDrawEmptyRec(absX, absY, sizeX, sizeY, color, ancho)
dxDrawRectangle(absX, absY, sizeX, ancho, color)
dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color)
dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color)
dxDrawRectangle(absX + sizeX-ancho, absY + ancho, ancho, sizeY - ancho*2, color)
end

function loadLoginFromXML()
local xml_save_log_File = xmlLoadFile("files/xml/userdata.xml")
if not xml_save_log_File then
xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login")
end
local usernameNode = xmlFindChild(xml_save_log_File, "username", 0)
local passwordNode = xmlFindChild(xml_save_log_File, "password", 0)
if usernameNode and passwordNode then
return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode)
else
return "", ""
end
xmlUnloadFile(xml_save_log_File)
end

function saveLoginToXML(username, password)
local xml_save_log_File = xmlLoadFile("files/xml/userdata.xml")
if not xml_save_log_File then
xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login")
end
if (username ~= "") then
local usernameNode = xmlFindChild(xml_save_log_File, "username", 0)
if not usernameNode then
usernameNode = xmlCreateChild(xml_save_log_File, "username")
end
xmlNodeSetValue(usernameNode, tostring(username))
end
if (password ~= "") then
local passwordNode = xmlFindChild(xml_save_log_File, "password", 0)
if not passwordNode then
passwordNode = xmlCreateChild(xml_save_log_File, "password")
end
xmlNodeSetValue(passwordNode, tostring(password))
end
xmlSaveFile(xml_save_log_File)
xmlUnloadFile(xml_save_log_File)
end
addEvent("saveLoginToXML", true)
addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML)

function resetSaveXML()
local xml_save_log_File = xmlLoadFile("files/xml/userdata.xml")
if not xml_save_log_File then
xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login")
end
if (username ~= "") then
local usernameNode = xmlFindChild(xml_save_log_File, "username", 0)
if not usernameNode then
usernameNode = xmlCreateChild(xml_save_log_File, "username")
end
xmlNodeSetValue(usernameNode, "")
end
if (password ~= "") then
local passwordNode = xmlFindChild(xml_save_log_File, "password", 0)
if not passwordNode then
passwordNode = xmlCreateChild(xml_save_log_File, "password")
end
xmlNodeSetValue(passwordNode, "")
end
xmlSaveFile(xml_save_log_File)
xmlUnloadFile(xml_save_log_File)
end
addEvent("resetSaveXML", true)
addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)

function removeLogin()
user.visible = false
pass.visible = false

guiSetVisible(checkBox1, false)
guiSetVisible(checkBox2, false)

removeEventHandler("onClientRender", getRootElement(), dxLogin)
removeEventHandler("onClientRender", getRootElement(), renderMensagesLogin)
removeEventHandler("onClientClick", getRootElement(), loginClick)
removeEventHandler("onClientCharacter", getRootElement(), onClientCharacter)

showCursor(false)
showChat(true)
end
addEvent("removeLogin", true)
addEventHandler("removeLogin", getRootElement(), removeLogin)

local fontMsg = dxCreateFont("files/font/font_Text.ttf", 20, true) or "default-bold"

mensages = {}
messagetick = 0

function servermessagesLogin(message, type)
table.insert(mensages, {message, type or "confirm", getTickCount(), dxGetTextWidth(message, fontScale*0.08, fontMsg) + screenW*0.01, 0, 0, 0})
messagetick = getTickCount()
end
addEvent("servermessagesLogin", true)
addEventHandler("servermessagesLogin", getRootElement(), servermessagesLogin)

function renderMensagesLogin()
local msgd = mensages
if #msgd ~= 0 then
local startY = screenH*0.5
local i = 1
repeat
mData = msgd[i]
local drawThis = true
if i~= 1 then
startY = startY + screenH*0.0425
end
if mData[5] == 0 and mData[6] == 0 then
mData[5] = - mData[4] - screenW*0.015
mData[6] = startY
mData[7] = startY
end
local tick = getTickCount() - mData[3]
local posX, posY, alpha
if tick < 1000 then
local progress = math.min(tick/1000,1)
mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear")
elseif tick >= 1000 and tick <= 7000 then
mData[5] = 0
elseif tick > 7000 then
local progress = math.min((tick - 7000)/1000,1)
mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenW*0.015, 0, 0, progress, "Linear")
if progress >= 1 then
table.remove(msgd, i)
drawThis = false
messagetick = getTickCount()
end
end
local globalTick = getTickCount() - messagetick
if drawThis then
mData[7] = startY
mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear")
posX = mData[5]
posY = mData[6]
alpha = 255
dxDrawRectangle(posX, posY, mData[4], screenH*0.04, tocolor(0, 0, 0, 100), true)
local r, g, b = 0, 255, 0
if mData[2] == "warning" then
r, g, b = 255, 0, 0
end
dxDrawRectangle(posX + mData[4], posY, screenW*0.006, screenH*0.04, tocolor(r, g, b, alpha), true)
dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenH*0.04, tocolor(255, 255, 255, alpha), fontScale*0.07, fontMsg, "center", "center", false, false, true, false, false)
end
i = i + 1
until i > #msgd
mensages = msgd
end
end

function apagarScript()
if fileExists("client.lua") then
fileDelete("client.lua")
end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), apagarScript)
addEventHandler("onClientPlayerQuit", getRootElement(), apagarScript)
addEventHandler("onClientPlayerJoin", getRootElement(), apagarScript)
« Son Düzenleme: 09 Haziran 2018, 00:40:07 Gönderen: LJ »
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


MTASA TÜRK

[YARDIM] Login Panel
« : 30 Mayıs 2018, 20:54:27 »

Çevrimdışı #ScottCoder

  • Acemi Üye
  • *
    • İleti: 111
  • 👑 AXE FREEROAM 👑
Yanıtla #1 : 30 Mayıs 2018, 21:18:59
client.lua atarsan yardımcı olurum.
 


Çevrimdışı #Unknown

  • R O Y A L - G A M İ N G
  • Yeni Üye
  • *
    • İleti: 6
  • R O Y A L
Yanıtla #2 : 30 Mayıs 2018, 21:20:51
Linki görebilmek için Kayıt olun yada Giriş yapın.
client.lua atarsan yardımcı olurum.

 özel ileti olarak atayım
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı #Serius

  • Uzman Üye
  • *
    • İleti: 660
Yanıtla #3 : 09 Haziran 2018, 00:09:54
Buyur; scriptn en başına ekle

Kod: lua
guiSetInputMode("no_binds_when_editing")
 


Çevrimdışı #Unknown

  • R O Y A L - G A M İ N G
  • Yeni Üye
  • *
    • İleti: 6
  • R O Y A L
Yanıtla #4 : 09 Haziran 2018, 00:16:12
Linki görebilmek için Kayıt olun yada Giriş yapın.
Buyur; scriptn en başına ekle

Kod: lua
guiSetInputMode("no_binds_when_editing")

Bunu ekledim şuanda açılmıyor fakat birşey diyeceğim şimdide login butonuna bastığımda mouse ekranda kalıyor.
« Son Düzenleme: 11 Haziran 2018, 15:14:37 Gönderen: Narkoz »
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı #Serius

  • Uzman Üye
  • *
    • İleti: 660
Yanıtla #5 : 09 Haziran 2018, 00:20:18
Buyur; gerekli kod zaten.

Kod: lua
showCursor(false), yada true

Kod: lua
addEventHandler ("onClientGUIClick",root,function()
                if source == giris_butonu then
                guiSetVisible(panel_adi,false) --> Paneli Kapattık
                showCursor(false) -- > Mause Kapattık
          end
end)
 


MTASA TÜRK

Ynt: [YARDIM] Login Panel
« Yanıtla #5 : 09 Haziran 2018, 00:20:18 »

Çevrimdışı #Unknown

  • R O Y A L - G A M İ N G
  • Yeni Üye
  • *
    • İleti: 6
  • R O Y A L
Yanıtla #6 : 09 Haziran 2018, 00:23:22
Linki görebilmek için Kayıt olun yada Giriş yapın.
Buyur; gerekli kod zaten.

Kod: lua
showCursor(false), yada true

Kod: lua
addEventHandler ("onClientGUIClick",root,function()
                if source == giris_butonu then
                guiSetVisible(panel_adi,false) --> Paneli Kapattık
                showCursor(false) -- > Mause Kapattık
          end
end)

Bu kodu üstte attığım kodların içine ekleyip atabilirmisin ben ekledim login panel hiç açılmadıda.
« Son Düzenleme: 11 Haziran 2018, 15:14:47 Gönderen: Narkoz »
Linki görebilmek için Kayıt olun yada Giriş yapın.