Jump to content

Register problem


Recommended Posts

Posted

client side

function registering() 
    if ( source == GUIEditor_Button[4] ) then 
        local g_textR = guiGetText( GUIEditor_Edit[3] ) 
        local g_textR2 = guiGetText( GUIEditor_Edit[4] ) 
        local g_textR3 = guiGetText( GUIEditor_Edit[5] ) 
        triggerServerEvent("g_textToRegister", getRootElement(), getLocalPlayer(), g_textR, g_textR2, g_textR3) 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), registering) 

server side

function g_textToRegister( player, user, password, g_textR3) 
    if password == g_textR3 then 
    account = addAccount ( user, password ) 
    else 
    triggerClientEvent(player,"confirmError",player) 
    if (logIn ( player, account2, password ) == true) then 
    outputChatBox ( "successfully registered, welcome ".. getPlayerName( source ), player, 255, 255, 0 , true ) 
            randomModel = math.random( 26, 37 ) 
            setElementModel ( player, randomModel ) 
    else 
    triggerClientEvent(player,"registerEroor",player) 
    end 
    end 
    end 
addEvent("g_textToRegister", true) 
addEventHandler("g_textToRegister", getRootElement(), g_textToRegister) 

every " else " that i put were happened, registerError and confirmError

sorry, I've been confused with this code

F4MZM4.gif

Posted

try

function g_textToRegister(player, user, password, g_textR3) 
     if password ~= g_textR3 then 
          triggerClientEvent(player,"confirmError",player) 
     return end 
    if getAccount(user) then 
        -- the Account already registred before.. 
     return end 
          local account = addAccount(user, password) 
     if logIn(player, account, password) then 
          outputChatBox("successfully registered, welcome "..getPlayerName(player), player, 255, 255, 0 , true) 
          randomModel = math.random(26, 37) 
          setElementModel(player, randomModel) 
     else 
          triggerClientEvent(player,"registerEroor",player) 
     end 
end 
addEvent("g_textToRegister", true) 
addEventHandler("g_textToRegister", root, g_textToRegister) 

CiTLh.png
Posted (edited)

i have another problem

        if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
        guiSetVisible( GUIEditor_Label[15], true ) 
        setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false )  
        return  
        end 

i want here if gui-edit[6] wasn't completed then stop every thing and show the error inside the gui-label[15]

Edited by Guest

F4MZM4.gif

Posted
i have another problems
        if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
        guiSetVisible( GUIEditor_Label[15], true ) 
        setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false )  
        return  
        end 

i want here if gui-edit[6] wasn't completed then stop every thing and show the error inside the gui-label[15]

Can you explain better ?

ING : [xXx]~Al3grab

Posted

You mean progress bar? Use "guiProgressBarGetProgress".

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
You mean progress bar? Use "guiProgressBarGetProgress".

you're really out of the subject and no

Maybe explaining in a proper english instead of wait for others to discover what you want would make me not being "out of subject".

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (edited)

try this,

Client:

function registering() 
    if ( source == GUIEditor_Button[4] ) then 
        local g_textR = guiGetText( GUIEditor_Edit[3] ) 
        local g_textR2 = guiGetText( GUIEditor_Edit[4] ) 
        local g_textR3 = guiGetText( GUIEditor_Edit[5] ) 
        if g_textR ~= "" and g_textR2~="" and g_textR3~="" then --check if the field actually have something 
            triggerServerEvent("g_textToRegister",localPlayer, g_textR, g_textR2, g_textR3) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",guiRoot, registering) 

Server:

function g_textToRegister( user, password, g_textR3) 
    if password == g_textR3 then 
        local account = addAccount ( user, password ) 
    else 
        triggerClientEvent(client,"confirmError",root) 
        return --automatically end the script if the password doesn't match 
    end 
    if logIn ( client, account, password) then --you used account2 instead of account 
        outputChatBox ( "successfully registered, welcome ".. getPlayerName( client ), client, 255, 255, 0 , true ) 
        randomModel = math.random( 26, 37 ) 
        setElementModel ( client, randomModel ) 
    else 
        triggerClientEvent(client,"registerEroor",root) 
    end 
end 
addEvent("g_textToRegister", true) 
addEventHandler("g_textToRegister",root, g_textToRegister) 

Edited by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted (edited)

Listen andrel,

if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
            guiSetVisible( GUIEditor_Label[15], true ) 
            setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
            return 
            end 

this is register code

so GUIEditor_Edit[6] is the player's e-mail so if he typed nothing then guiSetVisible true to GUIEditor_Label[15] this gui-label is an error

GUIEditor_Label[15] = guiCreateLabel(443,310,148,18,"enter your e-mail !",false,GUIEditor_Window[2]) 

i hope you understood me.

Edited by Guest

F4MZM4.gif

Posted
try this,

Client:

function registering() 
    if ( source == GUIEditor_Button[4] ) then 
        local g_textR = guiGetText( GUIEditor_Edit[3] ) 
        local g_textR2 = guiGetText( GUIEditor_Edit[4] ) 
        local g_textR3 = guiGetText( GUIEditor_Edit[5] ) 
        if g_textR ~= "" and g_textR2~="" and g_textR3~="" then --check if the field actually have something 
            triggerServerEvent("g_textToRegister",localPlayer, g_textR, g_textR2, g_textR3) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",guiRoot, registering) 

Server:

function g_textToRegister( user, password, g_textR3) 
    if password == g_textR3 then 
        account = addAccount ( user, password ) 
    else 
        triggerClientEvent(client,"confirmError",root) 
        return 
    end 
    if logIn ( client, account, password) then 
        outputChatBox ( "successfully registered, welcome ".. getPlayerName( client ), client, 255, 255, 0 , true ) 
        randomModel = math.random( 26, 37 ) 
        setElementModel ( client, randomModel ) 
    else 
        triggerClientEvent(client,"registerEroor",root) 
    end 
end 
addEvent("g_textToRegister", true) 
addEventHandler("g_textToRegister",root, g_textToRegister) 

jaysds this problem was solved

i'm talking now about this

        if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
        guiSetVisible( GUIEditor_Label[15], true ) 
        setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
        return 
        end 

thanks anyway :)

F4MZM4.gif

Posted
if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
        guiSetVisible( GUIEditor_Label[15], true ) 
        setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
        return 
        end 

if guiGetText ( GUIEditor_Edit[6] ) == "" then 
    guiSetVisible( GUIEditor_Label[15], true ) 
    setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
    return 
end 

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (edited)
if #guiGetText ( GUIEditor_Edit[6] ) == 0 then 
        guiSetVisible( GUIEditor_Label[15], true ) 
        setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
        return 
        end 

if guiGetText ( GUIEditor_Edit[6] ) == "" then 
    guiSetVisible( GUIEditor_Label[15], true ) 
    setTimer( guiSetVisible, 3000, 1, GUIEditor_Label[15], false ) 
    return 
end 

it doesn't work,

i see the error and the account was created.. ?

i want if the Edit[6] is empty then stop the registering process.

if full code needed then tell me

Edited by Guest

F4MZM4.gif

Posted

What happens? Errors? Did you check 'if'? Does label even shows? Nothing?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
What happens? Errors? Did you check 'if'? Does label even shows? Nothing?

the Label error is showing if the GUIEditor_Edit[6] is empty, but the registering process doesn't stop, it only show the label error

F4MZM4.gif

Posted

Maybe because you added "return" to stop the function after the label shows?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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...