Jump to content

Please help


Recommended Posts

Posted

Hello i find my old scriprs and i cant use it anymore because outdated and i thinking to remake it but i stock on some parts please help , about how to replace to the new mysql part

i try it on some one but still not works ;(

-- Default 
host = "127.0.0.1" -- Database Host 
username = "root" -- Database Username 
password = "" -- Database Password 
db = "accounts" -- Database ( Where you got your tables ) 
  
handler = dbConnect("mysql", host, username, password, db ) 
  
if handler then 
    outputChatBox("sikeres csatlakozas") else 
    outputChatBox("nem sikerult csatlakozni a mysql hez!") 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), 
    function() 
        triggerClientEvent(source, "onJoin", getRootElement()) 
    end 
) 
  
function onLogin ( player, user, pass ) 
    handler = dbConnect("mysql", host, username, password, db ) 
    local login = dbQuery(handler,"SELECT * FROM accounts 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 ) 
  

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Seems like this uses the MySQL module, do you have this installed?

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Well, if you don't have the module installed, these functions do not exist;

mysql_escape_string 
mysql_num_rows 
mysql_free_result 

What code is on Line 22? This?

function onLogin ( player, user, pass ) 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Yeah, I understood that, I simply said that you still have functions which belong to the MySQL Module in your code. Those will return nil errors because the function doesn't exist.

I also need to know what code is on Line 22. :D

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

This is my 22. line

   local login = dbQuery(handler,"SELECT * FROM accounts WHERE AccountName = '"..mysql_escape_string( handler, user ).."' AND Password = '"..mysql_escape_string( handler, md5(pass) ).."';") 

560x95_FFFFFF_FF9900_000000_000000.png

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