Hey leute ich habe ein Log-in bekommen , dass auch funktionier aber ich weiss nicht, was ich machen muss um danach irgendwo zu spawnen.Denn bei mir wenn ich mich einlogge bleibt der bildschirm schwarz.
Was muss ich scripten ?
Es wäre auch cool wenn sich ein Auto neben mir spawnt kann mir vielleicht einer weiterhelfen?
Ich packe mal das Log-in hier rein.
Danke im vorraus;)
PHP
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
Client:
function createPasswordWindow()
windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"[P-Login] - Change password",true)
guiSetSize(windowChangepw, 165, 21)
guiSetAlpha(windowChangepw,0.80000001192093)
editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
guiSetAlpha(editOldpw,1)
guiEditSetMasked(editOldpw,true)
labelOldpw = guiCreateLabel(10,29,90,21,"Old password:",false,windowChangepw)
guiSetAlpha(labelOldpw,1)
guiLabelSetColor(labelOldpw,255,255,255)
guiLabelSetVerticalAlign(labelOldpw,"center")
guiLabelSetHorizontalAlign(labelOldpw,"left",false)
editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
guiSetAlpha(editNewpw,1)
guiEditSetMasked(editNewpw,true)
guiEditSetMaxLength(editNewpw,50)
labelNewpw = guiCreateLabel(10,60,90,21,"New password:",false,windowChangepw)
guiSetAlpha(labelNewpw,1)
guiLabelSetColor(labelNewpw,255,255,255)
guiLabelSetVerticalAlign(labelNewpw,"center")
guiLabelSetHorizontalAlign(labelNewpw,"left",false)
buttonChangepw = guiCreateButton(10,91,265,23,"Change password",false,windowChangepw)
guiSetAlpha(buttonChangepw,1)
guiSetVisible(windowChangepw, false)
addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
end
function createLoginWindow()
windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"[P-Login]",true)
guiSetSize(windowLogin, 270, 155, false)
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,playerName,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,120,21,"Log in",false,windowLogin)
guiSetAlpha(buttonLogin,1)
buttonRegister = guiCreateButton(143,121,117,21,"Register",false,windowLogin)
guiSetAlpha(buttonRegister,1)
guiSetVisible(windowLogin, false)
addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, 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
triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
else
guiSetText(labelInfo, "Enter username and password.")
end
end
end
function clientSubmitRegister(button, state)
if button == "left" and state == "up" then
local username = guiGetText(editUsername)
local password = guiGetText(editPassword)
if username and password then
triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
else
guiSetText(labelInfo, "Enter username and 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)
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(labelInfo, "This username is allready taken.")
end
addEvent("hidePasswordWindow", true)
addEvent("hideLoginWindow", true)
addEvent("unknownError", true)
addEvent("loginWrong", true)
addEvent("registerTaken", true)
addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
addEventHandler("unknownError", getRootElement(), unknownError)
addEventHandler("loginWrong", getRootElement(), loginWrong)
addEventHandler("registerTaken", getRootElement(), registerTaken)
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart)
addCommandHandler("changepw", changePw)
Alles anzeigen
Script:
PHP
function passwordHandler(player, oldpassword, newpassword)
local account = getPlayerAccount(player)
if (account) then
if (isGuestAccount(account)) then
outputChatBox("You must be logged in to change your password.", player)
return
end
local playerName = getPlayerName(player)
local password_check = getAccount(playerName, oldpassword)
if (password_check ~= false) then
if (string.len(newpassword) >= 5) then
setAccountPassword(account, newpassword)
triggerClientEvent(player, "hidePasswordWindow", getRootElement())
else
outputChatBox("Your new password must be at least 5 characters long!", player)
end
else
outputChatBox("Old password invalid.", player)
end
end
end
function loginHandler(player, username, password)
local account = getAccount(username, password)
if (account ~= false) then
if (logIn(player, account, password) == true) then
outputChatBox("If you want to change your password, use /changepw", player)
triggerClientEvent (player, "hideLoginWindow", getRootElement())
else
triggerClientEvent (player, "unknownError", getRootElement())
end
else
triggerClientEvent (player, "loginWrong", getRootElement())
end
end
function registerHandler(player, username, password)
local account = getAccount(username, password)
if (account ~= false) then
triggerClientEvent(player, "registerTaken", getRootElement())
else
account = addAccount(username, password)
if (logIn(player, account, password) == true) then
outputChatBox("If you want to change your password, use /changepw", player)
triggerClientEvent(player, "hideLoginWindow", getRootElement())
else
triggerClientEvent(player, "unknownError", getRootElement())
end
end
end
addEvent("submitChangepw", true)
addEvent("submitLogin", true)
addEvent("submitRegister", true)
addEventHandler("submitChangepw", root, passwordHandler)
addEventHandler("submitLogin", root, loginHandler)
addEventHandler("submitRegister", root, registerHandler)
Alles anzeigen
Meta:
Tut mir leid aber ich bin halt noch ein voller anfänger