Jump to content

kevin433

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by kevin433

  1. I've read at Wiki that if I use the function "addCommandHandler", "source" is defined as "playerSource". It's at "Handler function parameters" and showed in Example 3 here: https://wiki.multitheftauto.com/wiki/AddCommandHandler
  2. Hi, Everytime I start the server it show me this: WARNING: MYSQL.lua: Bad argument @ 'getPlayerName' - Line: 32 [16:45:53] ERROR: ...reas/server/mods/deathmatch/resources/play/MYSQL.lua:32: attempt to concatenate a boolean value What does this mean? That's my code: function CreateMYSQLAccount(playerSource) if(not mysqlconnection) then outputServerLog("MYSQL Connection failed!") else mysql_select_db(mysqlconnection, "mtaserver") --benutzername = getPlayerName(player) [b]local result2 = mysql_query(mysqlconnection,"SELECT Username FROM Benutzer WHERE Username='" .. getPlayerName(playerSource) .."'")[/b] if(mysql_num_rows(result2) > 0) then outputServerLog( getPlayerName(playerSoure).. "gibt es schon!") outputChatBox( getPlayerName(playerSoure).. "getb es schon!", playerSource) else mysql_query(mysqlconnection, "INSERT INTO Benutzer (Username) VALUES('" .. getPlayerName(playerSource) .. "') ") result = mysql_query(mysqlconnection, "SELECT Username FROM Benutzer") outputServerLog("result: "..mysql_result(result, 1, 1)) outputChatBox("Spieler: "..mysql_result(result, 1, 1)) end end end addCommandHandler("register", CreateMYSQLAccount) Line 32 is in Bold
  3. If I understand it the right way, the "source" is already defined in Events like "onVehicleRespawn" "source" is the car and in events like "onPlayerClick" "source" is the player?
  4. Hi, Yesterday I got told to use thePlayer, plr or player instead of source if I meant a Player. Now I tried to change source to player. I started the sever, joined and... nothing happens. The only thing is that I'm looking into the sky and when I see at the SeverLog, the server spams it full with [15:22:38] WARNING: broph.lua: Bad argument @ 'spawnPlayer' - Line: 18 I changed then to plr, and that also didn't work. I tried thePlayer and that also didn't work. I then changed back to source, and everything worked fine. That's my code: addEventHandler("onResourceStart", resourceRoot, function() for i,plr in ipairs(getElementsByType("player")) do spawn(plr) end end ) function spawn(plr) repeat until spawnPlayer (plr, -711+math.random(1,5), 957+math.random(5,9), 12.4, 90, math.random(9,288) ) fadeCamera(plr, true) setCameraTarget(plr, plr) end function playerjoined() spawn(plr) setTimer(keys, 1000, 1, plr) setTimer(LichtAnlageOn, 500, 0, plr) outputChatBox("Hi Noob!", plr) end addEventHandler("onPlayerJoin", root, playerjoined)
  5. Yeah, I know that you said that don't know exactly the MYSQL module works, but I tried to ask if there is anyone in this Forum who knows how the MYSQL module work. Thanks for the mysql_result function, I got it to work now. I forgot to add a row Oh, yeah, forgot the code. For everyone who has the same problem: function MYSQLData() mysqlconnection = mysql_connect("hostname", "db_username", "db_password", "db_name",port(optional)) if(not mysqlconnection) then outputServerLog("MYSQL Connection failed!") else outputServerLog("MYSQL Connection succeeded!") mysql_query(mysqlconnection, "CREATE TABLE IF NOT EXISTS User (Geld INT NOT NULL)") mysql_query(mysqlconnection, "INSERT INTO User (Geld) VALUES('500') ") result = mysql_query(mysqlconnection, "SELECT Geld FROM User") outputServerLog("result"..mysql_result(result, 1, 1)) end end addEventHandler ( "onResourceStart", resourceRoot, MYSQLData )
  6. Got one last question. When I try to "Select" the info from the table, the Server gives me this error: ERROR: ...mods/deathmatch/resources/MYSQLSystem/Untitled 2.lua:9: attempt to get length of global 'result' (a userdata value) I don't know what the error means This is how my code is looking: mysql_query(mysqlconnection, "CREATE TABLE IF NOT EXISTS User (Geld INT NOT NULL)") result = mysql_query(mysqlconnection, "SELECT Geld FROM User") if #result > 0 then outputServerLog("Geld:" .. result[1].Geld) end
  7. I finally made it!! If someone has the same problem/question, here's the code: function MYSQLData() mysqlconnection = mysql_connect("hostname", "db_username", "db_password", "db_name",port (optional)) if(not mysqlconnection) then outputServerLog("MYSQL Connection failed!") else outputServerLog("MYSQL Connection succeeded!") mysql_query(mysqlconnection, "CREATE TABLE User (Geld INT NOT NULL)") end end addEventHandler ( "onResourceStart", resourceRoot, MYSQLData ) Thank you xbost and 50p (I will try it later again with player, thePlayer etc...)!
  8. That's how it would be in PHP (copied it from a site, didn't remember the whole.) <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Create a MySQL table in the selected database mysql_query("CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)") or die(mysql_error()); echo "Table Created!"; ?> So do I have to use the same syntax?
  9. OK, the first thing I checked now was if it had created a table. I opened up the registry.db file with SQLiteadmin and it was empty I now decided to move over to the MYSQL module, I have already some experience using it in PHP, but I don't know how to create a table in my database with LUA In PHP it was mysql_query(CREATE TABLE table_name(..... . My server is already connected with the database. I'm really confused about source, thePlayer etc... I changed everything with source where i excepted a player element with thePlayer (tried also player) and some things didn't work longer. I started with the "play" resource, and when i change everything to "thePlayer" or "player", then I can't even spawn
  10. Hi, I need help again This time it's about the SQLite in MTA. I started today with SQLite. What I want to try is to get an integer from the database and then show the integer for the Player in the textbox. That's how far I got: function SQLData(source) sourcename = getPlayerName ( source ) result = executeSQLQuery("SELECT Kevin433 FROM Geld WHERE Geld = '" .. usergeld .. "'") outputChatBox("Du hast " .. usergeld .. "$" ) end addCommandHandler("info", SQLData) I have worked with MYSQL before, but not with SQLite. The thing is that when I write /info, nothing happens. The most of it is from the wiki pages and the forum.
  11. Should this work? setElementData(source,"lightson", 1) Don't I have to make a local or global "lightson"? Or should it just be like that? And can I do things like this? if(getElementData(source, "lightson") == 1) then outputChatBox("Your lights are on!", source) end
  12. What is meaned with "string key"? I just saw the example on the Wiki page and there the key was "tempdata.originalnick". I just need to save an integer
  13. Hi, I recently began to script in LUA, and I have experience with PAWN. The problem is now that i want an "integer" which every player has his own off. I just know how to do this in SA:MP, but not in MTA. I mean something like this (I hope some guys understand what i want to do), I just can show how i would write it in SA:MP: new lightson[MAX_PLAYERS]; if(lightson[playerid] == 1) { ...... etc } How should i write this in LUA? I've checked the wiki, but I couldn't find it there.
  14. Hi, I scripted in SA:MP, but it got boring, because you can't do much things there. However, I started yesterday with MTA scripting. One thing I have wondered about is source, thePlayer, thePed, getRootElements etc... I would like to know when and where i should use them.
  15. Hi, When i go to forum.sa-mp.com i get redirected to mtasa.com . All my friends can go to forum.sa-mp.com why not me?
×
×
  • Create New...