Lloyd Logan

Members
  • Content Count

    642
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Lloyd Logan

  • Rank
    Crime Partner

Details

  • Gang
    South Cock Smugglers
  • Location
    Glasgow, Scotland |X|

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  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.