x,y=36.63,82.19 -- my width
intro_step=math.random(0,850)
local sx,sy=guiGetScreenSize()
local data={ showed=nil, button={}, info=nil, misc=nil, }
function isMouseIn(psx,psy,pssx,pssy,abx,aby)
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end
local dist = 10
local angler = 0
function getPointFromDistanceRotation(x, y, dist, angler)
local a = math.rad(20 - angler)
local dx = math.cos(a) * dist;
local dy = math.sin(a) * dist;
return x+dx, y+dy;
end
function renderLoginBox()
if data.info then dxDrawText(data.info, sx*36/640, sy*124/480, sx*156/640, sy*31/480, tocolor(237, 0, 0, 255), 1.00, "default", "center", "center", false) end
dxDrawImage(0, 0, 640, 480, "panel.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
--loguj = guiCreateButton(0.07, 0.58, 0.22, 0.08, "", true, wm.window)\
--rejestruj = guiCreateButton(0.07, 0.68, 0.22, 0.08, "", true, wm.window)
--log = guiCreateButton(0.07, 0.57, 0.21, 0.08, "", true)
--reg = guiCreateButton(0.08, 0.68, 0.21, 0.07, "", true)
--dxDrawText("", 44, 271, 181, 315, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
--dxDrawText("", 44, 321, 181, 360, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
-- end
--)
addEventHandler("onClientClick", root, function(btn,state)
if btn=="left" and state=="down" then
if isMouseIn(44, 271, 181, 315) and data.showed then
local login=guiGetText(data.button[1])
local pass=guiGetText(data.button[2])
if string.len(login) < 2 or string.len(pass) < 2 then
data.info="Wype?nij wszystkie pola!"
return
end
triggerServerEvent("logging:checkAccount", resourceRoot, login, pass)
end
if isMouseIn(44, 321, 181, 360) and data.showed then
local login=guiGetText(data.button[1])
local pass=guiGetText(data.button[2])
if string.len(login) < 2 or string.len(pass) < 2 then
data.info="Wype?nij wszystkie pola!"
return
end
if string.len(login) > 22 or string.len(pass) > 30 then
data.info="Login/Has?o musi mie? mniej ni? 22/30 znak?w."
return
end
triggerServerEvent("logging:newAccount", resourceRoot, login, pass)
end
end
end)
addEvent("logging:result", true)
addEventHandler("logging:result", resourceRoot, function(value,info)
if not info then info="" end
if value then
data.showed=false
showZones(data.misc)
-- Usuwamy elementy
destroyElement(data.button[1])
destroyElement(data.button[2])
removeEventHandler("onClientRender", root, renderLoginBox)
else
data.info=tostring(info)
setTimer(function() data.info=nil end, 3000, 1)
end
end)
addEventHandler("onClientResourceStart", resourceRoot, function()
showChat(false)
showCursor(true)
fadeCamera(true)
data.showed=true
setElementAlpha(localPlayer,0)
data.misc=playSound("misc/intro.mp3",true)
setSoundVolume(data.misc, 1.0)
showPlayerHudComponent("all",false)
guiSetInputMode("no_binds_when_editing")
setElementData(localPlayer,"status","Loguje si?")
setElementData(localPlayer,"player:logged",false)
addEventHandler("onClientRender", root, renderLoginBox)
data.button[1]=guiCreateEdit(0.10, 0.37, 0.15, 0.04, "", true)
data.button[2]=guiCreateEdit(0.10, 0.48, 0.18, 0.04, "", true)
guiEditSetMasked(data.button[2],true)
end)