PlayHard Posted March 4, 2014 Share Posted March 4, 2014 (edited) всем привет. не могу подключиться к своей db в mysql. дело в том что я все делал правильно. пробовал разные способы. различные скрипты. и нечего не получается. начну по порядку. сделал db. через VertrigoServ. сунул туда sql сервера. вроде все. потом прописал в скрипте коннект к моей db. запустил сервер но db не конектится. вот логи [2014-03-04 21:18:38] start: Resource 'reallife' start was requested () [2014-03-04 21:18:38] Stopping play [2014-03-04 21:18:38] Stopping freeroam [2014-03-04 21:18:39] Starting reallife [2014-03-04 21:18:39] ERROR: [gamemodes]\reallife\autohandler\auto.lua:199: attempt to call global 'mysql_query' (a nil value) [2014-03-04 21:18:40] ERROR: [gamemodes]\reallife\firma\firma_server.lua:4: attempt to call global 'mysql_query' (a nil value) [2014-03-04 21:18:40] ERROR: [gamemodes]\reallife\prestige\prestige_s.lua:23: attempt to call global 'mysql_query' (a nil value) вот sql скрипт -- HERE MYSQL SETTINGS CHANGE -- mysql = {} mysql["host"] = "127.0.0.1" mysql["username"] = "root" mysql["password"] = "" mysql["database"] = "dbs_reallife" handler = mysql_connect ( mysql["localhost"], mysql["root"], mysql[""], mysql["dbs_reallife"]) -- Global connection if not(handler) then error("MySQL Verbindung nicht akzeptiert! Fahre runter...") end housesystem_resource_name = "bf-housesystem" reallife_resource_name = "bfreallife" function setOfflineNachricht(thePlayer, nachricht) if(type(thePlayer) == "string") then if(isElement(getPlayerFromName(thePlayer))) then outputChatBox(nachricht, getPlayerFromName(thePlayer), 200, 200, 0) else mysql_query(handler,"UPDATE accounts SET OFFLINEMSG = '"..nachricht.."' WHERE NAME = '"..thePlayer.."'") end else if(isElement(thePlayer)) then outputChatBox(nachricht, thePlayer, 200, 200, 0) else mysql_query(handler,"UPDATE accounts SET OFFLINEMSG = '"..nachricht.."' WHERE NAME = '"..getPlayerName(thePlayer).."'") end end end local fadeP = {} function setInPosition(thePlayer, x, y, z, interior, typ) if not(thePlayer) then return end if (getElementType(thePlayer) == "vehicle") then return end if(isPedInVehicle(thePlayer)) then return end if not(x) or not(y) or not(z) then return end if not(interior) then interior = 0 end if(fadeP[thePlayer] == 1) then return end fadeP[thePlayer] = 1 fadeCamera(thePlayer, false) setElementFrozen(thePlayer, true) setTimer( function() fadeP[thePlayer] = 0 setElementPosition(thePlayer, x, y, z) setElementInterior(thePlayer, interior) fadeCamera(thePlayer, true) if not(typ) then setElementFrozen(thePlayer, false) else if(typ == true) then setTimer(setElementFrozen, 1000, 1, thePlayer, false) end end end, 1000, 1) end function o_removePedFromVehicle(thePlayer) -- Total Scheisse -- if not(thePlayer) then return end if not(getElementType(thePlayer) == "player") then return end local state = getPedOccupiedVehicleSeat ( thePlayer) if(state == 0) or (state == 2) then removePedFromVehicle(thePlayer) local x, y, z = getElementPosition(thePlayer) setElementPosition(thePlayer, x, y-1, z) setTimer(setPedAnimation, 500, 1, thePlayer, "ped", "CAR_getout_LHS", 1000, false, true, true) else removePedFromVehicle(thePlayer) local x, y, z = getElementPosition(thePlayer) setElementPosition(thePlayer, x, y+1, z) setTimer(setPedAnimation, 500, 1, thePlayer, "ped", "CAR_getout_RHS", 1000, false, true, true) end end function getWeaponSlotMuniMats(weapon) local muni = 0 if(weapon == getWeaponIDFromName("Colt 45")) then muni = 34 end if(weapon == getWeaponIDFromName("Deagle")) then muni = 14 end if(weapon == getWeaponIDFromName("Shotgun")) then muni = 5 end if(weapon == getWeaponIDFromName("MP5")) then muni = 50 end if(weapon == getWeaponIDFromName("AK-47")) then muni = 50 end if(weapon == getWeaponIDFromName("Knife")) then muni = 1 end if(weapon == getWeaponIDFromName("Rifle")) then muni = 5 end return muni; end function giveVehicleBetterEngine(theVehicle) if(getElementType(theVehicle) == "vehicle") then local sucess1 = setVehicleHandling(theVehicle, "engineAcceleration", (getVehicleHandling(theVehicle)['engineAcceleration']+5)) local sucess2 = setVehicleHandling(theVehicle, "maxVelocity", (getVehicleHandling(theVehicle)['maxVelocity']+15)) if(sucess1) and (sucess2) then return true; else return false; end end return false; end function giveVehiclePanzerung(theVehicle) if(getElementType(theVehicle) == "vehicle") then if(tonumber(getVehicleHandling(theVehicle)['collisionDamageMultiplier']) < 0.3) then setVehicleHandling(theVehicle, "collisionDamageMultiplier", 0) else setVehicleHandling(theVehicle, "collisionDamageMultiplier", (getVehicleHandling(theVehicle)['collisionDamageMultiplier']-0.3)) end end end Edited March 4, 2014 by Guest Link to comment
Other Languages Moderators Disinterpreter Posted March 4, 2014 Other Languages Moderators Share Posted March 4, 2014 Обычно attempt to call global 'mysql_query' (a nil value) говорит о том, что функция не существует, возможно, вы не подключили этот модуль. Link to comment
TheNormalnij Posted March 4, 2014 Share Posted March 4, 2014 Теги, табуляция, спойлеры... К черты все. У тебя не загружен модуль MTA-MySQL Link to comment
PlayHard Posted March 4, 2014 Author Share Posted March 4, 2014 спасибо. все было и так сделано только не прописано в mta.conf. теперь еще одна ошибка. как я понял mysql подключен только я что то напутал в коннекте с сервером. [2014-03-05 01:52:35] MODULE: Loaded "MySQL 5.0 database module" (0.50) by "Alberto Alonso " [2014-03-05 01:53:12] ERROR: [gamemodes]\reallife\server\settings.lua:8: bad argument #1 to 'mysql_connect' (string expected, got nil) [2014-03-05 01:53:12] ERROR: [gamemodes]\reallife\autohandler\auto.lua:199: bad argument #1 to 'mysql_query' (mysqlHandler expected, got nil) [2014-03-05 01:53:13] ERROR: [gamemodes]\reallife\frakt.lua:62: attempt to call global 'giveVehicleBetterEngine' (a nil value) вот скрипт -- HERE MYSQL SETTINGS CHANGE -- mysql = {} mysql["host"] = "127.0.0.1" mysql["username"] = "root" mysql["password"] = "" mysql["database"] = "dbs_reallife" handler = mysql_connect ( mysql["localhost"], mysql["root"], mysql[""], mysql["dbs_reallife"]) -- Global connection if not(handler) then Link to comment
Elengar Posted March 4, 2014 Share Posted March 4, 2014 спасибо. все было и так сделано только не прописано в mta.conf. теперь еще одна ошибка. как я понял mysql подключен только я что то напутал в коннекте с сервером. [2014-03-05 01:52:35] MODULE: Loaded "MySQL 5.0 database module" (0.50) by "Alberto Alonso " [2014-03-05 01:53:12] ERROR: [gamemodes]\reallife\server\settings.lua:8: bad argument #1 to 'mysql_connect' (string expected, got nil) [2014-03-05 01:53:12] ERROR: [gamemodes]\reallife\autohandler\auto.lua:199: bad argument #1 to 'mysql_query' (mysqlHandler expected, got nil) [2014-03-05 01:53:13] ERROR: [gamemodes]\reallife\frakt.lua:62: attempt to call global 'giveVehicleBetterEngine' (a nil value) вот скрипт -- HERE MYSQL SETTINGS CHANGE -- mysql = {} mysql["host"] = "127.0.0.1" mysql["username"] = "root" mysql["password"] = "" mysql["database"] = "dbs_reallife" handler = mysql_connect ( mysql["localhost"], mysql["root"], mysql[""], mysql["dbs_reallife"]) -- Global connection if not(handler) then Учитесь читать логи, а не просто скидывать их сюда. [2014-03-05 01:53:12] ERROR: [gamemodes]\reallife\server\settings.lua:8: bad argument #1 to 'mysql_connect' (string expected, got nil) Написано: плохой первый аргумент при вызове "mysql_connect"(ожидается string, но вместо string - nil) Собсна, в чем проблема, ты в функции берешь данные из таблицы выше, но ты их берешь не по ключу, а не понятно как по значению. Либо сделай вот так: mysql_connect ( "localhost", "root", "", "dbs_reallife") и вписывай данные сразу в вызов. Либо же так: mysql_connect ( mysql["host"], mysql["username"], mysql["password"], mysql["database"]) и вписывай данные в таблицу mysql . Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now