Jump to content

=KoG=Rouche

Members
  • Posts

    220
  • Joined

  • Last visited

Everything posted by =KoG=Rouche

  1. Thanks for your help. -- Return the real time function realTime() local time = getRealTime() local day = time.monthday local month = time.month local year = time.year +1900 local hours = time.hour +1 local minutes = time.minute +1 local lastSeen = "Lastseen : "..day.."/"..month.."/"..year.." - "..hours..":"..minutes.."" return lastSeen end addEvent("onPlayerQuiUpdateLastSeen",true) addEventHandler("onPlayerQuitUpdateLastSeen",rootElement,realTime)
  2. Ok thanks. But now i try to set a variable with a string. rootElement = getRootElement() ------ Functions -------- -- Return the real time (TO BE TESTED) function realTime() local time = getRealTime() day = fromJSON(time.monthday) month = fromJSON(time.month) year = fromJSON(time.year + 100) hours = fromJSON(time.hour) minutes = fromJSON(time.minute) lastSeen = "Lastseen : "..toString(day).."/"..toString(month).."/"..toString(year).." - "..toString(hours)..":"..toString(minutes).."" end addEventHandler("onResourceStart",rootElement,realTime) outputDebugString(lastSeen) It doesn't work :-/
  3. Hi all, I'm trying to save "lastSeen" in a mysql table called "DM". I got some issue. rootElement = getRootElement() ... function realTime() local lastSeen = getRealTime() -- It returns a tab end addEventHandler("onPlayerQuit",rootElement,realTime) -- Later in my code dbExec(connect,"INSERT INTO DM (lastSeen,timePlayed,cash,moneyUse,moneyWon,timeJoin,toPlayer) VALUES ('"..time..":""','0','0','0','0','0','"..account.."')") ... It's not working :-/ How to save an answer from getRealTime() in my DB ?
  4. Trop l'habitude de répondre en anglais Mauvais réflexe ^^
  5. The problem comes from gta_sa.exe the executable of the game. Re-install the game or ask a friend to send you this file again and replace it.
  6. Hi all, Here is a part of my "Userpanel" script. I try to retrieve player's datas into variables. Is it better to keep these variables clientside (what i did) or keep this in a table serverside ? I mean ... most of the variables can be edited when server is running. Last question : when must i save the datas to mysql ? When a player quit or with a timer ? Serverside : -- Retrieve Datas from Player table dataQuery = dbQuery(connect, "SELECT * FROM Player WHERE nickname = '"..account.."'") resultPlayer = dbPoll(dataQuery, -1) playerDatas = resultPlayer[1] triggerClientEvent("onReadData",rootElement,playerDatas) Clientside : function calledByReadData(datas) local account = datas.nickname local password = datas.password local mail = datas.mail local day = datas.day local month = datas.month local year = datas.year local level = datas.level local VIP = datas.VIP local welcomeText = datas.welcomeText outputDebugString("Test pseudo = "..account.." !") --like : -- local money = datas.money or 0 -- local playtime = datas.playtime or 0 --for example. end addEvent("onReadData",true) addEventHandler("onReadData",calledByReadData)
  7. It works now dbExec(connect,"INSERT INTO Player (nickname,password,mail,bDay,bMonth,bYear,level,VIP,welcomeText) VALUES ('"..account.."','"..password.."','"..mail.."','"..day.."','"..month.."','"..year.."','0','0','none')") Thanks,
  8. Je t'invite à consulter cette page addEventHandler tu pouras alors voir les arguments dont à besoin cette fonction pour que ça marche. WARNING: test\bomb_s.lua:145: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil]
  9. Cette erreur concerne la mémoire RAM de ton serveur. terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Combien de RAM as tu sur le serveur ? Si tu es sous Linux (et je te le souhaite) fais la commande free -m pour savoir si i lte reste de la RAM libre quand ton serveur tourne. Si tu souhaite voir la consommation de ton serveur utilise la commande top
  10. If you want to create a strongh server you can't do it with your computer ! Because your internet connection is slow (Even with biggest offer from your IAP). In fact the better way to run a server with lot of players is to rent a server and manage it from your computer. For exemple you can rent a server on http://www.kimsufi.com/uk/ and then configure a server on this server. It'll run 24h/24 and 7d/7 with a enterprise internet connection. Good luck (The best operating system for servers is Debian <3)
  11. I usualy use the command : screen -S NAME
  12. Ce genre de serveur devrait te convenir à merveille. http://www.kimsufi.com/fr/
  13. About local connect. I edited the script "con" is now a local variable. local con = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1", "USER", "PASSWORD", "share=1") About the function triggered on login. It is what i want to do. I would like to create the profile in database only if a player logged in to the server. (not when he joins the server)
  14. About regAndLogin function : the regAndLogin function is triggered when a player use login function on the server function regAndLogin() outputDebugString("Check if in regAndLogin function - OK") triggerClientEvent("onRegAndLogin",rootElement) end addEvent("onPlayerLogin",true) addEventHandler("onPlayerLogin",rootElement,regAndLogin) -- HERE, When a player join it 'll trigger the function Here is the last version of server.lua with your advices. Is the anti SQL injection important to in dbExec function with an insert ? Serverside -- || =KoG= Userpanel By Rouche || -- --------- MYSQL --------- -- Create an connection object for the Database function connectDB() local con = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1", "USER", "PASSWORD", "share=1") if (con) then outputDebugString("Connection OK !") else outputDebugString("Connection to Database failled !") end return con end ------- VARIABLES ------- rootElement = getRootElement() local connect = connectDB() --------- CODE ---------- -- Player Login / Register -- -- STEP 1 | Called when a player register and logged in on =KoG= Server | function regAndLogin() outputDebugString("Check if in regAndLogin function - OK") triggerClientEvent("onRegAndLogin",rootElement) end addEvent("onPlayerLogin",true) addEventHandler("onPlayerLogin",rootElement,regAndLogin) -- STEP 3 | Called by Step 2 (Clientside) Check if the profile already exist in database | function addUser(account,password,mail,day,month,year) outputDebugString("Check if in checkIfExist Function - OK") query = dbQuery(connect, "SELECT nickname FROM Player WHERE nickname= ?", account) result = dbPoll(query, -1) if(result) then outputDebugString("Database already have an account with this name : "..account.."!") -- Call a function that retrieves DATA in Variables (To BE CODED) else outputDebugString("checkIfExist will now execute dbExec to add create a new profile in DB - OK") -- INSERT TO (Add an entity in player table) dbExec(connect,"INSERT INTO player (nickname,password,mail,bDay,bMonth,bYear,level,VIP,welcomeText) VALUES ("..account..","..password..","..mail..","..day..","..month..","..year..",'0','0','none')") outputDebugString("An entity in player Table has been Created - OK") dbExec(connect,"INSERT INTO Events (toPlayer,eRegister,eLevel1,eLevel6,eLevel10,eLevel13,eLevel15,eLevel17,eLevel20,eChangeServ) VALUES ("..account..",'0','0','0','0','0','0','0','0','0')") outputDebugString("An entity in Events Table has been Created - OK") dbExec(connect,"INSERT INTO DM (lastSeen,timePlayed,cash,moneyUse,moneyWon,timeJoin,toPlayer) VALUES ('0','0','0','0','0','0','0',"..account..")") outputDebugString("An entity in DM Table has been Created - OK") dbExec(connect,"INSERT INTO OLD (lastSeen,timePlayed,cash,moneyUse,moneyWon,timeJoin,toPlayer) VALUES ('0','0','0','0','0','0','0',"..account..")") outputDebugString("An entity in OLD Table has been Created - OK") end end addEvent("onAddUser",true) addEventHandler("onAddUser",rootElement,addUser) Thanks
  15. Here is the new version of my script. Is it better now ? And is the dbExec line ok with insert > i mean is it correct -> ... ,"..account..", ... ? Serverside -- AddUser Server Part -- -- Create an connection object for the Database function connectDB() con = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1", "USER", "PASSWORD", "share=1") if (con) then outputDebugString("Connection OK !") else outputDebugString("Connection to Database failled !") end return con end ------- VARIABLES ------- rootElement = getRootElement() local connect = connectDB() --------- CODE ---------- -- STEP 1 | Called when a player register and logged in on =KoG= Server | function regAndLogin() outputDebugString("Check if in regAndLogin function - OK") triggerClientEvent("onRegAndLogin",rootElement) end addEvent("onPlayerLogin",true) addEventHandler("onPlayerLogin",rootElement,regAndLogin) -- STEP 3 | Called by Step 2 (Clientside) Check if the profile already exist in database | function addUser(account,password,mail,day,month,year) outputDebugString("Check if in checkIfExist Function - OK") query = dbQuery(connect, "SELECT nickname FROM Player WHERE nickname='"..account.."'") if(query) then outputDebugString("Database already have an account with this name : "..account.."!") else outputDebugString("checkIfExist will now execute dbExec to add create a new profile in DB - OK") -- INSERT TO (Add an entity in player table) dbExec(connect,"INSERT INTO player (nickname,password,mail,bDay,bMonth,bYear,level,VIP,welcomeText) VALUES ("..account..","..password..","..mail..","..day..","..month..","..year..",'0','0','none')") outputDebugString("Profile Added in DB - OK") end end addEvent("onAddUser",true) addEventHandler("onAddUser",rootElement,addUser) Clientside -- AddUser Client Part -- ------- VARIABLES ------- rootElement = getRootElement() thePlayer = getPlayerFromName() -- Client Answer from a GUI form (Not yet coded) local account="toto" local password="passtoto" local mail="[email protected]" local day=15 local month=5 local year=1998 -- STEP 2 | Called by Step 1 (Serverside) When a player use login action from my panel | function loginAction() outputDebugString("Check if in loginAction Function - OK") triggerServerEvent("onAddUser",account,password,mail,day,month,year) end addEvent("onRegAndLogin",true) addEventHandler("onRegAndLogin",rootElement,loginAction) Thanks for help
  16. Can someone give me advice on my script ? Is it a good way to start with Mysql ? (i'll try the script on my server later cuz i'm at work, i only access console for the moment so i can see the outpubDebusgString message serverside / I'll edit this topic after work in ~6 hours) Serverside -- AddUser Server Part -- -- Create an connection object for the Database function connectDB() con = dbConnect("mysql","dbname=DBNAME;host=127.0.0.1", "USER", "PASSWORD", "share=1") if (con) then outputDebugString("Connection OK !") else con=0 outputDebugString("Connection to Database failled !") end return con end ------- VARIABLES ------- rootElement = getRootElement() local connect = connectDB() --------- CODE ---------- -- STEP 1 | Called when a player register and logged in on =KoG= Server | function regAndLogin() outputDebugString("Check if in regAndLogin function - OK") triggerClientEvent("onRegAndLogin",rootElement,connect) end addEvent("onPlayerLogin",true) addEventHandler("onPlayerLogin",rootElement,regAndLogin) Clientside -- AddUser Client Part -- ------- VARIABLES ------- rootElement = getRootElement() thePlayer = getPlayerFromName() -- Client Answer from a GUI form (Not yet coded) local account="toto" local password="passtoto" local mail="[email protected]" local day=15 local month=5 local year=1998 -- STEP 2 | Called by Step 1 (Serverside) When a player use login action from my panel | function loginActionOneTime(connect) outputDebugString("Check if in loginActionOneTime Function - OK") checkIfExist(theplayer,connect) end addEvent("onRegAndLogin",true) addEventHandler("onRegAndLogin",rootElement,loginActionOneTime) -- STEP 4 | Called by Step 2 (Clientside) addUser function (Add datas to the database) | function addUser(connect) outputDebugString("Check if in addUser - OK !") if(connect) then outputDebugString("Check just before dbQuery INSERT TO player - OK !") dbQuery(connect,"INSERT INTO player (nickname,password,mail,bDay,bMonth,bYear,level,VIP,welcomeText) VALUES ("..account..","..password..","..mail..","..day..","..month..","..year..",'0','0','none')") outputDebugString("Creating a new profile for "..theplayer.." with account : "..account.."!") else outputDebugString("No Connection Object Here ! - KO") end end -- STEP 3 | Called by Step 2 (Clientside) Check if the profile already exist in database | function checkIfExist(theplayer,connect) outputDebugString("Check if in checkIfExist Function - OK") query = dbQuery(connect, "SELECT * FROM Player WHERE nickname='"..account.."'") if(query) then outputDebugString("Check if the checkIfExist query exist - OK") outputDebugString("Database already have an account with this name : "..account.."!") else outputDebugString("checkIfExist call addUser function to create a new profile - OK") addUser(connect) end end
  17. Bonjour, je suis le propriétaire de la team =KoG= qui existe depuis 2006. Je me permet de répondre en insistant sur le fait que les serveurs francophones sur MTA ne marche pas à long terme. Vu le peu de français présents j'ai moi-même changer ma façon de recruter il y a quelques années. J'ai décidé de devenir team international avec des gens de tout les coins du monde avec en commun l'anglais. Si tu souhaites un projet de serveur ambitieux sur MTA je te conseille vivement de choisir l'anglais comme l'angue principale. Je joue depuis 2006 et AUCUN serveur français n'a fait long feu. C'est dommage mais je pense qu'il faut s'adapter à la communauté et non l'inverse. Si tu décides d'utiliser l'anglais je pourai t'aider niveau scripting et hébergement de serveur. J'héberge tout mes serveurs sur un Dédié chez OVH. Donc pas de limite de slots et je suis informaticien et je pense avoir une bonne gestion de mes serveurs. Cependant le fait de ne pas faire un minimum de pub dans le cas ou quelqu'un t'héberge gratuitement n'est pas très correct, c'est donnant-donnant. Bonne fin d'après-midi, =KoG=Rouche
  18. In fact there is 2 ways of using MySQL. > MTA Built-in functions (dbConnect, dbQuery ...) > MTA Team MySQL Module (mysql_connect, mysql_close, ...) I understand it now and i'll use Built-in functions for the next scripts.
  19. Ok thanks it works now With DB function there isn't need to close the connection ? something like 'dbClose' ? Must i execute all this code clientside ? I think its better to create the "connect" object with password, username ... on serverside (Security reasons) and then send the "connect" object to clientside for queries ... true ? rootElement = getRootElement() function ClientResStart() connect = dbConnect("mysql","dbname=NAME;host=127.0.0.1", "USER", "PASS", "share=1") -- Establish the connection if ( not connect ) then -- The connection failed outputDebugString("Unable to connect to the MySQL server") outputConsole("Unable to connect to the MySQL server") else outputDebugString("OK") outputConsole("OK") query = dbQuery(connect, "SELECT * FROM Player WHERE nickname='rouche'") result = dbPoll(query, -1) datas = result[1] local nickname = datas.nickname outputDebugString("Pseudo : "..nickname.." !") dbClose(connect) -- Close the connection end end addEventHandler("onResourceStart",rootElement,ClientResStart)
  20. For me (on Debian 64 bits) functions without module dont work :-/ Then i added the modeule and it works fine now.
  21. Hi all, i try to display a data from my database but i got some problems function ClientResStart() handler = mysql_connect("127.0.0.1", "user", "pass", "dbname") -- Establish the connection if ( not handler ) then -- The connection failed outputDebugString("Unable to connect to the MySQL server") outputConsole ("Unable to connect to the MySQL server") else outputDebugString("OK") outputConsole("OK") local result = mysql_query(handler, "SELECT * FROM Player WHERE nickname='rouche'") if (not result) then outputConsole("Error executing the query: (" .. mysql_errno(handler) .. ") " .. mysql_error(handler)) else outputConsole ("Pseudo : "..result.nickname.. " !") mysql_free_result(result) -- Freeing the result is IMPORTANT end mysql_close(handler) -- Close the connection end end addEventHandler("onResourceStart",rootElement,ClientResStart) I'm pretty sure i don't use the right way to display database data. I think i need to retrieve data in a tab[] and then display the data ... True ? If yes how to retrieve all these datas in the tab ? Thank you for the help and keep playing.
×
×
  • Create New...