Jump to content

Recommended Posts

Witam. Pisze sobie system logowania do mta ale mam maly problem. Problem polega na tym ze po wcisnieciu buttonu "Zaloguj" powinno nas przeniesc do wyboru teamu ale nie przenosi. Sprawdzalem kod juz kilka razy ale nic nie znalazlem wiec moze wy cos znajdziecie :D.

Bardzo prosze o pomoc tutaj macie kod:

sound = playSound("logowanie.mp3")   
setSoundVolume(sound, 100)
 
 
 
function centerGUIElement(center_window)
local screenW,screenH=guiGetScreenSize()
local windowW,windowH=guiGetSize(center_window,false)
local x,y = (screenW-windowW)/2,(screenH-windowH)/2
guiSetPosition(center_window,x,y,false)
end
local localPlayer = getLocalPlayer()
x,y = guiGetScreenSize()
regtab = guiCreateTabPanel(x/3.30 - 22,y/3 - 60, 455,485,false)
guiSetAlpha(regtab, 0.87)
regulamin = guiCreateTab("Regulamin",regtab)
akc_reg_serw = guiCreateLabel(128,4,187,30,"Akceptacja regulaminu serwera",false,regulamin)
guiSetFont(akc_reg_serw,"default-bold-small")
reg = xmlLoadFile( "regulamin.xml" )
ra = xmlNodeGetValue(reg)
memo = guiCreateMemo(6,33,443,381,ra,false,regulamin)
guiMemoSetReadOnly(memo,true)
nieakceptuje = guiCreateButton(7,425,180,24,"Nie akceptuję regulaminu",false,regulamin)
guiSetFont(nieakceptuje,"default-bold-small")
guiSetProperty(nieakceptuje,"Disabled","true")
akceptuje = guiCreateButton(267,425,180,24,"Akceptuję regulamin",false,regulamin)
guiSetFont(akceptuje,"default-bold-small")
guiSetProperty(akceptuje,"Disabled","true")
 
local infoLabelText = "Witaj na serwerze. Jesli jeszcze tu nie grales to musisz sie zarejestrowac a jesli posiadasz juz konto to tylko sie zaloguj \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />"
local usernameText = "Login:"
local passwordText = "Haslo:"
local registerButtonText = "Zarejestruj"
local loginButtonText = "Zaloguj"
local loginWindowText = "Rejestracja/ Login"
 
fadeCamera(false)
showCursor(true)
toggleAllControls(false)
local screenW, screenH = guiGetScreenSize()
loginWindow = guiCreateWindow(screenW/2-648/2, screenH/2-303/2, 648, 303, loginWindowText, false)
guiWindowSetMovable(loginWindow, false)
guiWindowSetSizable(loginWindow, false)
infoLabel = guiCreateLabel(0.01, 0.11, 0.97, 0.33, infoLabelText, true, loginWindow)
guiSetFont(infoLabel, "default-bold-small")
guiLabelSetHorizontalAlign(infoLabel, "center", false)
guiLabelSetVerticalAlign(infoLabel, "center")
usernameLabel = guiCreateLabel(0.02, 0.48, 0.25, 0.13, usernameText, true, loginWindow)
guiSetFont(usernameLabel, "default-bold-small")
guiLabelSetHorizontalAlign(usernameLabel, "right", false)
guiLabelSetVerticalAlign(usernameLabel, "center")
usernameInput = guiCreateEdit(0.28, 0.50, 0.71, 0.10, getPlayerName(localPlayer), true, loginWindow)
guiEditSetMaxLength(usernameInput, 21)
passwordLabel = guiCreateLabel(0.02, 0.63, 0.25, 0.13, passwordText, true, loginWindow)
guiSetFont(passwordLabel, "default-bold-small")
guiLabelSetHorizontalAlign(passwordLabel, "right", false)
guiLabelSetVerticalAlign(passwordLabel, "center")
passwordInput = guiCreateEdit(0.28, 0.64, 0.71, 0.10, "", true, loginWindow)
guiEditSetMasked(passwordInput, true)
guiEditSetMaxLength(passwordInput, 32)
registerButton = guiCreateButton(0.02, 0.81, 0.43, 0.13, registerButtonText, true, loginWindow)
guiSetFont(registerButton, "default-bold-small")
guiSetProperty(registerButton, "NormalTextColour", "FFFFFFFF")
loginButton = guiCreateButton(0.46, 0.81, 0.52, 0.13, loginButtonText, true, loginWindow)
guiSetFont(loginButton, "default-bold-small")
guiSetProperty(loginButton, "NormalTextColour", "FFFFFFFF")
 
 
 
function buttonClick()
    if source == registerButton then
        if #guiGetText(usernameInput) < 5 then
            guiSetText(infoLabel,"Twoja nazwa uzytkownika musi miec co najmniej 5 znakow.")
            return
        end
        if #guiGetText(passwordInput) < 5 then
            guiSetText(infoLabel,"Twoje haslo musi miec co najmniej 5 znakow.")
            return
        end
        triggerServerEvent("registerServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
        guiSetEnabled(registerButton,false)
        setTimer(guiSetEnabled,3000,1,registerButton,true)
    elseif source == loginButton then
        triggerServerEvent("loginServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
        guiSetEnabled(loginButton,false)
        setTimer(guiSetEnabled,3000,1,loginButton,true)
    end
end
addEventHandler("onClientGUIClick",root,buttonClick)
 
addEvent("clientResponse",true)
function onResponse(n)
    if n == 3 then
        destroyElement(loginWindow)
        fadeCamera(true,5)
        showCursor(true)
        toggleAllControls(true)
        return
    elseif n == 2 then
        guiSetText(passwordInput,"")
        guiLabelSetColor(passwordLabel, 255, 0, 0)
    elseif n == 1 then
        guiSetProperty(registerButton, "NormalTextColour", "FFFF0000")
    elseif n == 4 or n == 5 then
        guiSetProperty(loginButton, "NormalTextColour", "FFFF0000")
    end
    responseText = {
        [1] = "To konto nie istnieje. Najpierw musisz sie zarejestrowac!",
        [2] = "Zle haslo sproboj ponownie!",
        [4] = "Konto z taka nazwa juz istnieje!",
        [5] = "Pomyslnie zarejestrowano. Mozesz teraz sie zalogowac!"
    }
    guiSetText(infoLabel,responseText[n])
end
addEventHandler("clientResponse",root,onResponse)
 
wybor = guiCreateTabPanel(x/2,y/2,465,280,false)
guiSetAlpha(wybor, 0.87)
praca = guiCreateTab("Wybór pracy",wybor)
napisa = guiCreateLabel(6,9,449,50,"Wybierz frakcje/firme do której należysz a następnie kliknij przycisk 'Wybierz'.\nJeśli nie posiadasz żadnej pracy zaznacz pole 'Truckerzy'",false,praca)
guiSetFont(napisa,"default-bold-small")
gridteam = guiCreateGridList ( 22, 63, 418, 150, false, praca )
kolteam = guiGridListAddColumn( gridteam, "Dostępne drużyny", 0.95 )
truc = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, truc, kolteam, "Kierowcy", false, false)
policja = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, policja, kolteam, "Policja", false, false)
pd = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, pd, kolteam, "Pomoc Drogowa", false, false)
pogo = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, pogo, kolteam, "Pogotowie", false, false)
tax = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, tax, kolteam, "Taxi", false, false)
pet = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, pet, kolteam, "Petrol", false, false)
sped = guiGridListAddRow(gridteam)
guiGridListSetItemText(gridteam, sped, kolteam, "InSped Transport", false, false)
wybierz = guiCreateButton(289,221,147,28,"Wybierz",false,praca)
guiSetFont(wybierz,"default-bold-small")
 
tabspawn = guiCreateTabPanel(x/2, y/2,465,226,false)
guiSetAlpha(tabspawn,0.87)
spawn = guiCreateTab("Miejsce spawnu",tabspawn)
najedg = guiCreateLabel(0.0151,0.06,0.9484,0.135,"Wybierz miasto w którym chcesz rozpocząć grę. Zaznacz odpowiednie miasto,\nnastępnie naciśnij przycisk 'Wybierz'.",true,spawn)
guiSetFont(najedg,"default-bold-small")
gridmiej = guiCreateGridList(0.0452,0.24,0.8925,0.53,true,spawn)
guiGridListSetSelectionMode(gridmiej,1)
miast = guiGridListAddColumn(gridmiej,"Miasta",0.90)
sf = guiGridListAddRow(gridmiej)
guiGridListSetItemText(gridmiej, sf, miast, "San Fierro", false, false)
lv = guiGridListAddRow(gridmiej)
guiGridListSetItemText(gridmiej, lv, miast, "Las Venturas", false, false)
ls = guiGridListAddRow(gridmiej)
guiGridListSetItemText(gridmiej, ls, miast, "Los Santos", false, false)
wybspawn = guiCreateButton(0.6258,0.805,0.3032,0.15,"Wybierz",true,spawn)
guiSetFont(wybspawn,"default-bold-small")
 
--Chowanie GUI--
guiSetVisible(regtab,false)
guiSetVisible (loginWindow, false)
guiSetVisible(wybor, false)
guiSetVisible(tabspawn, false)
centerGUIElement(loginWindow)
centerGUIElement(regtab)
centerGUIElement(tabspawn)
centerGUIElement(wybor)
 
function przyciski (button, state, absoluteX, absoluteY)
     if (source == akceptuje) then
     guiSetVisible(regtab,false)
     guiSetVisible(regulamin,false)
     guiSetVisible(loginWindow, true)
     guiSetInputMode("no_binds_when_editing")
     elseif(source == nieakceptuje) then
     triggerServerEvent ("Kick", getLocalPlayer())
     end
end
addEventHandler ("onClientGUIClick", getResourceRootElement(getThisResource()), przyciski)
 
function x()
guiSetVisible(regtab, true, true)
showPlayerHudComponent ( "radar", false )
showPlayerHudComponent ( "area_name", false )
setTimer(zmien, 1000, 1)
showCursor(true)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), x)
 
function zmien()
guiSetProperty(nieakceptuje,"Disabled","false")
guiSetProperty(akceptuje,"Disabled","false")
end
 
function hide()
guiSetEnablet(true)
guiSetVisible(loginWindow,false)
guiSetVisible(wybor,true)
end
addEvent("hide", true)
addEventHandler("hide", getResourceRootElement(getThisResource()), hide)
 
 
local facing = 0
function kamerka()
    local x, y, z = -2502.8571777344, 2417.1428222656, 62 --bayside
    local camX = x + math.cos( facing / math.pi * 180 ) * 5
    local camY = y + math.sin( facing / math.pi * 180 ) * 5
    setCameraMatrix( camX, camY, z+1, x, y, z-2)
    facing = facing + 0.000012
end
addEventHandler("onClientRender", getRootElement(), kamerka)
 
--Wybieranie pracy--
function pr(button, state, thePlayer)
if (source == wybierz) then
if button == "left" and state == "up" then
local praca = guiGridListGetItemText (gridteam, guiGridListGetSelectedItem(gridteam))
    if (praca == "Kierowcy") then
        guiSetVisible(wybor, false)
        guiSetVisible(tabspawn, true)
    elseif (praca == "Policja") then
        triggerServerEvent("pol", getRootElement(), getLocalPlayer())
    elseif (praca == "Pogotowie") then
        triggerServerEvent("pogo", getRootElement(), getLocalPlayer()) 
    elseif (praca == "Pomoc Drogowa") then
        triggerServerEvent("pd", getRootElement(), getLocalPlayer())
    elseif (praca == "Taxi") then
    triggerServerEvent("tax", getRootElement(), getLocalPlayer())   
    elseif (praca == "Petrol") then
        triggerServerEvent("pet", getRootElement(), getLocalPlayer())          
    elseif (praca == "InSped Transport") then
        triggerServerEvent("sped", getRootElement(), getLocalPlayer()) 
    else
    outputChatBox ("Nie wybrałeś żadnej pracy. Jeśli nie jesteś nigdzie zatrudniony wybierz pole #FFCC00Kierowcy#FFFFFF.", 255, 255, 255, true)
    end
    end
    end
end
addEventHandler ("onClientGUIClick", wybierz, pr, false)
 
--Wybieranie spawnu--
function so(button, state, thePlayer)
if (source == wybspawn) then
if button == "left" and state == "up" then
local ms = guiGridListGetItemText (gridmiej, guiGridListGetSelectedItem(gridmiej))
    if (ms == "San Fierro") then
        showCursor(false)
        guiSetVisible(tabspawn, false)
        triggerServerEvent("sf", getRootElement(), getLocalPlayer())
        showPlayerHudComponent ("all", true)
    elseif (ms == "Las Venturas") then
       
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...