[YARDIM] Login Panele Müzik Eklemek

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı emreozkantr

  • Yeni Üye
  • *
    • İleti: 7
: 29 Eylül 2018, 12:21:51
Selam login panelime müzik ekledim fakat giriş yap dediğim vakit müzik durmuyor bana yardımcı olabilirmisiniz.

Client.lua dosyası
Kod: lua
-- GET SCREEN SIZE --
local sX,sY = guiGetScreenSize()
-- ABBREVIATIONS --
lW, lH = 300,300
-- LOGIN PANEL --
function loginPanel()
    showChat (false)
showPlayerHudComponent ("all", false)
showCursor (true)
    -- BACKGROUND --
background = guiCreateStaticImage (0,0,sX,sY,"img/background.png",false)
-- LOGIN PANEL --
loginWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Giriş Yap",false,background)
    guiSetVisible (loginWindow,true)
loginHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,loginWindow)
    guiLabelSetVerticalAlign (loginHeaderText,"center")
    guiLabelSetHorizontalAlign (loginHeaderText,"center")
guiSetFont (loginHeaderText,"default-bold-small")
usernameEdit = guiCreateEdit (20,52,260,35,"Kullanıcı Adı",false,loginWindow)
    guiEditSetMaxLength (usernameEdit,21)
passwordEdit = guiCreateEdit (20,102,260,35,"Şifre",false,loginWindow)
    guiEditSetMaxLength (passwordEdit,21)
guiEditSetMasked (passwordEdit,true)
rememberCheckbox =  guiCreateCheckBox (lW-130,152,110,20,"Beni Hatırla",false,false,loginWindow)
    guiSetFont (rememberCheckbox,"default-bold-small")
loginButton = guiCreateButton (20,187,260,40,"",false,loginWindow)
    guiSetAlpha (loginButton,1)
loginLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginButton)
    guiLabelSetVerticalAlign (loginLabel,"center")
    guiLabelSetHorizontalAlign (loginLabel,"center")
guiSetFont (loginLabel,"default-bold-small")
registerButton = guiCreateButton (20,242,260,40,"",false,loginWindow)
registerLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerButton)
    guiLabelSetVerticalAlign (registerLabel,"center")
    guiLabelSetHorizontalAlign (registerLabel,"center")
guiSetFont (registerLabel,"default-bold-small")
-- REGISTER PANEL --
registerWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Kayıt Ol",false,background)
    guiSetVisible (registerWindow,false)
registerHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,registerWindow)
    guiLabelSetVerticalAlign (registerHeaderText,"center")
    guiLabelSetHorizontalAlign (registerHeaderText,"center")
guiSetFont (registerHeaderText,"default-bold-small")
usernameText = guiCreateLabel (20,42,80,35,"Kullanıcı Adı",false,registerWindow)
    guiEditSetReadOnly (usernameText,true)
guiSetFont (usernameText,"default-bold-small")
usernameREdit = guiCreateEdit (105,42,175,35,"",false,registerWindow)
    guiEditSetMaxLength (usernameREdit,21)
passwordText = guiCreateLabel (20,92,80,35,"Şifre",false,registerWindow)
    guiEditSetReadOnly (passwordText,true)
guiSetFont (passwordText,"default-bold-small")
passwordREdit = guiCreateEdit (105,92,175,35,"",false,registerWindow)
    guiEditSetMaxLength (passwordREdit,21)
guiEditSetMasked (passwordREdit,true)
passwordCText = guiCreateLabel (20,142,80,35,"Tekrar Şifre",false,registerWindow)
    guiEditSetReadOnly (passwordCText,true)
guiSetFont (passwordCText,"default-bold-small")
passwordCREdit = guiCreateEdit (105,142,175,35,"",false,registerWindow)
    guiEditSetMaxLength (passwordCREdit,21)
guiEditSetMasked (passwordCREdit,true)
registerRButton = guiCreateButton (20,192,260,40,"",false,registerWindow)
registerRLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerRButton)
    guiLabelSetVerticalAlign (registerRLabel,"center")
    guiLabelSetHorizontalAlign (registerRLabel,"center")
guiSetFont (registerRLabel,"default-bold-small")
loginRButton = guiCreateButton (20,247,260,40,"",false,registerWindow)
loginRLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginRButton)
    guiLabelSetVerticalAlign (loginRLabel,"center")
    guiLabelSetHorizontalAlign (loginRLabel,"center")
guiSetFont (loginRLabel,"default-bold-small")
-- REMEMBER PLAYER ACCOUNT --
xml = xmlLoadFile("userdata.xml")
    loadXML()
end
 addEventHandler ("onClientResourceStart",resourceRoot,loginPanel)
-- HOVER BUTTON --
addEventHandler ("onClientMouseEnter",root,
function()
    if source == loginLabel then
    guiStaticImageLoadImage ( loginButton, "img/hoverButton.png" )
elseif source == registerLabel then
guiStaticImageLoadImage ( registerButton, "img/hoverButton.png" )
elseif source == loginRLabel then
guiStaticImageLoadImage ( loginRButton, "img/hoverButton.png" )
elseif source == registerRLabel then
guiStaticImageLoadImage ( registerRButton, "img/hoverButton.png" )
end
end
)
-- BUTTON --
addEventHandler ("onClientMouseLeave",root,
function()
    if source == loginLabel then
    guiStaticImageLoadImage ( loginButton, "img/button.png" )
elseif source == registerLabel then
guiStaticImageLoadImage ( registerButton, "img/button.png" )
elseif source == loginRLabel then
guiStaticImageLoadImage ( loginRButton, "img/button.png" )
elseif source == registerRLabel then
guiStaticImageLoadImage ( registerRButton, "img/button.png" )
end
end
)
-- REMEMBER PLAYER ACCOUNT --
function loadXML()
  if not xml then
    xml = xmlCreateFile("userdata.xml","userdata")
    usernameChild = xmlCreateChild(xml,"username")
    passwordChild = xmlCreateChild(xml,"password")
    checkboxChild = xmlCreateChild(xml,"state")
    xmlSaveFile(xml)
  else
    usernameChild = xmlFindChild(xml,"username",0)
    passwordChild = xmlFindChild(xml,"password",0)
    checkboxChild = xmlFindChild(xml,"state",0)
  end
    usernameLoad = xmlNodeGetValue(usernameChild)
    passwordLoad = xmlNodeGetValue(passwordChild)
    guiSetText (usernameEdit,usernameLoad)
    guiSetText (passwordEdit,passwordLoad)
if xmlNodeGetValue(checkboxChild) then
    guiCheckBoxSetSelected (rememberCheckbox,true)
end
end
function saveXML(username,password,checkboxState)
  if guiCheckBoxGetSelected (rememberCheckbox) == true then
    xmlNodeSetValue(usernameChild,username)
    xmlNodeSetValue(passwordChild,password)
    xmlNodeSetValue(checkboxChild,tostring(checkboxState))
    xmlSaveFile(xml)
  else
    xmlNodeSetValue(usernameChild,"")
    xmlNodeSetValue(passwordChild,"")
    xmlNodeSetValue(checkboxChild,"")
    xmlSaveFile(xml)
  end
end
addEvent("saveXML",true)
addEventHandler("saveXML",getRootElement(),saveXML)
-- LOGIN PANEL/REGISTER PANEL --
function redirectPanel()
    if (source == registerLabel) then
    if (guiGetVisible (loginWindow) == true ) then
    guiSetVisible (loginWindow,false)
guiSetVisible (registerWindow,true)
end
end
if (source == loginRLabel) then
    if (guiGetVisible (registerWindow) == true ) then
      guiSetVisible (registerWindow,false)
    guiSetVisible (loginWindow,true)
end
end
end
 addEventHandler ("onClientGUIClick",getRootElement(),redirectPanel)
-- REGISTER --
function register()
    if (source == registerRLabel) then
    local username = guiGetText(usernameREdit)
        local password = guiGetText (passwordREdit)
if (guiGetText(usernameREdit) ~= "") and (guiGetText(passwordREdit) ~= "") and (guiGetText(passwordREdit) == guiGetText(passwordCREdit)) then
        triggerServerEvent("registerPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
elseif (guiGetText(usernameREdit) == "") then
    outputNotification ("Geçersiz kullanıcı adı.",3)
elseif (guiGetText(passwordREdit) == "") or (guiGetText(passwordCREdit) == "") or (guiGetText(passwordREdit) ~= guiGetText(passwordCREdit)) then
    outputNotification ("Geçersiz şifre.",3)
end
end
end
 addEventHandler ("onClientGUIClick",getRootElement(),register)
-- WRONG USERNAME OR PASSWORD --
function wrongAccount()
    outputNotification ("Kullanıcı adı veya şifre yanlış..",3)
end
 addEvent ("wrongAccount",true)
 addEventHandler ("wrongAccount",getRootElement(),wrongAccount)
-- SUCCESFULLY LOGGED IN --
function succesAccount()
    outputNotification ("Başarıyla giriş yapıldı.",1)
end
 addEvent ("successfullyLogin",true)
 addEventHandler ("successfullyLogin",getRootElement(),succesAccount)
-- NOT REGISTER --
function notRegister()
    outputNotification ("Hesap bulunamadı, yeni bir hesap oluşturabilirsiniz!",3)
end
 addEvent ("notRegister",true)
 addEventHandler ("notRegister",getRootElement(),notRegister)
-- LOGIN --
function login()
    if (source == loginLabel) then
    local username = guiGetText(usernameEdit)
        local password = guiGetText(passwordEdit)
if guiGetText(usernameEdit) ~= "" and guiGetText(passwordEdit) ~= "" then
    triggerServerEvent("loginPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
elseif guiGetText(usernameEdit) == "" and guiGetText(passwordEdit) == "" then
    outputNotification ("Geçersiz kullanıcı adı ve şifre",3)
    elseif guiGetText(usernameEdit) == "" then
    outputNotification ("Geçersiz kullanıcı adı.",3)
elseif guiGetText(passwordEdit) == "" then
    outputNotification ("Geçersiz şifre.",3)
end
end
end
 addEventHandler ("onClientGUIClick",getRootElement(),login)
-- CLOSE LOGIN PANEL --
function cLoginPanel()
    guiSetVisible (background,false)
showChat (true)
showPlayerHudComponent ("all", true)
showCursor (false)
end
 addEvent ("hideLoginPanel",true)
 addEventHandler ("hideLoginPanel",getRootElement(),cLoginPanel)
 -- CLOSE REGISTER PANEL --
function cRegisterPanel()
    guiSetVisible (background,false)
showChat (true)
showPlayerHudComponent ("all", true)
showCursor (false)
end
 addEvent ("hideRegisterPanel",true)
 addEventHandler ("hideRegisterPanel",getRootElement(),cRegisterPanel)

local sound
addEventHandler("onClientResourceStart", resourceRoot,   
function()       
sound = playSound("ses.mp3", false)       
setSoundVolume(sound, 1.0)   
end)
 
addEvent("muzikdurdur", true)
addEventHandler("muzikdurdur", root,
function()       
if (sound) and (isElement(sound)) then
destroyElement(sound)     
end   
end)
Eklediğim Kod
Kod: lua
local sound 
addEventHandler("onClientResourceStart", resourceRoot,   
function()       
sound = playSound("ses.mp3", false)       
setSoundVolume(sound, 1.0)   
end)
 
addEvent("muzikdurdur", true)
addEventHandler("muzikdurdur", root,
function()       
if (sound) and (isElement(sound)) then
destroyElement(sound)     
end   
end)
« Son Düzenleme: 30 Eylül 2018, 16:59:43 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Login Panele Müzik Eklemek
« : 29 Eylül 2018, 12:21:51 »

Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #1 : 29 Eylül 2018, 12:37:21
Server kısmına giriş yaptığı bölüme muzikdurdur eventini eklemelisin.
 


Çevrimdışı emreozkantr

  • Yeni Üye
  • *
    • İleti: 7
Yanıtla #2 : 29 Eylül 2018, 12:47:20
fazla kod bilgim yok yardımcı olamazmısın ?
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #3 : 29 Eylül 2018, 13:32:17
Client.lua' yı bu şekilde yap olacaktır.

Kod: lua
-- GET SCREEN SIZE --
local sX,sY = guiGetScreenSize()
-- ABBREVIATIONS --
lW, lH = 300,300
-- LOGIN PANEL --
function loginPanel()
    showChat (false)
        showPlayerHudComponent ("all", false)
        showCursor (true)
    -- BACKGROUND --
        background = guiCreateStaticImage (0,0,sX,sY,"img/background.png",false)
        -- LOGIN PANEL --
        loginWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Giriş Yap",false,background)
            guiSetVisible (loginWindow,true)
        loginHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,loginWindow)
            guiLabelSetVerticalAlign (loginHeaderText,"center")
            guiLabelSetHorizontalAlign (loginHeaderText,"center")
                guiSetFont (loginHeaderText,"default-bold-small")
        usernameEdit = guiCreateEdit (20,52,260,35,"Kullanıcı Adı",false,loginWindow)
            guiEditSetMaxLength (usernameEdit,21)
        passwordEdit = guiCreateEdit (20,102,260,35,"Şifre",false,loginWindow)
            guiEditSetMaxLength (passwordEdit,21)
                guiEditSetMasked (passwordEdit,true)
        rememberCheckbox =  guiCreateCheckBox (lW-130,152,110,20,"Beni Hatırla",false,false,loginWindow)
            guiSetFont (rememberCheckbox,"default-bold-small")
        loginButton = guiCreateButton (20,187,260,40,"",false,loginWindow)
            guiSetAlpha (loginButton,1)
        loginLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginButton)
            guiLabelSetVerticalAlign (loginLabel,"center")
            guiLabelSetHorizontalAlign (loginLabel,"center")
                guiSetFont (loginLabel,"default-bold-small")
        registerButton = guiCreateButton (20,242,260,40,"",false,loginWindow)
        registerLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerButton)
            guiLabelSetVerticalAlign (registerLabel,"center")
            guiLabelSetHorizontalAlign (registerLabel,"center")
                guiSetFont (registerLabel,"default-bold-small")
        -- REGISTER PANEL --
        registerWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Kayıt Ol",false,background)
            guiSetVisible (registerWindow,false)
        registerHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,registerWindow)
            guiLabelSetVerticalAlign (registerHeaderText,"center")
            guiLabelSetHorizontalAlign (registerHeaderText,"center")
                guiSetFont (registerHeaderText,"default-bold-small")
        usernameText = guiCreateLabel (20,42,80,35,"Kullanıcı Adı",false,registerWindow)
            guiEditSetReadOnly (usernameText,true)
                guiSetFont (usernameText,"default-bold-small")
        usernameREdit = guiCreateEdit (105,42,175,35,"",false,registerWindow)
            guiEditSetMaxLength (usernameREdit,21)
        passwordText = guiCreateLabel (20,92,80,35,"Şifre",false,registerWindow)
            guiEditSetReadOnly (passwordText,true)
                guiSetFont (passwordText,"default-bold-small")
        passwordREdit = guiCreateEdit (105,92,175,35,"",false,registerWindow)
            guiEditSetMaxLength (passwordREdit,21)
                guiEditSetMasked (passwordREdit,true)
        passwordCText = guiCreateLabel (20,142,80,35,"Tekrar Şifre",false,registerWindow)
            guiEditSetReadOnly (passwordCText,true)
                guiSetFont (passwordCText,"default-bold-small")
        passwordCREdit = guiCreateEdit (105,142,175,35,"",false,registerWindow)
            guiEditSetMaxLength (passwordCREdit,21)
                guiEditSetMasked (passwordCREdit,true)
        registerRButton = guiCreateButton (20,192,260,40,"",false,registerWindow)
        registerRLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerRButton)
            guiLabelSetVerticalAlign (registerRLabel,"center")
            guiLabelSetHorizontalAlign (registerRLabel,"center")
                guiSetFont (registerRLabel,"default-bold-small")
        loginRButton = guiCreateButton (20,247,260,40,"",false,registerWindow)
        loginRLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginRButton)
            guiLabelSetVerticalAlign (loginRLabel,"center")
            guiLabelSetHorizontalAlign (loginRLabel,"center")
                guiSetFont (loginRLabel,"default-bold-small")
        -- REMEMBER PLAYER ACCOUNT --
        xml = xmlLoadFile("userdata.xml")
    loadXML()
end
 addEventHandler ("onClientResourceStart",resourceRoot,loginPanel)
-- HOVER BUTTON --
addEventHandler ("onClientMouseEnter",root,
function()
    if source == loginLabel then
            guiStaticImageLoadImage ( loginButton, "img/hoverButton.png" )
        elseif source == registerLabel then
                guiStaticImageLoadImage ( registerButton, "img/hoverButton.png" )
        elseif source == loginRLabel then
                guiStaticImageLoadImage ( loginRButton, "img/hoverButton.png" )
        elseif source == registerRLabel then
                guiStaticImageLoadImage ( registerRButton, "img/hoverButton.png" )
        end
end
)
-- BUTTON --
addEventHandler ("onClientMouseLeave",root,
function()
    if source == loginLabel then
            guiStaticImageLoadImage ( loginButton, "img/button.png" )
        elseif source == registerLabel then
                guiStaticImageLoadImage ( registerButton, "img/button.png" )
        elseif source == loginRLabel then
                guiStaticImageLoadImage ( loginRButton, "img/button.png" )
        elseif source == registerRLabel then
                guiStaticImageLoadImage ( registerRButton, "img/button.png" )
        end
end
)
-- REMEMBER PLAYER ACCOUNT --
function loadXML()
  if not xml then
    xml = xmlCreateFile("userdata.xml","userdata")
    usernameChild = xmlCreateChild(xml,"username")
    passwordChild = xmlCreateChild(xml,"password")
    checkboxChild = xmlCreateChild(xml,"state")
    xmlSaveFile(xml)
  else
    usernameChild = xmlFindChild(xml,"username",0)
    passwordChild = xmlFindChild(xml,"password",0)
    checkboxChild = xmlFindChild(xml,"state",0)
  end
    usernameLoad = xmlNodeGetValue(usernameChild)
    passwordLoad = xmlNodeGetValue(passwordChild)
    guiSetText (usernameEdit,usernameLoad)
    guiSetText (passwordEdit,passwordLoad)
        if xmlNodeGetValue(checkboxChild) then
            guiCheckBoxSetSelected (rememberCheckbox,true)
        end
end
function saveXML(username,password,checkboxState)
  if guiCheckBoxGetSelected (rememberCheckbox) == true then
    xmlNodeSetValue(usernameChild,username)
    xmlNodeSetValue(passwordChild,password)
    xmlNodeSetValue(checkboxChild,tostring(checkboxState))
    xmlSaveFile(xml)
  else
    xmlNodeSetValue(usernameChild,"")
    xmlNodeSetValue(passwordChild,"")
    xmlNodeSetValue(checkboxChild,"")
    xmlSaveFile(xml)
  end
end
addEvent("saveXML",true)
addEventHandler("saveXML",getRootElement(),saveXML)
-- LOGIN PANEL/REGISTER PANEL --
function redirectPanel()
    if (source == registerLabel) then
            if (guiGetVisible (loginWindow) == true ) then
                    guiSetVisible (loginWindow,false)
                        guiSetVisible (registerWindow,true)
                end
        end
        if (source == loginRLabel) then
            if (guiGetVisible (registerWindow) == true ) then
                guiSetVisible (registerWindow,false)
                    guiSetVisible (loginWindow,true)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),redirectPanel)
-- REGISTER --
function register()
    if (source == registerRLabel) then
            local username = guiGetText(usernameREdit)
        local password = guiGetText (passwordREdit)
                if (guiGetText(usernameREdit) ~= "") and (guiGetText(passwordREdit) ~= "") and (guiGetText(passwordREdit) == guiGetText(passwordCREdit)) then
                triggerServerEvent("registerPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
                elseif (guiGetText(usernameREdit) == "") then
                    outputNotification ("Geçersiz kullanıcı adı.",3)
                elseif (guiGetText(passwordREdit) == "") or (guiGetText(passwordCREdit) == "") or (guiGetText(passwordREdit) ~= guiGetText(passwordCREdit)) then
                    outputNotification ("Geçersiz şifre.",3)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),register)
-- WRONG USERNAME OR PASSWORD --
function wrongAccount()
    outputNotification ("Kullanıcı adı veya şifre yanlış..",3)
end
 addEvent ("wrongAccount",true)
 addEventHandler ("wrongAccount",getRootElement(),wrongAccount)
-- SUCCESFULLY LOGGED IN --
function succesAccount()
    outputNotification ("Başarıyla giriş yapıldı.",1)
end
 addEvent ("successfullyLogin",true)
 addEventHandler ("successfullyLogin",getRootElement(),succesAccount)
-- NOT REGISTER --
function notRegister()
    outputNotification ("Hesap bulunamadı, yeni bir hesap oluşturabilirsiniz!",3)
end
 addEvent ("notRegister",true)
 addEventHandler ("notRegister",getRootElement(),notRegister)
-- LOGIN --
function login()
    if (source == loginLabel) then
            local username = guiGetText(usernameEdit)
        local password = guiGetText(passwordEdit)
                if guiGetText(usernameEdit) ~= "" and guiGetText(passwordEdit) ~= "" then
                    triggerServerEvent("loginPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
                elseif guiGetText(usernameEdit) == "" and guiGetText(passwordEdit) == "" then
                    outputNotification ("Geçersiz kullanıcı adı ve şifre",3)
            elseif guiGetText(usernameEdit) == "" then
                    outputNotification ("Geçersiz kullanıcı adı.",3)
                elseif guiGetText(passwordEdit) == "" then
                    outputNotification ("Geçersiz şifre.",3)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),login)
-- CLOSE LOGIN PANEL --
function cLoginPanel()
    guiSetVisible (background,false)
        showChat (true)
        showPlayerHudComponent ("all", true)
        showCursor (false)
if (sound) and (isElement(sound)) then
destroyElement(sound)     
end
end
 addEvent ("hideLoginPanel",true)
 addEventHandler ("hideLoginPanel",getRootElement(),cLoginPanel)
 -- CLOSE REGISTER PANEL --
function cRegisterPanel()
    guiSetVisible (background,false)
        showChat (true)
        showPlayerHudComponent ("all", true)
        showCursor (false)
end
 addEvent ("hideRegisterPanel",true)
 addEventHandler ("hideRegisterPanel",getRootElement(),cRegisterPanel)
 
local sound
addEventHandler("onClientResourceStart", resourceRoot,   
function()       
sound = playSound("ses.mp3", false)       
setSoundVolume(sound, 1.0)   
end)
 


Çevrimdışı emreozkantr

  • Yeni Üye
  • *
    • İleti: 7
Yanıtla #4 : 29 Eylül 2018, 17:16:53
olmadı :/
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #5 : 29 Eylül 2018, 17:23:08
Bunu dene olmaz ise server.lua'sını da at.

Kod: lua
-- GET SCREEN SIZE --
local sX,sY = guiGetScreenSize()
-- ABBREVIATIONS --
lW, lH = 300,300
-- LOGIN PANEL --
function loginPanel()
    showChat (false)
        showPlayerHudComponent ("all", false)
        showCursor (true)
    -- BACKGROUND --
        background = guiCreateStaticImage (0,0,sX,sY,"img/background.png",false)
        -- LOGIN PANEL --
        loginWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Giriş Yap",false,background)
            guiSetVisible (loginWindow,true)
        loginHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,loginWindow)
            guiLabelSetVerticalAlign (loginHeaderText,"center")
            guiLabelSetHorizontalAlign (loginHeaderText,"center")
                guiSetFont (loginHeaderText,"default-bold-small")
        usernameEdit = guiCreateEdit (20,52,260,35,"Kullanıcı Adı",false,loginWindow)
            guiEditSetMaxLength (usernameEdit,21)
        passwordEdit = guiCreateEdit (20,102,260,35,"Şifre",false,loginWindow)
            guiEditSetMaxLength (passwordEdit,21)
                guiEditSetMasked (passwordEdit,true)
        rememberCheckbox =  guiCreateCheckBox (lW-130,152,110,20,"Beni Hatırla",false,false,loginWindow)
            guiSetFont (rememberCheckbox,"default-bold-small")
        loginButton = guiCreateButton (20,187,260,40,"",false,loginWindow)
            guiSetAlpha (loginButton,1)
        loginLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginButton)
            guiLabelSetVerticalAlign (loginLabel,"center")
            guiLabelSetHorizontalAlign (loginLabel,"center")
                guiSetFont (loginLabel,"default-bold-small")
        registerButton = guiCreateButton (20,242,260,40,"",false,loginWindow)
        registerLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerButton)
            guiLabelSetVerticalAlign (registerLabel,"center")
            guiLabelSetHorizontalAlign (registerLabel,"center")
                guiSetFont (registerLabel,"default-bold-small")
        -- REGISTER PANEL --
        registerWindow = guiCreateWindow (sX/2-lW/2,sY/2-lH/2,lW,lH,"Kahraman Freeroam | Kayıt Ol",false,background)
            guiSetVisible (registerWindow,false)
        registerHeaderText = guiCreateLabel (0.1,0.1,300,30,"",false,registerWindow)
            guiLabelSetVerticalAlign (registerHeaderText,"center")
            guiLabelSetHorizontalAlign (registerHeaderText,"center")
                guiSetFont (registerHeaderText,"default-bold-small")
        usernameText = guiCreateLabel (20,42,80,35,"Kullanıcı Adı",false,registerWindow)
            guiEditSetReadOnly (usernameText,true)
                guiSetFont (usernameText,"default-bold-small")
        usernameREdit = guiCreateEdit (105,42,175,35,"",false,registerWindow)
            guiEditSetMaxLength (usernameREdit,21)
        passwordText = guiCreateLabel (20,92,80,35,"Şifre",false,registerWindow)
            guiEditSetReadOnly (passwordText,true)
                guiSetFont (passwordText,"default-bold-small")
        passwordREdit = guiCreateEdit (105,92,175,35,"",false,registerWindow)
            guiEditSetMaxLength (passwordREdit,21)
                guiEditSetMasked (passwordREdit,true)
        passwordCText = guiCreateLabel (20,142,80,35,"Tekrar Şifre",false,registerWindow)
            guiEditSetReadOnly (passwordCText,true)
                guiSetFont (passwordCText,"default-bold-small")
        passwordCREdit = guiCreateEdit (105,142,175,35,"",false,registerWindow)
            guiEditSetMaxLength (passwordCREdit,21)
                guiEditSetMasked (passwordCREdit,true)
        registerRButton = guiCreateButton (20,192,260,40,"",false,registerWindow)
        registerRLabel = guiCreateLabel (0,0,260,40,"Kayıt Ol",false,registerRButton)
            guiLabelSetVerticalAlign (registerRLabel,"center")
            guiLabelSetHorizontalAlign (registerRLabel,"center")
                guiSetFont (registerRLabel,"default-bold-small")
        loginRButton = guiCreateButton (20,247,260,40,"",false,registerWindow)
        loginRLabel = guiCreateLabel (0,0,260,40,"Giriş Yap",false,loginRButton)
            guiLabelSetVerticalAlign (loginRLabel,"center")
            guiLabelSetHorizontalAlign (loginRLabel,"center")
                guiSetFont (loginRLabel,"default-bold-small")
        -- REMEMBER PLAYER ACCOUNT --
        xml = xmlLoadFile("userdata.xml")
    loadXML()
end
 addEventHandler ("onClientResourceStart",resourceRoot,loginPanel)
-- HOVER BUTTON --
addEventHandler ("onClientMouseEnter",root,
function()
    if source == loginLabel then
            guiStaticImageLoadImage ( loginButton, "img/hoverButton.png" )
        elseif source == registerLabel then
                guiStaticImageLoadImage ( registerButton, "img/hoverButton.png" )
        elseif source == loginRLabel then
                guiStaticImageLoadImage ( loginRButton, "img/hoverButton.png" )
        elseif source == registerRLabel then
                guiStaticImageLoadImage ( registerRButton, "img/hoverButton.png" )
        end
end
)
-- BUTTON --
addEventHandler ("onClientMouseLeave",root,
function()
    if source == loginLabel then
            guiStaticImageLoadImage ( loginButton, "img/button.png" )
        elseif source == registerLabel then
                guiStaticImageLoadImage ( registerButton, "img/button.png" )
        elseif source == loginRLabel then
                guiStaticImageLoadImage ( loginRButton, "img/button.png" )
        elseif source == registerRLabel then
                guiStaticImageLoadImage ( registerRButton, "img/button.png" )
        end
end
)
-- REMEMBER PLAYER ACCOUNT --
function loadXML()
  if not xml then
    xml = xmlCreateFile("userdata.xml","userdata")
    usernameChild = xmlCreateChild(xml,"username")
    passwordChild = xmlCreateChild(xml,"password")
    checkboxChild = xmlCreateChild(xml,"state")
    xmlSaveFile(xml)
  else
    usernameChild = xmlFindChild(xml,"username",0)
    passwordChild = xmlFindChild(xml,"password",0)
    checkboxChild = xmlFindChild(xml,"state",0)
  end
    usernameLoad = xmlNodeGetValue(usernameChild)
    passwordLoad = xmlNodeGetValue(passwordChild)
    guiSetText (usernameEdit,usernameLoad)
    guiSetText (passwordEdit,passwordLoad)
        if xmlNodeGetValue(checkboxChild) then
            guiCheckBoxSetSelected (rememberCheckbox,true)
        end
end
function saveXML(username,password,checkboxState)
  if guiCheckBoxGetSelected (rememberCheckbox) == true then
    xmlNodeSetValue(usernameChild,username)
    xmlNodeSetValue(passwordChild,password)
    xmlNodeSetValue(checkboxChild,tostring(checkboxState))
    xmlSaveFile(xml)
  else
    xmlNodeSetValue(usernameChild,"")
    xmlNodeSetValue(passwordChild,"")
    xmlNodeSetValue(checkboxChild,"")
    xmlSaveFile(xml)
  end
end
addEvent("saveXML",true)
addEventHandler("saveXML",getRootElement(),saveXML)
-- LOGIN PANEL/REGISTER PANEL --
function redirectPanel()
    if (source == registerLabel) then
            if (guiGetVisible (loginWindow) == true ) then
                    guiSetVisible (loginWindow,false)
                        guiSetVisible (registerWindow,true)
                end
        end
        if (source == loginRLabel) then
            if (guiGetVisible (registerWindow) == true ) then
                guiSetVisible (registerWindow,false)
                    guiSetVisible (loginWindow,true)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),redirectPanel)
-- REGISTER --
function register()
    if (source == registerRLabel) then
            local username = guiGetText(usernameREdit)
        local password = guiGetText (passwordREdit)
                if (guiGetText(usernameREdit) ~= "") and (guiGetText(passwordREdit) ~= "") and (guiGetText(passwordREdit) == guiGetText(passwordCREdit)) then
                triggerServerEvent("registerPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
                elseif (guiGetText(usernameREdit) == "") then
                    outputNotification ("Geçersiz kullanıcı adı.",3)
                elseif (guiGetText(passwordREdit) == "") or (guiGetText(passwordCREdit) == "") or (guiGetText(passwordREdit) ~= guiGetText(passwordCREdit)) then
                    outputNotification ("Geçersiz şifre.",3)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),register)
-- WRONG USERNAME OR PASSWORD --
function wrongAccount()
    outputNotification ("Kullanıcı adı veya şifre yanlış..",3)
end
 addEvent ("wrongAccount",true)
 addEventHandler ("wrongAccount",getRootElement(),wrongAccount)
-- SUCCESFULLY LOGGED IN --
function succesAccount()
    outputNotification ("Başarıyla giriş yapıldı.",1)
    stopSound(sound)     
end
 addEvent ("successfullyLogin",true)
 addEventHandler ("successfullyLogin",getRootElement(),succesAccount)
-- NOT REGISTER --
function notRegister()
    outputNotification ("Hesap bulunamadı, yeni bir hesap oluşturabilirsiniz!",3)
end
 addEvent ("notRegister",true)
 addEventHandler ("notRegister",getRootElement(),notRegister)
-- LOGIN --
function login()
    if (source == loginLabel) then
            local username = guiGetText(usernameEdit)
        local password = guiGetText(passwordEdit)
                if guiGetText(usernameEdit) ~= "" and guiGetText(passwordEdit) ~= "" then
                    triggerServerEvent("loginPlayer",getLocalPlayer(),getLocalPlayer(),username,password)
                elseif guiGetText(usernameEdit) == "" and guiGetText(passwordEdit) == "" then
                    outputNotification ("Geçersiz kullanıcı adı ve şifre",3)
            elseif guiGetText(usernameEdit) == "" then
                    outputNotification ("Geçersiz kullanıcı adı.",3)
                elseif guiGetText(passwordEdit) == "" then
                    outputNotification ("Geçersiz şifre.",3)
                end
        end
end
 addEventHandler ("onClientGUIClick",getRootElement(),login)
-- CLOSE LOGIN PANEL --
function cLoginPanel()
    guiSetVisible (background,false)
        showChat (true)
        showPlayerHudComponent ("all", true)
        showCursor (false)       
end
 addEvent ("hideLoginPanel",true)
 addEventHandler ("hideLoginPanel",getRootElement(),cLoginPanel)
 -- CLOSE REGISTER PANEL --
function cRegisterPanel()
    guiSetVisible (background,false)
        showChat (true)
        showPlayerHudComponent ("all", true)
        showCursor (false)
end
 addEvent ("hideRegisterPanel",true)
 addEventHandler ("hideRegisterPanel",getRootElement(),cRegisterPanel)
 
local sound
addEventHandler("onClientResourceStart", resourceRoot,   
function()       
sound = playSound("ses.mp3", false)       
setSoundVolume(sound, 1.0)   
end)
« Son Düzenleme: 29 Eylül 2018, 21:12:17 Gönderen: Paradox »
 


MTASATURK

Ynt: [YARDIM]Login Panele Müzik Eklemek
« Yanıtla #5 : 29 Eylül 2018, 17:23:08 »

Çevrimdışı emreozkantr

  • Yeni Üye
  • *
    • İleti: 7
Yanıtla #6 : 29 Eylül 2018, 20:53:17
Yine olmadı Linki görebilmek için Kayıt olun yada Giriş yapın.
Kod: lua
-- ADD EVENT --
addEvent ("registerPlayer",true)
addEvent ("loginPlayer",true)
-- REGISTER --
function onRegister(player,username,password)
    account = addAccount(username,password)
if (account) then
    outputChatBox ("#FFA800[FFS] #C1C1C1You have successfully registered! Username: #FFA800"..username.." #C1C1C1Password: #FFA800"..password.."#C1C1C1.",player,255,255,255,true)
local account = getAccount(username,password)
if (account) then
    logIn (player,account,password)
triggerClientEvent(player,"successfullyLogin",player)
else
    triggerClientEvent(player,"notRegister",player)
end
triggerClientEvent(player,"hideRegisterPanel",player)
end
end
 addEventHandler ("registerPlayer",root,onRegister)
-- LOGIN --
function onLogin(player,username,password,checkboxState)
    local account = getAccount(username,password)
if (account) then
    logIn (player,account,password)
triggerClientEvent(player,"successfullyLogin",player)
triggerClientEvent(player,"hideLoginPanel",player)
triggerClientEvent(player,"saveXML",getRootElement(),username,password,tostring(checkboxState))
else
    triggerClientEvent(player,"wrongAccount",player)
end
end
 addEventHandler ("loginPlayer",root,onLogin)
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #7 : 29 Eylül 2018, 21:01:24
Bundan önceki iletimi güncelledim ordaki client.lua 'yı dene, muhtemelen çalışacaktır küçük bir hata yapmışım.  :)
 


Çevrimdışı emreozkantr

  • Yeni Üye
  • *
    • İleti: 7
Yanıtla #8 : 30 Eylül 2018, 10:38:00
denedim de olmadı artık boşvermek lazım