zmienione na root w calym kodzie, nadal nic.
Nawet jak dam outputChatBoxa do clienta, nie wykona si?.
Po prostu, server nie wysyla nic do clienta, a nie wyskakuj? b??dy.
Nie mam ju? kompletnie pomys?u, daje ca?y kod:
Server
--[[
* Author: Szymixo
* Project: iPlay-RPG
* Type: server
]]--
----------------------------------------------------------------------------
local SQL = dbConnect("mysql", "dbname=mta;host=localhost", "root", "", "share=1")
if SQL == false then
outputDebugString("Polaczenie z MySQL nie udalo sie.")
else
outputDebugString("Poprawnie polaczono z baza danych MySQL")
end
----------------------------------------------------------------------------
addEventHandler("onPlayerJoin", getRootElement(), function()
triggerClientEvent(source, "openLoginGUI", source)
end)
----------------------------------------------------------------------------
function loginPlayer(username, password)
query = dbQuery(SQL, "SELECT * FROM accounts WHERE BINARY username=? and password=?", username, password)
result, numrows, errorMsg = dbPoll(query, -1)
local row = result[1]
if row then
triggerClientEvent(client, "login.success", client)
outputChatBox("Pomy?lnie zalogowa?e? si?.", client)
else
outputChatBox("Niepoprawne dane logowania!", client)
end
end
addEvent("loginPlayer", true)
addEventHandler("loginPlayer", getRootElement(), loginPlayer)
----------------------------------------------------------------------------
function registerPlayer(username, password, email)
query = dbQuery(SQL, "SELECT * FROM accounts WHERE BINAY username=?", username)
result, numrows, errorMsg = dbPoll(query, -1)
local row = result[1]
if row then
outputChatBox("Ten nick jest ju? zaj?ty!", client)
else
query1 = dbQuery(SQL, "INSERT INTO accounts (username, password, email) VALUES (?, ?, ?)", username, password, email)
triggerClientEvent(client, "register.success", client)
end
end
addEvent("registerPlayer", true)
addEventHandler("registerPlayer", resourceRoot, registerPlayer)
----------------------------------------------------------------------------
Client
--[[
* Author: Szymixo
* Project: iPlay-RPG
* Type: client
]]--
----------------------------------------------------------------------------
function centerWindow (center_window)
local screenW, screenH = guiGetScreenSize()
local windowW, windowH = guiGetSize(center_window, false)
local x, y = (screenW - windowW) /2,(screenH - windowH) /2
return guiSetPosition(center_window, x, y, false)
end
----------------------------------------------------------------------------
GUIEditor = {
button = {},
window = {},
label = {},
memo = {}
}
-- GUI Rejestracji !!! DO ZMIANY !!!
window = guiCreateWindow(605, 120, 334, 286, "Register.", false)
guiWindowSetSizable(window, false)
guiSetVisible(window, false)
centerWindow(window)
guiWindowSetMovable(window, false)
labUser = guiCreateLabel(27, 66, 64, 15, "Username:", false, window)
guiSetFont(labUser, "default-bold-small")
labPass = guiCreateLabel(27, 104, 64, 15, "Password:", false, window)
guiSetFont(labPass, "default-bold-small")
regRepeat = guiCreateEdit(111, 132, 183, 33, "", false, window)
guiEditSetMasked(regRepeat, true)
labRep = guiCreateLabel(8, 140, 103, 15, "Repeat Password:", false, window)
guiSetFont(labRep, "default-bold-small")
regPassword = guiCreateEdit(111, 96, 183, 33, "", false, window)
guiEditSetMasked(regPassword, true)
regUsername = guiCreateEdit(111, 58, 183, 33, "", false, window)
regEmail = guiCreateEdit(111, 169, 183, 33, "", false, window)
labMail = guiCreateLabel(42, 179, 35, 13, "Email:", false, window)
guiSetFont(labMail, "default-bold-small")
goback = guiCreateButton(23, 227, 120, 49, "Back", false, window)
guiSetFont(goback, "default-bold-small")
regBtn = guiCreateButton(191, 229, 120, 47, "Register", false, window)
guiSetFont(regBtn, "default-bold-small")
-- GUI logowania !!! DO ZMIANY !!!
GUIEditor.window[1] = guiCreateWindow(562, 255, 427, 460, "Login.", false)
guiWindowSetSizable(GUIEditor.window[1], false)
guiSetVisible(GUIEditor.window[1], false)
centerWindow(GUIEditor.window[1])
guiWindowSetMovable(GUIEditor.window[1], false)
GUIEditor.label[1] = guiCreateLabel(13, 46, 57, 19, "Username", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[1], "default-bold-small")
username = guiCreateEdit(80, 36, 174, 31, "", false, GUIEditor.window[1])
GUIEditor.label[2] = guiCreateLabel(13, 87, 57, 19, "Password", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[2], "default-bold-small")
password = guiCreateEdit(80, 77, 174, 31, "", false, GUIEditor.window[1])
guiEditSetMasked(password, true)
GUIEditor.button[1] = guiCreateButton(281, 81, 122, 40, "Register", false, GUIEditor.window[1])
guiSetFont(GUIEditor.button[1], "default-bold-small")
GUIEditor.label[3] = guiCreateLabel(0, 116, 521, 15, "____________________________________________________________________________________", false, GUIEditor.window[1])
GUIEditor.button[2] = guiCreateButton(284, 33, 119, 40, "Login", false, GUIEditor.window[1])
guiSetFont(GUIEditor.button[2], "default-bold-small")
GUIEditor.label[4] = guiCreateLabel(10, 141, 57, 19, "Updates", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[4], "default-bold-small")
GUIEditor.memo[1] = guiCreateMemo(9, 162, 408, 283, "", false, GUIEditor.window[1])
guiMemoSetReadOnly(GUIEditor.memo[1], true)
----------------------------------------------------------------------------
function loginGUI()
guiSetVisible(GUIEdior.window[1], true)
showCursor(true)
fadeCamera(true)
guiSetInputEnabled(false)
end
addEvent("openLoginGUI", true)
addEventHandler("openLoginGUI", localPlayer, loginGUI)
----------------------------------------------------------------------------
function login()
if(source == GUIEditor.button[2]) then
if(string.len(guiGetText(password)) > 4 and string.len(guiGetText(username)) > 1) then
triggerServerEvent("loginPlayer", root, guiGetText(username), guiGetText(password))
else
outputChatBox("Has?o musi mie? minimum 4 znaki, a Login 1 znak!", root)
end
end
end
addEventHandler("onClientGUIClick", localPlayer, login)
----------------------------------------------------------------------------
function register()
if (source == regBtn) then
if(string.len(guiGetText(regPassword)) > 4 and string.len(guiGetText(regUsername)) > 1) then
if(guiGetText(regPassword) == guiGetText(regRepeat)) then
triggerServerEvent("registerPlayer", root, guiGetText(regUsername), guiGetText(regPassword))
else
outputChatBox("Has?a nie s? takie same!", client)
end
else
outputChatBox("Twoje has?o lub login s? za kr?tkie!", client)
end
end
end
addEventHandler("onClientGUIClick", localPlayer, register)
----------------------------------------------------------------------------
function backToLogin()
if(source == goback) then
guiSetVisible(GUIEditor.window[1], true)
guiSetVisible(window, false)
end
end
addEventHandler("onClientGUIClick", localPlayer, backToLogin)
----------------------------------------------------------------------------
function openRegisterFormule()
if(source == GUIEditor.button[1]) then
guiSetVisible(GUIEditor.window[1], false)
guiSetVisible(window, true)
end
end
addEventHandler("onClientGUIClick", localPlayer, openRegisterFormule)
----------------------------------------------------------------------------
function updateNews()
local input = xmlLoadFile("news.xml")
local value = xmlNodeGetValue(input)
guiSetText(GUIEditor.memo[1], tostring(value))
end
updateNews()
----------------------------------------------------------------------------
function loginSuccess()
fadeCamera(true, 1, 255, 0, 0)
guiSetVisible(GUIEditor.window[1], false)
showCursor(false)
end
addEvent("login.success", true)
addEventHandler("login.success", localPlayer, loginSuccess)
----------------------------------------------------------------------------
function registerSuccess()
guiSetVisible(GUIEditor.window[1], true)
guiSetVisible(window, false)
end
addEvent("register.success", true)
addEventHandler("register.success", localPlayer, registerSuccess)
----------------------------------------------------------------------------
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach