Jump to content

Marshell

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Marshell

  1. Hello! I want to get an advice from you and a problem solution. Thanks in advance. Bad argument @ "logIn" [Expected account at argument 2, got boolean] the line is : if (logIn(player, account, password) == true) then the script is : function passwordHandler(player, oldpassword, newpassword) local account = getPlayerAccount(player) if (account) then if (isGuestAccount(account)) then outputChatBox("You must be logged in to change your password.", player) return end local playerName = getPlayerName(player) local password_check = getAccount(playerName, oldpassword) if (password_check ~= false) then if (string.len(newpassword) >= 5) then setAccountPassword(account, newpassword) triggerClientEvent(player, "hidePasswordWindow", getRootElement()) else outputChatBox("Your new password must be at least 5 characters long!", player) end else outputChatBox("Old password invalid.", player) end end end function loginHandler(player, username, password, thePlayer) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, account, password) == true) then setTimer( spawnPlayer, 2000,1,player, 925.329, 46.152, 80.908) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 5000, 1, player, true, 0.5 ) setElementFrozen(player, false) setTimer( setCameraTarget,3200,1,player) triggerClientEvent (player, "hideLoginWindow1", getRootElement()) else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end function registerHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else account = addAccount(username, password) if (logIn(player, account, password) == true) then triggerClientEvent(player, "hideLoginWindow", getRootElement()) setPlayerHudComponentVisible ( player, "radar", false ) setTimer ( fadeCamera, 50, 1, player,false, 1 ) setTimer ( fadeCamera, 3000, 1, player,true, 3 ) setTimer( spawnPlayer, 2250,1,player, 806.7,-1350,-0.4) setTimer(setCameraMatrix,1500,1,player, 808,-1351,-0.4,-1000,0,0,0,0) --setTimer(setElementPosition,2000,1,player, 806.7,-1350,-0.4) setTimer(setElementRotation,2251,1,player,0,0,220) else triggerClientEvent(player, "unknownError", getRootElement()) end end end function setCameraOnPlayerJoin() fadeCamera(source, true, 5) setTimer ( fadeCamera, 5000, 1, source, true, 0.5 ) setCameraMatrix(source, 1000.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) end addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) function hudChangerOnJoin () setPlayerHudComponentVisible ( source, "radar", false ) showChat( source, false) end addEventHandler ( "onPlayerJoin", getRootElement(), hudChangerOnJoin ) function hudChangerOnLogin () setPlayerHudComponentVisible ( source, "radar", true ) end addEventHandler ( "onPlayerLogin", getRootElement(), hudChangerOnLogin ) function logoutHandler()--We define a function name local accountname = getAccountName (getPlayerAccount(source))--we get an account if (isGuestAccount(getPlayerAccount(source)) == true) then cancelEvent()--then cancelEvent --triggerClientEvent("logOutOp", getRootElement())--output him to chatbox that logout is not allowed end end addEventHandler("onPlayerLogout",getRootElement(),logoutHandler)--we add a event handler which will handle the funciton function setCameraRegister(player, thePlayer) setTimer(setElementPosition,1000,1,source, 925.329, 46.152, 80.908) setTimer( setCameraTarget,1200,1, source ) setTimer ( fadeCamera, 50, 1, source,false, 1 ) setTimer ( fadeCamera, 3000, 1, source,true, 3 ) setElementFrozen ( source, false ) setPlayerHudComponentVisible ( source, "radar", true ) showChat(source, true) end addEvent("setCameraRegister", true) addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) addEventHandler("setCameraRegister", root, setCameraRegister)
  2. How can I do this ? can you tell me, please?
  3. Hello! Bad argument @ passwordVerify [ Expected string at argument 2, got boolean] Thanks in advance. local MINIMUM_PASSWORD_LENGTH = 6 local function isPasswordValid(password) return string.len(password) >= MINIMUM_PASSWORD_LENGTH end -- create an account addEvent('auth:register-attempt', true) addEventHandler('auth:register-attempt', root, function (username, password) -- check if an account with that username already exists if getAccount(username) then return outputChatBox('An account already exists with that name.', source, 255, 100, 100) end -- is the password valid? if not isPasswordValid(password) then return outputChatBox('The password supplied was not valid.', source, 255, 100, 100) end -- create a hash of the password local player = source passwordHash(password, 'bcrypt', {}, function (hashedPassword) -- create the account local account = addAccount(username, hashedPassword) setAccountData(account, 'hashed_password', hashedPassword) -- automatically login and spawn the player. logIn(player, account, hashedPassword) spawnPlayer(player, 0, 0, 10) setCameraTarget(player, player) return triggerClientEvent(player, 'register-menu:close', player) end) end) -- login to their account addEvent('auth:login-attempt', true) addEventHandler('auth:login-attempt', root, function (username, password) local account = getAccount(username) if not account then return outputChatBox('No such account could be found with that username or password.', source, 255, 100, 100) end local hashedPassword = getAccountData(account, 'hashed_password') local player = source passwordVerify(password, hashedPassword, function (isValid) <<<< THIS IS THE LINE if not isValid then return outputChatBox('No such account could be found with that username or password.', player, 255, 100, 100) end if logIn(player, account, hashedPassword) then spawnPlayer(player, 0, 0, 10) setCameraTarget(player, player) return triggerClientEvent(player, 'login-menu:close', player) end return outputChatBox('An unknown error occured while attempting to authenticate.', player, 255, 100, 100) end) end) -- logout of their account addCommandHandler('accountLogout', function (player) logOut(player) end)
  4. Hello !! Can you help me, please ? I've got this problem : Bad argument @ "passwordVerify" [ Expected string at argument 2, got boolean] Thanks in advance! local MINIMUM_PASSWORD_LENGTH = 6 local function isPasswordValid(password) return string.len(password) >= MINIMUM_PASSWORD_LENGTH end addCommandHandler("register", function(player, command, username, password) if not username or not password then return outputChatBox("Syntax: /" .. command .. " [nume utilizator] [ parola ]", player, 255, 205, 201) end if getAccount(username) then return outputChatBox("Un cont cu acest nume exista deja.", player, 255, 205, 201) end if not isPasswordValid(password) then return outputChatBox("Parola este invalida/Parola trebuie sa aiba minim 6 caractere.", player, 255, 100, 100) end passwordHash(password, "bcrypt", {}, function(hashedPassword) local account = addAccount(username, hashedPassword) setAccountData(account, "hashed_password", hashedPassword) outputChatBox("Contul tau a fost inregistrat cu succes! Acum poti folosi /accountLogin pentru a te autentifica.", player, 100, 255, 100) end) end) addEvent("auth:login-attempt", true) addEventHandler("auth:login-attempt", root, function (username, password) local account = getAccount(username) if not account then return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", source, 255, 100, 100) end local hashedPassword = getAccountData(account, "hashed_password") local player = source passwordVerify(password, hashedPassword, function (isValid) if not isValid then return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", player, 255, 100, 100) end if logIn(player, account, hashedPassword) then return triggerClientEvent(player, "login-menu:close", player) end return outputChatBox("O eroare neasteptata a avut loc in timpul autentificarii.", player, 255, 100, 100) end) end) addCommandHandler("accountLogout", function(player) logOut(player) end)
  5. Hello! Would you like to help me ? I've got this problem : dbExec failed; (1) near "x": syntax error. THANKS! dbExec failed; (1) near "x": syntax error. [DUP x2] function createVehicleForPlayer(player, command, model) local db = exports.db:getConnection() local x, y, z = getElementPosition(player) local rotX, rotY, rotZ = getElementRotation(player) rotZ = rotZ * 90 y = y + 5 dbExec(db, "INSERT INTO vehicles(model, x, y, z, rotation_x, rotation_y, rotation_z) VALUES(?, ?, ?, ?, ?, ?, ?)", model, x, y, z, rotX, rotY, rotZ) local vehicleObject = createVehicle(model, x, y, z, rotX, rotY, rotZ) dbQuery(function (queryHandle) local results = dbPoll(queryHandle, 0) local vehicle = results[1] setElementData(vehicleObject, "id", vehicle.id) end, db, "SELECT id FROM vehicles ORDER BY id DESC LIMIT 1") end addCommandHandler("veh", createVehicleForPlayer, false, false) function loadAllVehicles(queryHandle) local results = dbPoll(queryHandle, 0) for index, vehicle in pairs(results) do local vehicleObject = createVehicle(vehicle.model, vehicle.x, vehicle.y, vehicle.z, vehicle.rotation_x, vehicle.rotation_y, vehicle.rotation_z) setElementData(vehicleObject, "id", vehicle.id) end end addEventHandler("onResourceStart", resourceRoot, function() local db = exports.db:getConnection() dbQuery(loadAllVehicles, db, "SELECT * FROM vehicles") end) addEventHandler("onResourceStop", resourceRoot, function() local db = exports.db:getConnection() local vehicles = getElementsByType("vehicle") for index, vehicle in pairs(vehicles) do local id = getElementData(vehicle, "id") local x, y, z = getElementPosition(vehicle) local rotX, rotY, rotZ = getElementRotation(vehicle) dbExec(db, "UPDATE vehicles SET x=?, y=?, z=?, rotation x = ?, rotation y = ?, rotation z = ? WHERE id = ?", x, y, z, rotX, rotY, rotZ, id) end end)
  6. Oke, thanks, but, the other problems ? How can I solve them ?
  7. Problems : > Acces denied @ "addAccount" the line is : local account ="" addAccount(username, hashedPassword) "" and the 2nd problem is : Bad argument "setAccountData [ Expected account at argument 1, got nil] and the line is : >> setAccountData(account, "hashed_password", hashedPassword) ( it's under the first line mentioned). Other problem is when a players tries to login .. the line is : local hashedPassword = getAccountData(account, "hashed_password") -- and the problem : "Bad argument getAccountData[ Expected account at argument 1, got boolean" and "Bad argument @ passwordVerify [ Expected string at argument 2, got boolean], the line is passwordVerify(password, getAccountData(account, "hashed_password"), function(isValid) local MINIMUM_PASSWORD_LENGTH = 6 local function isPasswordValid(password) return string.len(password) >= 6 end addCommandHandler("register", function(player, command, username, password) if not username or not password then return outputChatBox("Syntax: /" .. command .. " [nume utilizator] [ parola ]", player, 255, 205, 201) end if getAccount(username) then return outputChatBox("Un cont cu acest nume exista deja.", player, 255, 205, 201) end if not isPasswordValid(password) then return outputChatBox("Parola este invalida/Parola trebuie sa aiba minim 6 caractere.", player, 255, 100, 100) end passwordHash(password, "bcrypt", {}, function(hashedPassword) local account = addAccount(username, hashedPassword) setAccountData(account, "hashed_password", hashedPassword) outputChatBox("Contul tau a fost inregistrat cu succes! Acum poti folosi /accountLogin pentru a te autentifica.", player, 100, 255, 100) end) end) addCommandHandler("accountLogin", function(player, command, username, password) if not username or not password then return outputChatBox("Syntax: /" .. command .. " [nume utilizator] [ parola ]", player, 255, 205, 201) end local account = getAccount(username) if not account then outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", player, 255, 100, 100) end local hashedPassword = getAccountData(account, "hashed_password") passwordVerify(password, getAccountData(account, "hashed_password"), function(isValid) if not isValid then return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", player, 255, 100, 100) end if logIn(player, account, hashedPassword) then return outputChatBox("Te-ai autentificat cu succes!", player, 100, 255, 100) end return outputChatBox("O eroare neasteptata a avut loc in timpul autentificarii.", player, 255, 100, 100) end) end, false, false)
  8. I got another problem... " dbExec failed; (1) near "x" : syntax error dbExec(db, "UPDATE vehicles SET x=?, y=?, z=? WHERE id = ?", x, y, z, id) <<this is the line
  9. I also got this error : attempt to index global "vehicle" ( a nil value) at this line : setElementData(vehicleObject, "id", vehicle.id)
  10. Hello, people! Forgive me if I did something bad/wrong, but, I am following tutorials to make scripts. So.. as u read, in the title, I have this problem "Bad argument #1 to "pairs"(table expected, got boolean)" (line 28); and the other problem : dbPoll failed, near "FROM" : syntax error.(line 26) function createVehicleForPlayer(player, command, model) local db = exports.db:getConnection() local x, y, z = getElementPosition(player) y = y + 5 dbExec(db, "INSERT INTO vehicles(model, x, y, z) VALUES(?, ?, ?, ?)", model, x, y, z) local vehicleObject = createVehicle(model, x, y, z) dbQuery(function (queryHandle) local results = dbPoll(queryHandle, 0) local vehicles = results[1] setElementData(vehicleObject, "id", vehicle.id) end, db, "SELECT id FROM vehicles ORDER BY id DESC LIMIT 1") end addCommandHandler("veh", createVehicleForPlayer, false, false) function loadAllVehicles(queryHandle) local results = dbPoll(queryHandle, 0) for index, vehicle in pairs(results) do local vehicleObject = createVehicle(vehicle.model, vehicle.x, vehicle.y, vehicle.z) setElementData(vehicleObject, "id", vehicle.id) end end addEventHandler("onResourceStart", resourceRoot, function() local db = exports.db:getConnection() dbQuery(loadAllVehicles, db, "SELECT + FROM vehicles") end) addEventHandler("onResourceStop", resourceRoot, function() local db = exports.db:getConnection() local vehicles = getElementsByType("vehicle") for index, vehicle in pairs(vehicles) do local id = getElementData(vehicle, "id") local x, y, z = getElementPosition(vehicle) dbExec(db, "UPDATE vehicles SET x=?, y=?, z=? WHERE id = ?", x, y, z, id) end end)
×
×
  • Create New...