Jump to content

MySQL and textdraw problem


flashman

Recommended Posts

Posted

Hi.

I made a GUI with the GUIcreator and used some other script to make the login button.

Client:

        GUIEditor.window[1] = guiCreateWindow(0.37, 0.28, 0.23, 0.35, "", true) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(0.03, 0.85, 0.46, 0.11, "LOGIN", true, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF7F7D7D") 
        GUIEditor.button[2] = guiCreateButton(0.51, 0.85, 0.45, 0.11, "REGISTER", true, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(0.12, 0.72, 0.78, 0.08, "", true, GUIEditor.window[1]) 
        guiEditSetMasked(GUIEditor.edit[1], true) 
        GUIEditor.label[1] = guiCreateLabel(0.40, 0.67, 0.22, 0.04, "Password:", true, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[1], "default-bold-small") 
        GUIEditor.staticimage[1] = guiCreateStaticImage(0.03, 0.06, 0.93, 0.43, ":guieditor/images/examples/mtalogo.png", true, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(0.12, 0.56, 0.78, 0.08, "", true, GUIEditor.window[1]) 
        guiEditSetMasked(GUIEditor.edit[2], true) 
        GUIEditor.label[2] = guiCreateLabel(0.40, 0.52, 0.22, 0.04, "Username:", true, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[2], "default-bold-small")     
  
function playerJoin() 
    guiSetVisible(GUIEditor.window[1], true ) 
    showCursor( true ) 
    guiSetInputEnabled( true ) 
    setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) 
    fadeCamera (true) 
end 
  
addEvent("onJoin", true) 
addEventHandler("onJoin", getRootElement(), playerJoin) 
  
function closeWindow() 
    guiSetVisible(GUIEditor.window[1], false ) 
    showCursor( false ) 
    guiSetInputEnabled( false ) 
end 
addEvent("closeWindow", true) 
addEventHandler("closeWindow", getRootElement(), closeWindow) 
  
function login_player ( source ) 
        triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player,false) 

Server:

-- Default 
host = "127.0.0.1" -- Database Host 
username = "root" -- Database Username 
password = "" -- Database Password 
db = "accounts" -- Database ( Where you got your tables ) 
  
handler = mysql_connect( host, username, password, db ) 
  
addEventHandler("onPlayerJoin", getRootElement(), 
    function() 
        triggerClientEvent(source, "onJoin", getRootElement()) 
    end 
) 
  
function onLogin ( player, user, pass ) 
    handler = mysql_connect( host, username, password, db ) 
    local login = mysql_query(handler,"SELECT * FROM account_data WHERE AccountName = '"..mysql_escape_string( handler, user ).."' AND Password = '"..mysql_escape_string( handler, md5(pass) ).."';") 
    if login then 
        local rows = mysql_num_rows(login) 
        if rows == 1 then 
            triggerClientEvent( player, "closeWindow", getRootElement() ) 
            outputChatBox("* You successfully logged in your account!", player, 255, 255, 255) 
            spawnPlayer( player, 0,0,3 )  
            fadeCamera( player, true ) 
            setCameraTarget( player, player ) 
        else 
            outputChatBox("* Login failed!", player, 255, 255, 255) 
        end 
        mysql_free_result(login) 
    end 
end 
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  

Meta:

        type="script"  author="Risto" name="Login Register System (MySQL)" version="1.0"/> 
        

But when I go in game no gui is displayed for me.

Posted

Where's "GUIEditor" table defined?

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

I cant understand you very well..

this is all the files I have, I just copy the gui from GUIeditor.

C:\Program Files (x86)\MTA San Andreas 1.3\server\mods\deathmatch\resources\guieditor

C:\Program Files (x86)\MTA San Andreas 1.3\server\mods\deathmatch\resources\loginsystem

Posted

The client side you posted is all you got? if so, then you've got missing the GUIeditor table generated along with the GUI.

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 (edited)

Thank you very much, Castillo.

I don't know why, but I had deleted the part. I really appreciate that you found some time to help me :fadein:

Edited by Guest
Posted

You're welcome.

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

Hi:

GUIEditor = { 
    staticimage = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(0.37, 0.28, 0.23, 0.35, "", true) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(0.03, 0.85, 0.46, 0.11, "LOGIN", true, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF7F7D7D") 
        GUIEditor.button[2] = guiCreateButton(0.51, 0.85, 0.45, 0.11, "REGISTER", true, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(0.12, 0.72, 0.78, 0.08, "", true, GUIEditor.window[1]) 
        guiEditSetMasked(GUIEditor.edit[1], true) 
        GUIEditor.label[1] = guiCreateLabel(0.40, 0.67, 0.22, 0.04, "Password:", true, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[1], "default-bold-small") 
        GUIEditor.staticimage[1] = guiCreateStaticImage(0.03, 0.06, 0.93, 0.43, ":loginsystem/mtalogo.png", true, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(0.12, 0.56, 0.78, 0.08, "", true, GUIEditor.window[1]) 
        guiEditSetMasked(GUIEditor.edit[2], false)--username 
        GUIEditor.label[2] = guiCreateLabel(0.40, 0.52, 0.22, 0.04, "Username:", true, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[2], "default-bold-small")     
    end 
) 
     
  
function playerJoin() 
    guiSetVisible(GUIEditor.window[1], true ) 
    showCursor( true ) 
    guiSetInputEnabled( true ) 
    setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) 
    fadeCamera (true) 
    outputChatBox("Player joined.") 
end 
  
addEvent("onJoin", true) 
addEventHandler("onJoin", getRootElement(), playerJoin) 
  
function closeWindow() 
    guiSetVisible(GUIEditor.window[1], false ) 
    showCursor( false ) 
    guiSetInputEnabled( false ) 
end 
addEvent("closeWindow", true) 
addEventHandler("closeWindow", getRootElement(), closeWindow) 
  
function login_player ( source ) 
        outputChatBox("Player clicked on login button, executing server part.") 
        triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player, false) -- button 2 is username 
  

That part is not working: "outputChatBox("Player clicked on login button, executing server part.")". The message does not get sent, but the join message does, what's wrong?

Posted
addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player, false) -- button 2 is username 

That has to go inside the onClientResourceStart function.

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.

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