Jump to content

Lloyd Logan

Members
  • Posts

    642
  • Joined

  • Last visited

Everything posted by Lloyd Logan

  1. Can you provide us with your code?
  2. So; function getSerial() local serialz = getPlayerSerial(source) local queryResult = dbQuery ( server, "SELECT serial FROM accounts WHERE serial = ?", serialz ) local database = dbPoll(queryResult, -1) if #database > 0 then dbExec ( server, "UPDATE accounts SET serial = ? WHERE serial = ?", serial, tostring (serialz)) else dbExec ( server, "INSERT INTO accounts (serial) VALUES (?)", tostring (serialz)) end end addEventHandler("onPlayerJoin", getRootElement(), getSerial)
  3. It gives me the error; attempt to get length of local 'data' a userdata value
  4. function spawnVeh() local serialz = getPlayerSerial(source) carid = dbQuery(server, "SELECT carid FROM accounts WHERE serial = ?", serialz) local cx = dbQuery(server, "SELECT cx FROM accounts WHERE serial = ?", serialz) local cy = dbQuery(server, "SELECT cy FROM accounts WHERE serial = ?", serialz) local cz = dbQuery(server, "SELECT cz FROM accounts WHERE serial = ?", serialz) veh = createVehicle(carid, cx, cy, cz) end addEventHandler("onPlayerJoin", getRootElement(), spawnVeh) Expected number for the createvehicle, but the returned should be a number from the table.
  5. Why does this keep INSERTING even if there is already the same serial in the table? local data = dbPoll(dbQuery(server, "SELECT serial FROM accounts WHERE serial = ?", serial), -1) if data and type (data) == "table" and #data > 0 then dbExec (server, "UPDATE accounts SET serial = ?, WHERE serial = '"..serial.."'", tostring (serialz)) else dbExec (server, "INSERT INTO accounts (serial) VALUES (?)", tostring (serialz)) end
  6. Thank you for taking the time to write that. I understand it much more. Also I have fixed those errors! Thanks again
  7. local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", serial), -1) if data and type (data) == "table" and #data > 0 then dbExec (server, "UPDATE accounts SET x = ?, y = ?, z = ?, cx = ?, cy = ?, cz = ?, carid = ? WHERE serial = '"..serial.."'", tostring (a), tostring (b), tostring (c), tostring (x), tostring (y), tostring (z), tostring (vehname),) else dbExec (server, "INSERT INTO accounts VALUES (x, y, z, cx, cy, cz, carid) VALUES (?, ?, ?, ?, ?, ?, ?)", tostring (a), tostring (b), tostring (c), tostring (x), tostring (y), tostring (z), tostring (vehname)) end It now gives me the error of unexpected symbol near ) at line 15
  8. Thank you, also those websites you refer me to, I don't fully understand it; In MTA It would equal to = dbExec(server, "INSERT INTO accounts blah) Whereas On that website it says = UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value; It's different, how do I apply the website syntax into the MTA one.
  9. Why doesn't this INSERT a new value? if data and type (data) == "table" and #data > 0 then dbExec (server, "UPDATE accounts SET (x, y, z, cx, cy, cz, carid) VALUES (?, ?, ?, ?, ?, ?, ?)", tostring (a), tostring (b), tostring (c), tostring (x), tostring (y), tostring (z), tostring (vehname) "WHERE serial ='"..serial.."'") else dbQuery (server, "INSERT INTO accounts VALUES (x, y, z, cx, cy, cz, carid) VALUES (?, ?, ?, ?, ?, ?, ?)", tostring (a), tostring (b), tostring (c), tostring (x), tostring (y), tostring (z), tostring (vehname))
  10. Infact, what the hell am I thinking, disregard this!
  11. Why doesn't this work, it tells me I am returning a string value? serial = getPlayerSerial(source) x, y, z = getElementPosition(newveh) a, b, c = getElementPosition(source) dbQuery ( server, "INSERT INTO accounts (x, y, z, cx, cy, cz) VALUES (?, ?, ?, ?, ?, ?)", tostring (a), tostring (b), tostring (c), tostring (x), tostring (y), tostring (z)" WHERE serial = '".. serial .."'")--THIS BIT HERE!
  12. Yeah, I only used his example as a guideline, so all is good, thanks though!
  13. Thank you! All is working.
  14. I never thought of it to be honest! Thanks!
  15. Wait so I don't need to use addEventHandler within a function until I want to?
  16. But if I were to do onClientRender wouldn't it show as soon as the player joins? Instead of when I trigger it?
  17. So how could I trigger it at a specific time?
  18. Ah, I understand! So how would I trigger them (not using the render?)
  19. As soon as the it draws the text, it disappears almost extremely quickly (like .5 seconds).
  20. Why does this instantly delete the text? function drawText() dxDrawText("You have successfully bought a vehicle!", 92, 158, 720, 195, tocolor(65, 205, 4, 255), 1.40, "pricedown", "left", "top", false, false, true, false, false) setTimer ( function() triggerEvent("destroy") end, 5000, 1 ) end addEvent("drawSuccess", true) addEventHandler("drawSuccess", root, drawText) function destroyText() removeEventHandler("drawSuccess", getRootElement(), drawText) end addEvent("destroy", true) addEventHandler("destroy", root, destroyText)
  21. I just realised that! My bad, thanks guys!
  22. Why is nothing happening with this script? function buyVeh() local money = getPlayerMoney(source) if (money < 10000) then ("You do not have enough money to purchase this car", 255, 0, 0) else newveh = createVehicle(589, 558.748046875, -1265.380859375, 17.2421875 ) warpPedIntoVehicle(source, newveh) takePlayerMoney (source, 10000) outputChatBox("You have successfully bought a club!", 0, 255, 0) end end addCommandHandler("buyvehclub", getRootElement(), buyVeh)
  23. I didn't even realise it was that easy, thank you!
×
×
  • Create New...