Sign in to follow this  
wesleywillems17

Problem with login resource

Recommended Posts

Hi all,

 

Today i updated my MTA from 1.4.3 to 1.5.3

I have copied all my resources from my older server to my new server but i have a problem.

Everytime somebody joins my server then i get this error: ERROR: Client (****) triggered serverside event onLoadedAtClient, but event is not added serverside

But there is no onLoadedAtClient -,-

Can somebody tell me how to fix this?

 

Login-system resource:

Client.lua

local infoLabelText = "Welcome to SARS:RPG\n\nYou must have a account to have access to SARS:RPG\nIf you don't have a account then feel free to create one.\nAs a guest you can only play for 30 minutes and you can't buy anything!\nFollow the rules and have a nice day!"
local usernameText = "Username:"
local passwordText = "Password:"
local registerButtonText = "Create a account"
local loginButtonText = "Login"
local loginWindowText = "SARS:RPG 1.0"

showChat(false)
showCursor(true)
toggleAllControls(false)
setPlayerHudComponentVisible ( "all", false )
setCameraMatrix(1855.80, -1469.50, 49.09, 1786.30, -1417.69, 94.69)
local screenW, screenH = guiGetScreenSize()
loginWindow = guiCreateWindow(screenW/2-648/2, screenH/2-303/2, 648, 303, loginWindowText, false)
guiWindowSetMovable(loginWindow, false)
guiWindowSetSizable(loginWindow, false)
infoLabel = guiCreateLabel(0.01, 0.11, 0.97, 0.33, infoLabelText, true, loginWindow)
guiSetFont(infoLabel, "default-bold-small")
guiLabelSetHorizontalAlign(infoLabel, "center", false)
guiLabelSetVerticalAlign(infoLabel, "center")
usernameLabel = guiCreateLabel(0.02, 0.48, 0.25, 0.13, usernameText, true, loginWindow)
guiSetFont(usernameLabel, "default-bold-small")
guiLabelSetHorizontalAlign(usernameLabel, "right", false)
guiLabelSetVerticalAlign(usernameLabel, "center")
usernameInput = guiCreateEdit(0.28, 0.50, 0.71, 0.10, getPlayerName(localPlayer), true, loginWindow)
guiEditSetMaxLength(usernameInput, 21)
passwordLabel = guiCreateLabel(0.02, 0.63, 0.25, 0.13, passwordText, true, loginWindow)
guiSetFont(passwordLabel, "default-bold-small")
guiLabelSetHorizontalAlign(passwordLabel, "right", false)
guiLabelSetVerticalAlign(passwordLabel, "center")
passwordInput = guiCreateEdit(0.28, 0.64, 0.71, 0.10, "", true, loginWindow)
guiEditSetMasked(passwordInput, true)
guiEditSetMaxLength(passwordInput, 32)
registerButton = guiCreateButton(0.02, 0.81, 0.43, 0.13, registerButtonText, true, loginWindow)
guiSetFont(registerButton, "default-bold-small")
guiSetProperty(registerButton, "NormalTextColour", "FFFFFFFF")
loginButton = guiCreateButton(0.46, 0.81, 0.52, 0.13, loginButtonText, true, loginWindow)
guiSetFont(loginButton, "default-bold-small")
guiSetProperty(loginButton, "NormalTextColour", "FFFFFFFF")

function buttonClick()
    if source == registerButton then
        if #guiGetText(usernameInput) < 5 then
            guiSetText(infoLabel,"Your username needs to be at least 5 characters long.")
			return
        end
		if #guiGetText(passwordInput) < 5 then
			guiSetText(infoLabel,"Your password needs to be at least 5 characters long.")
			return
		end
		triggerServerEvent("registerServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
	elseif source == loginButton then
		triggerServerEvent("loginServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
	end
end
addEventHandler("onClientGUIClick",root,buttonClick)

addEvent("clientResponse",true)
function onResponse(n)
	if n == 3 then
		destroyElement(loginWindow)
		showCursor(false)
		toggleAllControls(true)
		return
	elseif n == 2 then
		guiSetText(passwordInput,"")
		guiLabelSetColor(passwordLabel, 255, 0, 0)
	elseif n == 1 then
		guiSetProperty(registerButton, "NormalTextColour", "FFFF0000")
	elseif n == 4 or n == 5 then
		guiSetProperty(loginButton, "NormalTextColour", "FFFF0000")
	end
	responseText = {
		[1] = "There is no account with this username.\nClick on 'Create a account' to make a new account.",
		[2] = "Your password didn't match with the username.\nPlease check your password and try again.",
		[4] = "This username has already been taked, please login or use a other username.",
		[5] = "congratulations!\nYou can now login with your new account!"
	}
	guiSetText(infoLabel,responseText[n])
end
addEventHandler("clientResponse",root,onResponse)

function playSoundOnReg ()
     playSound("sound/reg.mp3")
end
addEvent( "playSound", true )
addEventHandler( "playSound", root, playSoundOnReg )

Server.lua:

addEvent("loginServer",true)
addEvent("registerServer",true)
function loginProcess(username,password)
	if not getAccount(username) then
		triggerClientEvent(source,"clientResponse",source,1)
		return
	end
	if not getAccount(username,password) then
		triggerClientEvent(source,"clientResponse",source,2)
		return
	end
	logIn(source,getAccount(username),password)
	showChat(source, true)
	setCameraTarget(source, nil)
	setElementFrozen ( source, false )
	setPlayerHudComponentVisible ( source, "all", true )
	triggerClientEvent(source,"clientResponse",source,3)
end

function registerProcess(username,password)
	if getAccount(username) then
		triggerClientEvent(source,"clientResponse",source,4)
		return
	end
	addAccount(username,password)
	givePlayerMoney(source,50000)
	setElementPosition ( source, 1481.14, -1770.90, 18.79 )
	outputChatBox("As a newcomer you received $50,000", source, 255, 0, 0, true)
    triggerClientEvent ( source, "playSound", source )
	triggerClientEvent(source,"clientResponse",source,5)
end

function onLogout ()
	cancelEvent ()
	outputChatBox("INFO: Function disabled", source, 255, 0, 0, true)
	outputChatBox("INFO: Press ESC and then use 'Disconnect'", source, 255, 0, 0, true)
end
addEventHandler ("onPlayerLogout", root, onLogout)

addEventHandler("loginServer",root,loginProcess)
addEventHandler("registerServer",root,registerProcess)

 

Share this post


Link to post

I downloaded a other login system resource from the community but still i get the error.

So it has nothing to do with the script that i placed in the topic.

Where can i look to find the bug? the debug doesn't give me a resource name.

Share this post


Link to post

Get Notepad++ and use "Find in files..." function to find the troubling event wherever it is located.

But my best guess would be fr_client.lua from freeroam as it contains the said event.

Edited by Mega9

Share this post


Link to post

You should try (not sure if it'll work for remote events) addDebugHook - hook it up on onLoadedAtClient for pre-event and output the resource, file and line number where it occurs.

Edited by MrTasty

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.