Jump to content

Some Help Please


Evil-Cod3r

Recommended Posts

Hi all i have downlaod this resource login and register window show fine but select skin dosnt show :(

local localPlayer = getLocalPlayer() 
local playerName = getPlayerName(localPlayer)
local sx,sy = guiGetScreenSize()
wnd_window = {}
local guiSkinShop = guiCreateWindow(0.37*sx,0.80*sy,0.3*sx,0.15*sy,"Choose a skin!",false)
done = guiCreateButton(0.25,0.60,0.50,0.30,"Done",true,guiSkinShop)
left = guiCreateButton(0.07,0.60,0.15,0.30,"<-",true,guiSkinShop)
right = guiCreateButton(0.78,0.60,0.15,0.30,"->",true,guiSkinShop)
guiWindowSetSizable(guiSkinShop,false)
guiSetVisible(guiSkinShop, false)
skinLabel = guiCreateLabel(0.05,0.30,0.90,0.17,"Skins can be bought once in game",true,guiSkinShop)
    guiSetAlpha(skinLabel,1)
    guiLabelSetColor(skinLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop )
           guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop )
    guiLabelSetHorizontalAlign(skinLabel,"center",false)
    guiSetFont(skinLabel,"default-bold-small")
 
function createLoginWindow(title, logo, content)
 
            local xml = xmlLoadFile( "server.xml" )
            local content = xmlNodeGetValue( xml )
    windowLogin = guiCreateWindow(0.02*sx,0.05*sy,0.4*sx,0.8*sy,"Xeno's Login System",false)
    guiSetSize(windowLogin, 270, 400, false)
guiWindowSetSizable(windowLogin,false)
    guiCreateMemo(01,170,500,220,content,false,windowLogin)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(10,52,59,24,"Username:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
labelPassword = guiCreateLabel(10,86,59,24,"Password:",false,windowLogin)
 
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    labelInfo = guiCreateLabel(10,26,250,17,"Please login or register.",false,windowLogin)
    guiSetAlpha(labelInfo,1)
    guiLabelSetColor(labelInfo,255,255,255)
    guiLabelSetVerticalAlign(labelInfo,"top")
    guiLabelSetHorizontalAlign(labelInfo,"center",false)
    guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(10,121,117,21,"Log in",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(149,121,117,21,"Register",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
       guiCreateStaticImage( 0.0001, 0.370, 0.99, 0.006, "red.png", true, windowLogin )
       guiCreateStaticImage( 0.0001, 0.415, 0.99, 0.006, "red.png", true, windowLogin )
newsLabel = guiCreateLabel(0.35,0.372,0.300,0.17,"Server News",true,windowLogin)
    guiSetAlpha(newsLabel,1)
    guiLabelSetColor(newsLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.11, 0.99, 0.006, "red.png", true, windowLogin )
       guiCreateStaticImage( 0.0001, 0.06, 0.99, 0.006, "red.png", true, windowLogin )
    guiLabelSetHorizontalAlign(newsLabel,"center",false)
    guiSetFont(newsLabel,"default-bold-small")
 
    guiSetVisible(windowLogin, false)
    showChat(false)
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, showReg, false)
end
 
regMenu = guiCreateWindow(0.357*sx,0.05*sy,0.33*sx,0.3*sy,"Register Menu",false)
guiCreateStaticImage( 0.0001, 0.13, 0.99, 0.010, "red.png", true, regMenu )
guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.010, "red.png", true, regMenu )
guiWindowSetSizable(regMenu,false)
guiSetAlpha(regMenu,1)
 
    regUsername = guiCreateLabel(10,52,59,24,"Username:",false,regMenu)
    guiSetAlpha(regUsername,1)
    guiLabelSetColor(regUsername,255,255,255)
    guiLabelSetVerticalAlign(regUsername,"center")
    guiLabelSetHorizontalAlign(regUsername,"left",false)
    editRegUsername = guiCreateEdit(70,52,181,25,"",false,regMenu)
    guiSetAlpha(editRegUsername,1)
    guiEditSetMaxLength(editRegUsername, 50)
 
regPassword = guiCreateLabel(10,86,59,24,"Password:",false,regMenu)
 
    guiSetAlpha(regPassword,1)
    guiLabelSetColor(regPassword,255,255,255)
    guiLabelSetVerticalAlign(regPassword,"center")
    guiLabelSetHorizontalAlign(regPassword,"left",false)
 
editRegPassword = guiCreateEdit(70,86,181,25,"",false,regMenu)
    guiSetAlpha(editRegPassword,1)
    guiEditSetMasked(editRegPassword, true)
    guiEditSetMaxLength(editRegPassword, 50)
 
        regComPassword = guiCreateLabel(10,122,59,24,"*Email:",false,regMenu)
    guiSetAlpha(regComPassword,1)
    guiLabelSetColor(regComPassword,255,255,255)
    guiLabelSetVerticalAlign(regComPassword,"center")
    guiLabelSetHorizontalAlign(regComPassword,"left",false)
 
    editEmail = guiCreateEdit(70,120,181,25,"",false,regMenu)
    guiSetAlpha(editEmail,1)
    guiEditSetMasked(editEmail, true)
    guiEditSetMaxLength(editEmail, 50)
 
        buttonReg = guiCreateButton(10,150,120,21,"Register",false,regMenu)
    guiSetAlpha(buttonReg,1)
    buttonCan = guiCreateButton(143,150,117,21,"Cancel",false,regMenu)
    guiSetAlpha(buttonCan,1)
 
 
labelRegister = guiCreateLabel(10,26,250,17,"Register with a user and pass here.",false,regMenu)
 
guiSetAlpha(labelRegister,1)
guiLabelSetColor(labelRegister,255,255,255)
guiLabelSetVerticalAlign(labelRegister,"top")
guiLabelSetHorizontalAlign(labelRegister,"center",false)
guiSetFont(labelRegister,"default-bold-small")
 
 
guiSetVisible(regMenu, false)
 
function cancelWindow()
guiSetVisible(regMenu, false)
end
 
 
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("An error has occurred.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
showChat(true)
 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
 
        else
            guiSetText(labelInfo, "Enter username and password.")
        end
    end
end
 
function showReg(button, state)
guiSetVisible(regMenu, true)
end
 
function clientSubmitRegister(button, state)
if button == "left" and state == "up" then
    local username = guiGetText(editRegUsername)
    local password = guiGetText(editRegPassword)
    if username and password then
showChat(false)
 
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
        end
    end
end
 
 
 
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Enter old and new password.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
guiSetVisible(regMenu, false)
 
setTimer(guiSetVisible, 3100, 1, guiSkinShop, true)
showCursor(true)
end
 
 
function hideLoginWindow1()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
 
 
 
 
guiSetVisible(regMenu, false)
 call(getResourceFromName("guiText"),"outputGuiText","[RPG] You have been logged in!",255,0,0)
 
 
end
 
 
function hidePasswordWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowChangepw, false)
    showCursor(false)
end
 
function unknownError()
    guiSetText(labelInfo, "An unknown error occured.")
end
 
function loginWrong()
    guiSetText(labelInfo, "Wrong username and/or password.")
end
 
function registerTaken()
guiSetText(labelRegister, "This username is in use.")
end
 
 
 
 
 
 
function goRight(player)
  local newSkin = getElementModel (localPlayer) + 1
  while not setElementModel (localPlayer,newSkin) do newSkin = newSkin + 1 end
end
 
Link to comment

You had a little mess with the scripts there, fixed some small things and added spaces to make it easier for you to recognize the numbers from the number spam.

However, you had few missing addEventHandlers for the GUIs and possibly that's the reason why it didn't show up.

And for your information, 'localPlayer' is 1.1 afterwards been an built-in abbrevation for getLocalPlayer()

This is the current version, I might make some changes to it.

Command to open the skin selection screen: /skins

local playerName = getPlayerName(localPlayer) 
local sx, sy = guiGetScreenSize()
local thisRoot = getResourceRootElement(getRootElement())
local root = getRootElement()
 
function createShopWindow()
    guiSkinShop = guiCreateWindow(0.37 * sx, 0.80 * sy, 0.3 * sx, 0.15 * sy, "Choose a skin!", false)
    guiWindowSetSizable(guiSkinShop, false)
    guiSetVisible(guiSkinShop, false)
   
    guiCreateStaticImage(0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop)
    guiCreateStaticImage(0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop)
   
    done = guiCreateButton(0.25, 0.60, 0.50, 0.30, "Done", true, guiSkinShop)
    left = guiCreateButton(0.07, 0.60, 0.15, 0.30, "<-", true, guiSkinShop)
    right = guiCreateButton(0.78, 0.60, 0.15, 0.30, "->", true, guiSkinShop)
   
    skinLabel = guiCreateLabel(0.05, 0.30, 0.90, 0.17, "Skins can be bought once in game", true, guiSkinShop)
    guiLabelSetHorizontalAlign(skinLabel, "center", false)
    guiSetFont(skinLabel, "default-bold-small")
    guiLabelSetColor(skinLabel, 255, 255, 255)
    guiSetAlpha(skinLabel, 1)
   
    addEventHandler("onClientGUIClick", right, goRight, false)
    addEventHandler("onClientGUIClick", done, doneButton, false)
    addEventHandler("onClientGUIClick", left, goLeft, false)
end
addEventHandler("onClientResourceStart", thisRoot, createShopWindow)
 
function createLoginWindow(title, logo, content)
    local xml = xmlLoadFile("server.xml")
    local content = xmlNodeGetValue(xml)
    windowLogin = guiCreateWindow(0.02 * sx, 0.05 * sy, 0.4 * sx, 0.8 * sy, "Xeno's Login System", false)
    guiSetSize(windowLogin, 270, 400, false)
    guiWindowSetSizable(windowLogin, false)
    guiCreateMemo(01, 170, 500, 220, content, false, windowLogin)
    guiSetAlpha(windowLogin, 1)
    labelUsername = guiCreateLabel(10, 52, 59, 24, "Username:", false, windowLogin)
    guiSetAlpha(labelUsername, 1)
    guiLabelSetColor(labelUsername, 255, 255, 255)
    guiLabelSetVerticalAlign(labelUsername, "center")
    guiLabelSetHorizontalAlign(labelUsername, "left", false)
    labelPassword = guiCreateLabel(10, 86, 59, 24, "Password:", false, windowLogin)
 
    guiSetAlpha(labelPassword, 1)
    guiLabelSetColor(labelPassword, 255, 255, 255)
    guiLabelSetVerticalAlign(labelPassword, "center")
    guiLabelSetHorizontalAlign(labelPassword, "left", false)
    labelInfo = guiCreateLabel(10, 26, 250, 17, "Please login or register.", false, windowLogin)
    guiSetAlpha(labelInfo, 1)
    guiLabelSetColor(labelInfo, 255, 255, 255)
    guiLabelSetVerticalAlign(labelInfo, "top")
    guiLabelSetHorizontalAlign(labelInfo, "center", false)
    guiSetFont(labelInfo, "default-bold-small")
    editUsername = guiCreateEdit(79, 52, 181, 25, "", false, windowLogin)
    guiSetAlpha(editUsername, 1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(79, 86, 181, 25, "", false, windowLogin)
    guiSetAlpha(editPassword, 1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
   
    buttonLogin = guiCreateButton(10, 121, 117, 21, "Log in", false, windowLogin)
    guiSetAlpha(buttonLogin, 1)
    buttonRegister = guiCreateButton(149, 121, 117, 21, "Register", false, windowLogin)
    guiSetAlpha(buttonRegister, 1)
    guiCreateStaticImage(0.0001, 0.370, 0.99, 0.006, "red.png", true, windowLogin)
    guiCreateStaticImage(0.0001, 0.415, 0.99, 0.006, "red.png", true, windowLogin)
    newsLabel = guiCreateLabel(0.35, 0.372, 0.300, 0.17, "Server News", true, windowLogin)
    guiSetAlpha(newsLabel, 1)
    guiLabelSetColor(newsLabel, 255, 255, 255)
    guiCreateStaticImage(0.0001, 0.11, 0.99, 0.006, "red.png", true, windowLogin)
    guiCreateStaticImage(0.0001, 0.06, 0.99, 0.006, "red.png", true, windowLogin)
    guiLabelSetHorizontalAlign(newsLabel, "center", false)
    guiSetFont(newsLabel, "default-bold-small")
 
    guiSetVisible(windowLogin, false)
    showChat(false)
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, showReg, false)
end
 
function createRegisterWindow()
    regMenu = guiCreateWindow(0.357 * sx,0.05 * sy,0.33 * sx,0.3 * sy, "Register Menu", false)
    guiCreateStaticImage(0.0001, 0.13, 0.99, 0.010, "red.png", true, regMenu)
    guiCreateStaticImage(0.0001, 0.25, 0.99, 0.010, "red.png", true, regMenu)
    guiWindowSetSizable(regMenu, false)
    guiSetAlpha(regMenu, 1)
    guiSetVisible(regMenu, false)
     
    regUsername = guiCreateLabel(10, 52, 59, 24, "Username:", false, regMenu)
    guiSetAlpha(regUsername, 1)
    guiLabelSetColor(regUsername, 255, 255, 255)
    guiLabelSetVerticalAlign(regUsername, "center")
    guiLabelSetHorizontalAlign(regUsername, "left", false)
    editRegUsername = guiCreateEdit(70, 52, 181, 25, "", false, regMenu)
    guiSetAlpha(editRegUsername, 1)
    guiEditSetMaxLength(editRegUsername, 50)
     
    regPassword = guiCreateLabel(10, 86, 59, 24, "Password:", false, regMenu)
     
    guiSetAlpha(regPassword, 1)
    guiLabelSetColor(regPassword, 255, 255, 255)
    guiLabelSetVerticalAlign(regPassword, "center")
    guiLabelSetHorizontalAlign(regPassword, "left", false)
     
    editRegPassword = guiCreateEdit(70, 86, 181, 25, "", false, regMenu)
    guiSetAlpha(editRegPassword, 1)
    guiEditSetMasked(editRegPassword, true)
    guiEditSetMaxLength(editRegPassword, 50)
     
    regComPassword = guiCreateLabel(10, 122, 59, 24, "*Email:", false, regMenu)
    guiSetAlpha(regComPassword, 1)
    guiLabelSetColor(regComPassword, 255, 255, 255)
    guiLabelSetVerticalAlign(regComPassword, "center")
    guiLabelSetHorizontalAlign(regComPassword, "left", false)
   
    editEmail = guiCreateEdit(70, 120, 181, 25, "", false, regMenu)
    guiSetAlpha(editEmail, 1)
    guiEditSetMasked(editEmail, true)
    guiEditSetMaxLength(editEmail, 50)
     
    buttonReg = guiCreateButton(10, 150, 120, 21, "Register", false, regMenu)
    guiSetAlpha(buttonReg, 1)
    buttonCan = guiCreateButton(143, 150, 117, 21, "Cancel", false, regMenu)
    guiSetAlpha(buttonCan, 1)
   
    labelRegister = guiCreateLabel(10, 26, 250, 17, "Register with a user and pass here.", false, regMenu)
     
    guiSetAlpha(labelRegister, 1)
    guiLabelSetColor(labelRegister, 255, 255, 255)
    guiLabelSetVerticalAlign(labelRegister, "top")
    guiLabelSetHorizontalAlign(labelRegister, "center", false)
    guiSetFont(labelRegister, "default-bold-small")
   
    addEventHandler("onClientGUIClick", buttonCan, cancelWindow, false)
    addEventHandler("onClientGUIClick", buttonReg, clientSubmitRegister, false)
end
 
function showSkinSelection()
    local state = guiGetVisible(guiSkinShop)
    if state == false then
        guiSetVisible(guiSkinShop, true)
    else
        guiSetVisible(guiSkinShop, false)
    end
end
addCommandHandler("skins", showSkinSelection)
 
function cancelWindow()
    guiSetVisible(regMenu, false)
end
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("An error has occurred.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            showChat(true)
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Enter username and password.")
        end
    end
end
 
function showReg(button, state)
    guiSetVisible(regMenu, true)
end
 
function clientSubmitRegister(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editRegUsername)
        local password = guiGetText(editRegPassword)
        if username and password then
            showChat(false)
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        end
    end
end
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Enter old and new password.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
    guiSetVisible(regMenu, false)
    setTimer(guiSetVisible, 3100, 1, guiSkinShop, true)
    showCursor(true)
end
 
function hideLoginWindow1()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
    guiSetVisible(regMenu, false)
    call(getResourceFromName("guiText"),"outputGuiText","[RPG] You have been logged in!",255,0,0)
end
 
function hidePasswordWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowChangepw, false)
    showCursor(false)
end
 
function unknownError()
    guiSetText(labelInfo, "An unknown error occured.")
end
 
function loginWrong()
    guiSetText(labelInfo, "Wrong username and/or password.")
end
 
function registerTaken()
    guiSetText(labelRegister, "This username is in use.")
end
 
function goRight(player)
    local newSkin = getElementModel(localPlayer) + 1
    while not setElementModel(localPlayer, newSkin) do newSkin = newSkin + 1 end
end
 
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...