Jump to content

[HELP] What is wrong with this!?


..:D&G:..

Recommended Posts

PLEASE someone tell me what is wrong with this before I go nuts!

function checkLoginCreditals(name, pass) 
    local result = db:query( "SELECT * FROM users WHERE name ='"..name.."'") 
    if result then 
        if md5(pass) == tostring(result[1]['password']) then 
            return true 
        else 
            return false 
        end 
    end 
    return false 
end 

It outputs the password and username as it should, but from line 3 onwards it doesn't work....

I've used THE SAME THING, in another function and it works perfectly!

function setPlayerDatas(player, accountName) 
    local result = db:query("SELECT * FROM users WHERE name = '"..accountName.."'") 
    if result then 
        setData(player, "deaths", tonumber(result[1]['deaths'])) 
        setData(player, "woodHarvested", tonumber(result[1]['woodHarvested'])) 
        setData(player, "kills", tonumber(result[1]['kills'])) 
        setData(player, "accountName", tostring(accountName)) 
    end 
end 
addEvent("setPlayerDatas", true) 
addEventHandler("setPlayerDatas", getRootElement(), setPlayerDatas) 

So what the hell is wrong with the first function? -.-

Link to comment

I managed to find the problem, but I am so pissed that I can't figure out how to solve it :@

So if I do this:

outputDebugString(""..userName.."WORD") 

it comes up as: INFO: Username WORD, now how do I remove the space at the end of the username so I have the username and 'WORD' joined together?

Link to comment

If you still need help, here you go.

outputDebugString(userName.."WORD") 
-- output --> INFO: Username WORD 
  
-- Use string.gsub to remove spaces, so it will be like that, 
local userName = string.gsub(userName, " ", "") 
outputDebugString(userName.."WORD") 
-- output --> INFO: UsernameWORD 
  

Link to comment
If you still need help, here you go.
outputDebugString(userName.."WORD") 
-- output --> INFO: Username WORD 
  
-- Use string.gsub to remove spaces, so it will be like that, 
local userName = string.gsub(userName, " ", "") 
outputDebugString(userName.."WORD") 
-- output --> INFO: UsernameWORD 
  

I managed to solve it. It was because I used guiCreateMemo which adds a space at the end regardless of what I am doing to the word. So I switched to guiCreateEdit and it works fine.

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