Jump to content

Need Help with that little Problem!


Maurize

Recommended Posts

Posted

So take a look at this, simply doenst make anything -.-

Showing GUI & all, but I can insert every password like "nose" and login, even the true password is "uncle" -.-

Can you see a mistake?

addEvent( "onDataRegister", true ) 
addEventHandler( "onDataRegister", rootMain, 
function( code ) 
    local weapon = { 2, 3, 5, 6, 7 } 
    local user = getPlayerName( source ) 
    local db = executeSQLSelect( "DatabaseValues", "*", "Name = '"..user.."'" ) 
    local dbw = executeSQLSelect( "DatabaseWeapon", "*", "Name = '"..user.."'" ) 
if db and #db == 1 then 
if ( code == db[1]["Code"] ) then 
spawnPlayer( source, 2311.2, -9.4, 26.4, 0, db[1]["Skin"] ) 
    giveWeapon( source, math.random( weapon[1], weapon[5] ), 1 ) 
    setPlayerMoney( source, db[1]["Geld"] ) 
    setElementHealth( source, db[1]["HP"] ) 
    setPedArmor( source, db[1]["AP"] ) 
    setCameraTarget( source, source ) 
    fadeCamera( source, true, 3.0 ) 
else 
    outputChatBox( "Falsches Passwort", source ) 
    end 
else 
    executeSQLInsert( "DatabaseValues", "'"..user.."', '"..code.."', '100', '0', '0', '78', '0', '0'" ) 
    spawnPlayer( source, 2311.2, -9.4, 26.4, 0, 78 ) 
    setCameraTarget( source, source ) 
    fadeCamera( source, true, 3.0 ) 
    end 
end ) 

and here clientside:

  
local x, y =  guiGetScreenSize() 
local guiElement1 = guiCreateWindow( x / 2 - 181, y / 2 - 43, 262, 86, "Identification Terminal ",false ) guiSetVisible( guiElement1, false ) 
local guiElement2 = guiCreateLabel( 8, 25, 248, 19, "User ID: "..getPlayerName( rootData ).."#"..math.random( 0, 10000 ), false, guiElement1 ) 
local guiElement3 = guiCreateLabel( 9, 53, 57, 17, "Code ID:", false, guiElement1 ) 
local guiElement4 = guiCreateEdit( 68, 48, 186, 30, "", false, guiElement1 ) 
guiSetFont( guiElement2, "clear-normal" ) 
guiSetFont( guiElement3, "clear-normal" ) 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
    guiSetVisible( guiElement1, true ) 
    showCursor( true ) 
    fadeCamera( false, 0.5, 255, 255, 255 ) 
    bindKey( "enter", "down", 
function() 
    local data = guiGetText( guiElement3 ) 
if ( data ) then 
    local code = tostring( data ) 
    triggerServerEvent( "onDataRegister", rootData, code ) 
else 
    outputChatBox( "No Inputdata found." ) 
        end 
    end ) 
end ) 

Posted
addEvent( "onDataRegister", true ) 
addEventHandler( "onDataRegister", rootMain, 
function( code ) 
    local weapon = { 2, 3, 5, 6, 7 } 
    local user = getPlayerName( source ) 
    local db = executeSQLSelect( "DatabaseValues", "*", "Name = '"..user.."'" ) 
    local dbw = executeSQLSelect( "DatabaseWeapon", "*", "Name = '"..user.."'" ) 
    if (db and #db == 1) then 
        if ( tostring(db[1]["Code"]) ~= tostring(code) ) then outputChatBox( "Falsches Passwort", source ) return end 
        spawnPlayer( source, 2311.2, -9.4, 26.4, 0, db[1]["Skin"] ) 
        giveWeapon( source, math.random( weapon[1], weapon[5] ), 1 ) 
        setPlayerMoney( source, db[1]["Geld"] ) 
        setElementHealth( source, db[1]["HP"] ) 
        setPedArmor( source, db[1]["AP"] ) 
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 3.0 ) 
    else 
        executeSQLInsert( "DatabaseValues", "'"..user.."', '"..code.."', '100', '0', '0', '78', '0', '0'" ) 
        spawnPlayer( source, 2311.2, -9.4, 26.4, 0, 78 ) 
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 3.0 ) 
    end 
end ) 

P.S: You're not encrypting the password with MD5?

P.S2: You're triggering the register event to getRootElement?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

First sure this is for testing, to see if password get's saved and so on.

Then, sry forgot : local rootMain = getRootElement()

and then, solidsnake, if a player only enters numbers, the next time he trys to login fails, and says no password, but it is in database :oo this is weird, you know why?

Posted

In your client side, you do this:

triggerServerEvent( "onDataRegister", rootData, code ) 

What is "rootData"? because if it's not a player, 'source' in server-side will be..?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

on client side, getLocalPlayer is rootData, too, to prevent me for typing to much ;D

//

Still doens't say wrong password, on wrong password -.-

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