Jump to content

I have a simple question :D


SoundWave

Recommended Posts

@ Solidsnake14: No i don't want to see there passwords i only want to see their nicknames.

@ Citizen: Well we have a site when a player when one of the leaders sends a private message to him that he can write an

application then the leaders will decide if he can join or not so when we say YES you can join then i can see his login and so i can make him admin then :D

here is the register code:

client:

function build_loginWin() 
    confFile = xmlLoadFile("preferences.xml") 
    if (confFile) then 
        infoTable["account"] = xmlNodeGetAttribute(confFile,"username") 
        infoTable["pass"] = xmlNodeGetAttribute(confFile,"pass") 
        infoTable["save"] = xmlNodeGetAttribute(confFile,"save") 
    else 
        confFile = xmlCreateFile("preferences.xml","user") 
        xmlNodeSetAttribute(confFile,"username","") 
        xmlNodeSetAttribute(confFile,"pass","") 
        xmlNodeSetAttribute(confFile,"save","false") 
         
        infoTable["account"] = getPlayerName(localPlayer) 
        infoTable["pass"] = "" 
        infoTable["save"] = "false" 
    end 
    xmlSaveFile(confFile) 
---- THIS IS NOT THE WHOLE CODE THE OTHER PART YOU DON'T NEED THAT IS THE GUI BUT IT IS SCRIPTED IN HERE ------ 

--REGISTER THE PLAYER 
function attemptToRegister(button, state) 
    local username = guiGetText(Login_Edit[3]) 
    local pass1 = guiGetText(Login_Edit[4]) 
    local pass2 = guiGetText(Login_Edit[5]) 
    if (guiCheckBoxGetSelected(Login_Check[1])) then 
        if not (tostring(username) == "") then 
            if not (tostring(pass1) == "") or not (tostring(pass1) == "") then 
                if (pass1 == pass2) then 
                    showCursor(false,false) 
                    guiSetInputEnabled(false) 
                    triggerServerEvent("onClientSendRegisterDataToServer", getRootElement(), localPlayer, username, pass1)               
                else 
                    reason = "The passwords do not match!" 
                    build_Warning(localPlayer, reason) 
                end 
            else 
                reason = "No password was entered!" 
                build_Warning(localPlayer, reason) 
            end 
        else 
            reason = "No username was entered!" 
            build_Warning(localPlayer, reason) 
        end 
    else 
        reason = "You did not accept the rules!" 
        build_Warning(localPlayer, reason) 
    end 
end 

server:

--REGISTER THE PLAYER 
function tryToRegsiterPlayer(player, username, pass) 
    if not getAccount(username, pass) then 
        theAccount = addAccount(username, pass) 
        if (theAccount) then 
            logIn(player, theAccount, pass) 
            outputChatBox("* You successfully registered account '" ..username.. "' for player '" ..getPlayerName(player).. "' with password '" ..pass.."'!", player, 0, 255, 0, false) 
            triggerClientEvent("onRegisterPlayWelcomeSound", player) 
            triggerClientEvent("onPlayerFirstTimeSeen", player) 
            triggerClientEvent("onPlayerDoneLogin", player) 
            setTimer(triggerClientEvent, 3000, 1, "onPlayerPlayUEFASound", player, false)            
        else 
            reason = "The Account already exists!" 
            triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
        end 
    else 
        reason = "The Account already exists!" 
        triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
    end 
end 
addEvent("onClientSendRegisterDataToServer", true) 
addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer) 

Link to comment
  • Moderators

Try this ( replace SoundWave by your name In-Game ):

Server:

--REGISTER THE PLAYER 
function tryToRegsiterPlayer(player, username, pass) 
    if not getAccount(username, pass) then 
        theAccount = addAccount(username, pass) 
        if (theAccount) then 
            logIn(player, theAccount, pass) 
            outputChatBox("* You successfully registered account '" ..username.. "' for player '" ..getPlayerName(player).. "' with password '" ..pass.."'!", player, 0, 255, 0, false) 
             
            local you = getPlayerFromName( "SoundWave" ) 
            outputChatBox(" The player "..getPlayerName(player).." have been registered with the login "..username, you  ) 
             
            triggerClientEvent("onRegisterPlayWelcomeSound", player) 
            triggerClientEvent("onPlayerFirstTimeSeen", player) 
            triggerClientEvent("onPlayerDoneLogin", player) 
            setTimer(triggerClientEvent, 3000, 1, "onPlayerPlayUEFASound", player, false)           
        else 
            reason = "The Account already exists!" 
            triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
        end 
    else 
        reason = "The Account already exists!" 
        triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
    end 
end 
addEvent("onClientSendRegisterDataToServer", true) 
addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer) 

Link to comment
  • Moderators
Well now it shows when a player registers but when i am not online and someone registers i won't see their register nickname

well is it possible to save there logins somewhere where i can see them :P

Server:

--REGISTER THE PLAYER 
function tryToRegsiterPlayer(player, username, pass) 
    if not getAccount(username, pass) then 
        theAccount = addAccount(username, pass) 
        if (theAccount) then 
            logIn(player, theAccount, pass) 
            outputChatBox("* You successfully registered account '" ..username.. "' for player '" ..getPlayerName(player).. "' with password '" ..pass.."'!", player, 0, 255, 0, false) 
            
            local you = getPlayerFromName( "SoundWave" ) 
            outputChatBox(" The player "..getPlayerName(player).." have been registered with the login "..username, you  ) 
            saveTheLogins( getPlayerName(player), tostring( username ) ) 
            
            triggerClientEvent("onRegisterPlayWelcomeSound", player) 
            triggerClientEvent("onPlayerFirstTimeSeen", player) 
            triggerClientEvent("onPlayerDoneLogin", player) 
            setTimer(triggerClientEvent, 3000, 1, "onPlayerPlayUEFASound", player, false)           
        else 
            reason = "The Account already exists!" 
            triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
        end 
    else 
        reason = "The Account already exists!" 
        triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) 
    end 
end 
addEvent("onClientSendRegisterDataToServer", true) 
addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer) 
  
function saveTheLogins( thePlayerName, theLogin ) 
    if ( fileExists( "logins.txt" ) ) then 
        local file = fileCreate( "logins.txt" ) 
        if( file )then 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n") 
            fileClose( file ) 
        end 
    else 
        local file = fileOpen( "logins.txt" ) 
        if ( file ) then 
            fileSetPos( file, fileGetSize( file ) ) 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n" ) 
        end 
    end 
end 

Link to comment

Well i get this error

login_server.lua:83: fileOpen; unable to load file

THAT IS THE FUNCTION WHERE I GET THE ERROR

Line 83 ==> local file = fileOpen( "logins.txt" )

function saveTheLogins( thePlayerName, theLogin ) 
    if ( fileExists( "logins.txt" ) ) then 
        local file = fileCreate( "logins.txt" ) 
        if( file )then 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n") 
            fileClose( file ) 
        end 
    else 
        local file = fileOpen( "logins.txt" ) 
        if ( file ) then 
            fileSetPos( file, fileGetSize( file ) ) 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n" ) 
        end 
    end 
end 

Link to comment
  • Moderators

Yeah sorry, my bad:

function saveTheLogins( thePlayerName, theLogin ) 
    if ( not fileExists( "logins.txt" ) ) then 
        local file = fileCreate( "logins.txt" ) 
        if( file )then 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n") 
            fileClose( file ) 
        end 
    else 
        local file = fileOpen( "logins.txt" ) 
        if ( file ) then 
            fileSetPos( file, fileGetSize( file ) ) 
            fileWrite( file, " The player "..thePlayerName.." have been registered with the login "..theLogin.."\r\n" ) 
        end 
    end 
end 

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