Jump to content

Access denied & Bad argument


Recommended Posts

Hey there!

Recently the console outputs these warnings to me when I attempt to register:

[09:15:25] WARNING: script.lua: Access denied @ 'addAccount' - Line: 77
[09:15:25] WARNING: script.lua: Bad argument @ 'logIn' - Line: 78

The lines are these two (server-side script):

[...]
account = addAccount(user, pass)
if(logIn(player, account, pass) == true) then
[...]

Has anyone got any clue of what's wrong here? If anything's missing, please let me know.

Thanks.

Link to comment

Fixed the "Access denied" warning. Now my problem is the "Bad argument" warning when I use logIn.

Here's the onRegister event:

function onRegister(player, user, pass)
local account = getAccount(user, pass)
if(account ~= false) then
if(logIn(player, account, pass) == true) then
triggerClientEvent("hideLoginWindow", getRootElement())
outputChatBox("You have been successfully logged in.", player)
else
outputChatBox("Error: Invalid password, username or already logged in.", player)
end
else
	account = addAccount(user, pass)
if(logIn(player, account, pass) == true) then
triggerClientEvent("hideLoginWindow", getRootElement())
outputChatBox("You have been successfully registered and logged in.", player)
else
outputChatBox("Error: Invalid password, username or already logged in.", player)
end
end
end

and onLogin:

function onLogin(player, user, pass)
local account = getAccount(user, pass)
if(account ~= false) then
if(logIn(player, account, pass) == true) then
triggerClientEvent("hideLoginWindow", getRootElement())
outputChatBox("You have been successfully logged in.", player)
else
outputChatBox("Error: Invalid password, username or already logged in.", player)
end
else
outputChatBox("Error: Invalid username or password.", player)
end
end

Link to comment

this is from wiki i believe you will see what you did wrong

function clientSubmitLogin(button,state)
if button == "left" and state == "up" then
-- get the text entered in the 'username' field
local username = guiGetText(edtUser)
-- get the text entered in the 'password' field
local password = guiGetText(edtPass)
 
-- if the username and password both exist
if username and password then
-- trigger the server event 'submitLogin' and pass the username and password to it
triggerServerEvent("submitLogin", getRootElement(), username, password)
 
-- hide the gui, hide the cursor and return control to the player
guiSetInputEnabled(false)
guiSetVisible(wdwLogin, false)
showCursor(false)
else
-- otherwise, output a message to the player, do not trigger the server
-- and do not hide the gui
outputChatBox("Please enter a username and password.")
end
end
end

Link to comment
this is from wiki i believe you will see what you did wrong
function clientSubmitLogin(button,state)
if button == "left" and state == "up" then
-- get the text entered in the 'username' field
local username = guiGetText(edtUser)
-- get the text entered in the 'password' field
local password = guiGetText(edtPass)
 
-- if the username and password both exist
if username and password then
-- trigger the server event 'submitLogin' and pass the username and password to it
triggerServerEvent("submitLogin", getRootElement(), username, password)
 
-- hide the gui, hide the cursor and return control to the player
guiSetInputEnabled(false)
guiSetVisible(wdwLogin, false)
showCursor(false)
else
-- otherwise, output a message to the player, do not trigger the server
-- and do not hide the gui
outputChatBox("Please enter a username and password.")
end
end
end

I see what you're trying to say. But the code I posted is in the server-side script, not the client-side. It uses triggerServerEvent because it's in the client-side script, right?

The example from the wiki is in the client-side script.

Link to comment

This is where it triggers the event:

function onClickBtn(button, state)
if(button == "left" and state == "up") then
if(source == BtnAction) then
if(guiGetSelectedTab(TabPanel) == TabLogin) then
triggerServerEvent("onLogin", getRootElement(), getPlayerName(getLocalPlayer()), guiGetText(LoginUsername), guiGetText(LoginPassword))
else
triggerServerEvent("onRegister", getRootElement(), getPlayerName(getLocalPlayer()), guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword))
end
end
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...