Jump to content

=KoG=Rouche

Members
  • Posts

    220
  • Joined

  • Last visited

Everything posted by =KoG=Rouche

  1. Thanks it works now I've a new problem. I try to check if the user is already registered in the database but it seems that it's not working. When i try to outputDebugString the "compare" var it says "Excpected String at argument 1, got nil" So i think i don't use the dbPoll very well. Can someone help me ? -- Check if a user already exsit in database function checkIfUserExist() outputDebugString("Check if in checkIfUserExist Function - OK") local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) local result = dbPoll(query, -1) local compare = result[1] outputDebugString(compare) if compare then local compAccount = compare.account outputDebugString(compAccount) if compAccount == account then return 1 -- User already exist in DB else return 0 -- User doesn't exist in DB end else return 0 end end Thanks.
  2. It's a dedicated server (OVH) and i tried to upgrade my 1.3 server to 1.4. It works for a random time and then black screen with maps that doesn't load. I downgraded the server to 1.3 to make it work.
  3. Hi all, i got this problem when i try to create the entry in my DB. DbExec failed; (1048) column "bMonth" could not be null. In the code bellow u can see that i initialize "bMonth" to 0 ...so what's wrong ? :-/ -- INSERT TO (Add an entity in player table) local bDay,bMonth,bYear,level,VIP,achievementPoints,token,tokenBought = 0 local mail,welcomeText = "none" dbExec(connect,"INSERT INTO Player (account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) VALUES (?,?,?,?,?,?,?,?,?,?,?)",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) outputDebugString("An entity in Player Table has been Created - OK") Thanks for your help. =KoG=Rouche
  4. Hi all i got some problem with this update. I'm the owner of server =KoG= using Race mod. I tried to update to 1.4 and i've a problem. When i join the server, the resource of the map start and it only display a black screen. I can heard the music of the map and the download progress has no problem. I think there is a problem with the "Spawn" of the player on the map. They only see a black screen without any errors in Debugscript 3. Thanks for help.
  5. Now i got this error. [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil] [19:00:47] WARNING: [gamemodes]/[race]/[addons]/panel/server.lua:105: Bad argume nt @ 'getElementData' [Expected element at argument 1, got nil]
  6. I don't understand this part. Can you explain ? local _getElementData = getElementData function getElementData ( plr, group ) return tostring ( _getElementData ( plr, group ) ) end
  7. Hi all i've a problem with my SQL syntax. Can someone help me ? function updateDB(playerAccount) ... -- Update Player Table local mail = getElementData(localPlayer,"temp.mail") local bDay = getElementData(localPlayer,"temp.bDay") local bMonth = getElementData(localPlayer,"temp.bMonth") local bYear = getElementData(localPlayer,"temp.bYear") local level = getElementData(localPlayer,"temp.level") local VIP = getElementData(localPlayer,"temp.VIP") local welcomeText = getElementData(localPlayer,"temp.welcomeText") local achievementPoints = getElementData(localPlayer,"temp.achivementPoints") local token = getElementData(localPlayer,"temp.token") local tokenBought = getElementData(localPlayer,"temp.tokenbought") dbExec(connect,"UPDATE 'Player' (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) SET (?,?,?,?,?,?,?,?,?,?) WHERE account=?",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought,playerAccount) outputDebugString("Player Table has been Updated - OK") ... end Error Message : [15:52:55] WARNING: @[gamemodes]/[race]/[addons]/panel/server.lua:120: dbExec failed; (1064) You ha ve an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Player' (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoin ts,token,to' at line 1 Thanks.
  8. I've another problem now But count seems to be correct 0.o Error : [12:02:57] WARNING: @[gamemodes]/[race]/[addons]/panel/server.lua:75: dbExec fai led; (1136) Column count doesn't match value count at row 1 Code : dbExec(connect,"INSERT INTO Player VALUES (?,?,?,?,?,?,?,?,?,?,?)",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) Thanks for your help.
  9. Its not working. Error Message : WARNING: @[gamemodes]/[race]/[addons]/panel/server.lua:75: dbExec fai led; (1064) You have an error in your SQL syntax; check the manual that correspo nds to your MySQL server version for the right syntax to use near 'account=0,mai l='none',bDay=0,bMonth='',bYear='',level='',VIP='',welcomeText='',a' at line 1 Code : dbExec(connect,"INSERT INTO Player VALUES account=?,mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenbought=?",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) What's wrong ? Thanks.
  10. It says it's not correct. What is my error ? dbExec(connect,"UPDATE Player (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) SET mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenBought=? WHERE account =?",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought,quittingPlayerAccount) Thanks.
  11. Hi all, I'm working on a Lobby Script running on my Lobby Server. This lobby must redirect players to the other servers (DM, OLD, Shooter and Training). 1. Lobby Is it possible to display the number of player online from all servers on the lobby server choice panel ? How to query these informations from other servers (DM, OLD, Shooter and Training) to the lobby server ? 2. Cadena Then i would like to "lock" the different servers (DM, OLD, Shooter and Training) and let only the Lobby Server unlocked. Is it possible to lock a server which is joinable only via the lobby server with his choice server panel ?
  12. If i've more arguments it will work like that ? dbExec(connect,"UPDATE Player (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) SET (mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenBought=?) WHERE account = '"..quittingPlayerAccount.."'",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) Thanks for your Help.
  13. Hi all I explain my situation. I'm creating an userpanel with MySQL Database. Step By Step 1. When the player login (Go to 2 if already exist in DB else go to 1.1) 1.1 - Create the initialized tables in the Database and then go to 2 2. Read the data from database (serverside) and send the results clientside. 3. A triggered Clientside function add all the values from serverside to the Element (Player) with setElementData. setElementData(root,"temp.account",playerData.account) Right now can i use the getElementData(source,temp.account) both clientside and serverside ? 4. When the player quit i want to save datas to Database. (Serverside) dbExec(connect,"UPDATE Player (account) VALUES ('"..getElementData(source,"temp.account").."') Is it correct ? Thanks for your help.
  14. Just change this triggerClientEvent(thePlayer,"onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) to this triggerClientEvent("onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) and it works now I'll now try to make it work with the "onPlayerLogin" event. Get the account, create DB record if not yet done and read datas or read datas if already created and send it all to Clientside. Juste one question. What is the best way to manage datas and DB ? I mean ... - Must i trigger a serverside query to database each time a player interact with a data ? (winCash, winMap, lostRoll, LostBet, got an achievement, ...). I think it can easily overload the DB. - Must i use the function updateDatasToDB (to write clientside datas to DB) and readDatasFromDB (query datas from DB and send it clientside) in a laps of time (Every 20 seconds for example). In this case clientside variables are updated for all interactions from theplayer (winCash, winMap, lostRoll, LostBet, got an achievement, ...). - Must i use updateDatasToDB (to write current clientside datas to DB) every 20 seconds and readDatasFromDB (query datas from DB and send it clientside) each time the player open the userpanel ? In this case clientside variables are updated for all interactions from theplayer (winCash, winMap, lostRoll, LostBet, got an achievement, ...).
  15. It was working before 0.o function connectDB() local con = dbConnect("mysql","dbname=DBNAME;host=IP", "USERNAME", "PASSWORD", "share=1") if (con) then outputDebugString("Connection OK !") else outputDebugString("Connection to Database failled !") end return con end -- Call the function to create a Connection Object function initVar() connect = connectDB() end addEventHandler("onResourceStart",root,initVar)
  16. I've an error when the test player "blabla" login. [16:17:33] WARNING: [gamemodes]/[race]/[addons]/kog-readdb/server.lua:29: Bad argument @ 'dbQuery' [Expecte d db-connection at argument 1, got nil] [16:17:33] WARNING: [gamemodes]/[race]/[addons]/kog-readdb/server.lua:35: Bad argument @ 'dbQuery' [Expecte d db-connection at argument 1, got nil] [16:17:33] WARNING: [gamemodes]/[race]/[addons]/kog-readdb/server.lua:41: Bad argument @ 'dbQuery' [Expecte d db-connection at argument 1, got nil] [16:17:33] WARNING: [gamemodes]/[race]/[addons]/kog-readdb/server.lua:47: Bad argument @ 'dbQuery' [Expecte d db-connection at argument 1, got nil] It seems that the "connect" object is not set.
  17. Ok thanks. What is the meaning of the underscore in this function ? -- When a player login it calls the readPlayerDatas function function init(_, account) account = "Blabla" -- Test Variable ! ##### The Account variable 'll come later with a loginPanel ##### readPlayerDatas(account) end addEventHandler("onPlayerLogin",root,init)
  18. Here is the edited code. I don't know if i can add the "local" state for variables "playerData", "EventsData", "DMData" and "OLDData" because i've to use them out of the function with the triggerClientEvent action. The account 'll come from a loginPanel which is not yet implemented here. ---- MYSQL Connection ---- -- Create an connection object for the Database function connectDB() .... end -- Call the function to create a Connection Object function initVar() connect = connectDB() end addEventHandler("onResourceStart",root,initVar) -- When a player login it calls the readPlayerDatas function function initPlayer() local account = "Blabla" -- Test Variable ! ##### Later it'll be send by the Login Panel ##### readPlayerDatas(account) end addEventHandler("onPlayerLogin",root,init) function readPlayerDatas(account) -- Account must be a input variable from clientside -- Retrieve Player table datas from DB local queryPlayer = dbQuery(myCallBackPlayer,connect, "SELECT * FROM Player WHERE account = ?", account) function myCallBackPlayer(queryPlayer) local resultPlayer = dbPoll(queryPlayer,0) playerData = resultPlayer[1] end -- Retrieve Events table datas from DB local queryEvents = dbQuery(myCallBackEvents,connect, "SELECT * FROM Events WHERE toPlayer = ?", account) function myCallBackEvents(queryEvents) local resultEvents = dbPoll(queryEvents,0) EventsData = resultEvents[1] end -- Retrieve DM datas from DB local queryDM = dbQuery(myCallBackDM,connect, "SELECT * FROM DM WHERE toPlayer = ?", account) function myCallBackDM(queryDM) local resultDM = dbPoll(queryDM,0) DMData = resultDM[1] end -- Retrieve OLD datas from DB local queryOLD = dbQuery(myCallBackOLD,connect, "SELECT * FROM OLD WHERE toPlayer = ?", account) function myCallBackOLD(queryOLD) local resultOLD = dbPoll(queryOLD,0) OLDData = resultOLD[1] end -- Trigger an event clientside and send the previous datas with in triggerClientEvent(thePlayer,"onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) end addEvent("onPlayerReadDatas",true) addEventHandler("onPlayerReadDatas",root,readPlayerDatas) Thank you,
  19. Now it must be ok ? Any other advices ? Is it important to use dbFree ? Serverside ---- MYSQL Connection ---- -- Create an connection object for the Database function connectDB() .... end -- Call the function to create a Connection Object function initVar() connect = connectDB() end addEventHandler("onResourceStart",root,initVar) -- When a player login it calls the readPlayerDatas function function initPlayer() account = "Blabla" -- Test Variable ! ##### readPlayerDatas() end addEventHandler("onPlayerLogin",root,init) function readPlayerDatas(account) -- Account must be a input variable from clientside -- Retrieve Player table datas from DB local queryPlayer = dbQuery(myCallBackPlayer,connect, "SELECT * FROM Player WHERE account = ?", account) function myCallBackPlayer(queryPlayer) local resultPlayer = dbPoll(queryPlayer,0) playerData = resultPlayer[1] end -- Retrieve Events table datas from DB local queryEvents = dbQuery(myCallBackEvents,connect, "SELECT * FROM Events WHERE toPlayer = ?", account) function myCallBackEvents(queryEvents) local resultEvents = dbPoll(queryEvents,0) EventsData = resultEvents[1] end -- Retrieve DM datas from DB local queryDM = dbQuery(myCallBackDM,connect, "SELECT * FROM DM WHERE toPlayer = ?", account) function myCallBackDM(queryDM) local resultDM = dbPoll(queryDM,0) DMData = resultDM[1] end -- Retrieve OLD datas from DB local queryOLD = dbQuery(myCallBackOLD,connect, "SELECT * FROM OLD WHERE toPlayer = ?", account) function myCallBackOLD(queryOLD) local resultOLD = dbPoll(queryOLD,0) OLDData = resultOLD[1] end -- Trigger an event clientside and send the previous datas with in triggerClientEvent(thePlayer,"onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) end addEvent("onPlayerReadDatas",true) addEventHandler("onPlayerReadDatas",root,readPlayerDatas) Clientside -- Recceive the data from serverside function receiveDatasFromDB(playerDatas) -- Set the local vars that'll be edited while playing (I'll later save all these changes to database) local mail = playerData.mail -- Display Test outputDebugString(mail) -- ... end -- Trigggered by serverside to call receiveDatasFromDB addEvent("onReplyFromReadDatas",true) addEventHandler("onReplyFromReadDatas",root,receiveDatasFromDB)
  20. Here is some modifications with your advices. Where can i find information about Callback ? I know them in C++ but not with Lua. Thanks Serverside ---- MYSQL Connection ---- -- Create an connection object for the Database function connectDB() ... end -- Call the function to create a Connection Object function initVar() connect = connectDB() end addEventHandler("onResourceStart",root,initVar) function readPlayerDatas(account) -- Account must be a input variable from clientside -- Retrieve Player table datas from DB local queryPlayer = dbQuery(connect, "SELECT * FROM Player WHERE account = ?", account) local resultPlayer = dbPoll(queryPlayer, -1) local playerData = resultPlayer[1] -- Retrieve Events table datas from DB local queryEvents = dbQuery(connect, "SELECT * FROM Events WHERE toPlayer = ?", account) local resultEvents = dbPoll(queryEvents, -1) local EventsData = resultEvents[1] -- Retrieve DM datas from DB local queryDM = dbQuery(connect, "SELECT * FROM DM WHERE toPlayer = ?", account) local resultDM = dbPoll(queryDM, -1) local DMData = resultDM[1] -- Retrieve OLD datas from DB local queryOLD = dbQuery(connect, "SELECT * FROM OLD WHERE toPlayer = ?", account) local resultOLD = dbPoll(queryOLD, -1) local OLDData = resultOLD[1] -- Trigger an event clientside and send the previous datas with in triggerClientEvent(thePlayer,"onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) end addEvent("onPlayerReadDatas",true) addEventHandler("onPlayerReadDatas",root,readPlayerDatas) Clienside -- trigger the readPlayerDatas serverside function callReadDatas() -- TEST Variable (Later it'll come from login panel) account = "rouche" triggerServerEvent("onPlayerReadDatas",localPlayer,account) end -- When the player logged in call the function callReadDatas addEventHandler("onPlayerLogin",root,callReadDatas) -- Recceive the data from serverside function receiveDatasFromDB(playerDatas) -- Set the local vars that'll be edited while playing (I'll later save all these changes to database) local mail = playerData.mail -- Display Test outputDebugString(mail) end -- Trigggered by serverside to call receiveDatasFromDB addEvent("onReplyFromReadDatas",true) addEventHandler("onReplyFromReadDatas",root,receiveDatasFromDB)
  21. Hi all, I'm working on my userpanel and i try to send the datas from DB to my client when they logged in. I would like to ask you if my script is well done. Serverside rootElement = getRootElement() ---- MYSQL Connection ---- -- Create an connection object for the Database function connectDB() local con = dbConnect("mysql","dbname=DBNAME;host=IP", "USERNAME", "PASSWORD", "share=1") if (con) then outputDebugString("Connection OK !") else outputDebugString("Connection to Database failled !") end return con end function readPlayerDatas(account) -- Account must be a input variable from clientside connect = connectDB() -- Retrieve Player table datas from DB local queryPlayer = dbQuery(connect, "SELECT * FROM Player WHERE account = ?", account) local resultPlayer = dbPoll(queryPlayer, -1) local playerData = resultPlayer[1] -- Retrieve Events table datas from DB local queryEvents = dbQuery(connect, "SELECT * FROM Events WHERE toPlayer = ?", account) local resultEvents = dbPoll(queryEvents, -1) local EventsData = resultEvents[1] -- Retrieve DM datas from DB local queryDM = dbQuery(connect, "SELECT * FROM DM WHERE toPlayer = ?", account) local resultDM = dbPoll(queryDM, -1) local DMData = resultDM[1] -- Retrieve OLD datas from DB local queryOLD = dbQuery(connect, "SELECT * FROM OLD WHERE toPlayer = ?", account) local resultOLD = dbPoll(queryOLD, -1) local OLDData = resultOLD[1] -- Trigger an event clientside and send the previous datas with in triggerClientEvent(thePlayer,"onReplyFromReadDatas",rootElement,playerData,EventsData,DMData,OLDData) end addEvent("onPlayerReadDatas",true) addEventHandler("onPlayerReadDatas",rootElement,readPlayerDatas) Clientside rootElement = getRootElement() -- trigger the readPlayerDatas serverside function callReadDatas() -- TEST Variable (Later it'll come from login panel) account = "rouche" triggerServerEvent("onPlayerReadDatas",localPlayer,account) end -- When the player logged in call the function callReadDatas addEventHandler("onPlayerLogin",rootElement,callReadDatas) -- Recceive the data from serverside function receiveDatasFromDB(playerDatas) -- Set the local vars that'll be edited while playing (I'll later save all these changes to database) local mail = playerData.mail -- Display Test outputDebugString(mail) end -- Trigggered by serverside to call receiveDatasFromDB addEvent("onReplyFromReadDatas",true) addEventHandler("onReplyFromReadDatas",rootElement,receiveDatasFromDB) Thanks
×
×
  • Create New...