local sNU = query("SELECT * FROM userinfo WHERE nickname = '"..tostring(inputs1).."'")
local sNU = query("SELECT * FROM userinfo WHERE nickname = 'testTest123'")
sNU[0]
возвращает nil local dbHost = 'localhost'
local dbName = 'test'
local dbUsername = 'root'
local dbPassword = ''
function query(...)
local queryHandle = dbQuery(dbConnect('mysql','host='..dbHost..';dbname='..dbName, dbUsername, dbPassword), ...)
if (not queryHandle) then
return nil
end
local rows = dbPoll(queryHandle, -1)
return rows
end
addEventHandler("onResourceStart", resourceRoot, function()
local usrSerial = "4AF00E3E63A0DB4C3C5E4E8FE4560DB4"
local inputs1 = "testTest123"
local inputs2 = "testPswd123"
local addA = query("INSERT INTO userinfo (serial, nickname, password) VALUES ('"..tostring(usrSerial).."','"..tostring(inputs1).."','"..tostring(inputs2).."')")
if(addA) then
outputDebugString('INSERT Success')
local sNU = query("SELECT * FROM userinfo WHERE nickname = '"..tostring(inputs1).."'") -- ищем игрока в базе по имени
if (sNU) then
outputDebugString('SELECT Success')
for _, row in ipairs(sNU) do -- перебираем данные из базы
posX = row['posX'] -- позичия X
posY = row['posY'] -- позичия Y
posZ = row['posZ'] -- позичия Z
usrHealth = row['health'] -- здоровье
w11 = row['w11'] -- 11 слот оружия
usrTeam = row['team'] -- команда
usrSkinID = row['skin'] -- скин
usrMoney = row['money'] -- деньги
usrArmor = row['armor'] -- броня
outputDebugString('posX: '..posX)
outputDebugString('posY: '..posY)
outputDebugString('posZ: '..posZ)
outputDebugString('usrHealth: '..usrHealth)
outputDebugString('w11: '..w11)
outputDebugString('usrTeam: '..usrTeam)
outputDebugString('usrSkinID: '..usrSkinID)
outputDebugString('usrMoney: '..usrMoney)
outputDebugString('usrArmor: '..usrArmor)
end
else
outputDebugString('SELECT Failed')
end
else
outputDebugString('INSERT Failed')
end
end)
setTimer(function() end, 1000, 1)
[34m[2017-06-29 10:07:17.992] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:07:18.951] [TRACE] [default] - [39mParsing finished 959ms.
[34m[2017-06-29 10:07:20.362] [TRACE] [default] - [39mUpdated 1348 items
[34m[2017-06-29 10:07:20.362] [TRACE] [default] - [39mLeave time: 2370 ms.
[34m[2017-06-29 10:07:20.362] [TRACE] [default] - [39mTotal items: 4880
[34m[2017-06-29 10:07:33.004] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:07:33.151] [TRACE] [default] - [39mParsing finished 147ms.
[33m[2017-06-29 10:07:33.151] [WARN] [default] - [39mSite unavailable
[34m[2017-06-29 10:07:48.016] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:07:48.170] [TRACE] [default] - [39mParsing finished 154ms.
[33m[2017-06-29 10:07:48.170] [WARN] [default] - [39mSite unavailable
[34m[2017-06-29 10:08:03.020] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:08:03.177] [TRACE] [default] - [39mParsing finished 157ms.
[33m[2017-06-29 10:08:03.178] [WARN] [default] - [39mSite unavailable
[34m[2017-06-29 10:08:18.034] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:08:18.205] [TRACE] [default] - [39mParsing finished 171ms.
[33m[2017-06-29 10:08:18.205] [WARN] [default] - [39mSite unavailable
[34m[2017-06-29 10:08:33.046] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:08:33.186] [TRACE] [default] - [39mParsing finished 140ms.
[33m[2017-06-29 10:08:33.186] [WARN] [default] - [39mSite unavailable
[34m[2017-06-29 10:08:48.059] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:08:48.995] [TRACE] [default] - [39mParsing finished 936ms.
[34m[2017-06-29 10:08:50.363] [TRACE] [default] - [39mUpdated 1347 items
[34m[2017-06-29 10:08:50.363] [TRACE] [default] - [39mLeave time: 2304 ms.
[34m[2017-06-29 10:08:50.363] [TRACE] [default] - [39mTotal items: 4882
[34m[2017-06-29 10:09:03.071] [TRACE] [default] - [39mParsing launched
[34m[2017-06-29 10:09:04.057] [TRACE] [default] - [39mParsing finished 986ms.
[34m[2017-06-29 10:09:06.258] [TRACE] [default] - [39mUpdated 1347 items
[34m[2017-06-29 10:09:06.258] [TRACE] [default] - [39mLeave time: 3187 ms.
[34m[2017-06-29 10:09:06.258] [TRACE] [default] - [39mTotal items: 4882