Answer the question
In order to leave comments, you need to log in
MTA (Multi Theft Auto) LUA - Why does it return 0 or false?
Hello. The problem is:
There is a code
function playerRegister(login, password)
local player = source
local mynick getPlayerName(source)
local mylogin = getAccount(login)
local mypassword = getAccount(password)
if not getAccount(login) then
addAccount(login, password)
dbQuery(db, "INSERT INTO users(login, nickname, password, status, hp, money, level) VALUES(" .. tostring( mylogin ) .. ", " .. tostring( mynick ) .. ", " .. tostring( mypassword ) .. ", 1, 100, 1500, 16)")
outputChatBox('Аккаунт успешно создан.', player)
else
outputChatBox('Аккаунт с таким логином существует!', player)
end
end
addEvent('playerRegister', true)
addEventHandler('playerRegister', root, playerRegister)
Answer the question
In order to leave comments, you need to log in
The problem could be anything .
There is no need to guess and puzzle. Get into debugging .
function playerRegister(login, password)
outputChatBox('Enter playerRegister...')
outputChatBox('login=',login,' password=',password)
local player = source
outputChatBox('player=',player)
local mynick getPlayerName(source)
outputChatBox('mynick=',mynick)
local mylogin = getAccount(login)
outputChatBox('mylogin=',mylogin)
local mypassword = getAccount(password)
outputChatBox('mypassword=',mypassword)
if not getAccount(login) then
outputChatBox('Creatre new account (' .. tostring(login) .. ')...')
addAccount(login, password)
outputChatBox('dbQuery:')
local query = "INSERT INTO users(login, nickname, password, status, hp, money, level) VALUES("
.. tostring( mylogin ) .. ", " .. tostring( mynick ) .. ", " .. tostring( mypassword ) .. ", 1, 100, 1500, 16)"
outputChatBox(query)
dbQuery(db, query)
outputChatBox('Аккаунт успешно создан.', player)
else
outputChatBox('Аккаунт с таким логином существует!', player)
end
end
addEvent('playerRegister', true)
addEventHandler('playerRegister', root, playerRegister)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question