Jump to content

تصحيح كود تسجيل


Recommended Posts

السلام عليكم و رحمة الله و بركاته

سويت لوحة تسجيل و تسجيل دخول

التسجيل خربان يقولى بالدي بق :

access denied @ 'addAccount' , Bad Argument @ logIn [Expected account at argument 2 , got nil]

اكوادى :

  
  
addEventHandler("onResourceStart", resourceRoot, function() 
  executeSQLQuery("CREATE TABLE IF NOT EXISTS Accounts (Serial,UserName,UserPass)") 
  outputDebugString("Sql Remember User Name - User Pass , Loaded .", 3) 
end) 
  
addUser = function(Serial, UserName, UserPass) 
  return executeSQLQuery("INSERT INTO Accounts (Serial,UserName,UserPass) VALUES(?,?,?)", Serial, UserName, UserPass) 
end 
  
setUser = function(Serial, UserName, UserPass) 
  return executeSQLQuery("UPDATE Accounts SET UserName=?,UserPass=? WHERE Serial=?", UserName, UserPass, Serial) 
end 
  
getUser = function(Serial) 
  local Row = executeSQLQuery("SELECT * FROM Accounts WHERE Serial = '" .. Serial .. "'") 
  if (type(Row) == "table" and #Row == 0) or not Row then 
    return {} 
  else 
    return tostring(Row[1].UserName), tostring(Row[1].UserPass) 
  end 
end 
  
addEvent("getPass",true) 
addEventHandler("getPass",root,function () 
local UserName, UserPass = getUser(getPlayerSerial(source)) 
if tostring(UserName) and tostring(UserPass) then 
triggerClientEvent(source, "UpRememberUser", source, UserName, UserPass) 
end 
end) 
  
addEvent("OnLogin", true) 
addEventHandler("OnLogin", root, function(user, pass) 
 if not ( isGuestAccount(getPlayerAccount(source)) ) then triggerClientEvent(source,"Play",source) end 
  local Account = getAccount(user, pass) 
  if Account ~= true then 
    local result = logIn(source, Account, pass) 
    if result == true then 
      triggerClientEvent(source, "Play", source) 
    else 
      outputChatBox("* Error : You Entered an Incorrect Information ", source, 255, 0, 0, true) 
    end 
  else 
    outputChatBox("* Wrong Password / Username", source, 255, 0, 0, true) 
  end 
end) 
  
addEvent("OnRegister", true) 
addEventHandler("OnRegister", root, function(user, pass) 
  if not ( isGuestAccount(getPlayerAccount(source)) ) then triggerClientEvent(source,"Play",source) end 
  local Accountlog = getAccount(user, pass) 
  if Accountlog ~= false then 
    if logIn(source, Accountlog, pass) == true then 
      triggerClientEvent(source, "Play", source) 
    else 
      return false 
    end 
    else 
    local Accountreg = addAccount(user, pass) 
    if logIn(source, Accountreg, pass) == true then 
    triggerClientEvent(source, "Play", source) 
    else 
    triggerClientEvent(source, "dontplay", source) 
    outputChatBox("* Error : You`ve Entered Incorrect Information", source, 255, 0, 0, true) 
  end 
 end 
end) 
  
addEvent("OnSave", true) 
addEventHandler("OnSave", root, function(UserName, UserPass) 
  local Serial = getPlayerSerial(source) 
    local Row = executeSQLQuery("SELECT * FROM Accounts WHERE Serial = '" .. Serial .. "'") 
    if (type(Row) == "table" and #Row == 0) or not Row then 
      addUser(Serial, UserName, UserPass) 
      outputChatBox("* This Account Doesn`t Exist", source, 0, 255, 255, true) 
    else 
      setUser(Serial, UserName, UserPass) 
      outputChatBox("* Your Account Has Been Saved.", source, 0, 0, 255, true) 
    end 
end) 

شكرا مقدماً

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...