Jump to content

Login server issues


Recommended Posts

This is the login script. I tried to add Money and now it broke. It says "Clien Trigered serverside Event on4XRegister, but event is not added serverside. Also says the same thing on login but it has on4XLogin . Help please. Once this is fixed, I'll add pos loading. Then later i plan to add skin settings but that is kind of be on me right now. Thanks.

login_serv.lua

-- Based Parts and/Or whole from  Icedsun's Login GUI (logingui) by icedsun AND login_register By Dr4x
-- Money System added by Kevin
--Default spawn location, if you wish to use one...
local spawnX = 1959
local spawnY = -1714
local spawnZ = 17
--Default welcome messages...
local welcomeMessageNewUser = "Welcome to our server!"
local welcomeMessageReturningUser = "Welcome back to the server!"
 
 
function on4XLogin ( player, user, pass )
local account = getAccount ( user, pass )
if ( account ~= false ) then
	if (logIn ( player, account, pass ) == true) then
		triggerClientEvent ( "hideLoginWindow", getRootElement())
		local playermoney = getAccountData ( account, "acct.money" )
		setPlayerMoney ( client, playermoney )
		spawnPlayer(client,spawnX,spawnY,spawnZ)
		fadeCamera(client,true)
		outputChatBox(welcomeMessageReturningUser,client)
	else
		outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
	end
else
	outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
 
addEvent( "on4XLogin", true )
addEventHandler( "on4XLogin", getRootElement(), on4XLogin )
 
 
function on4XRegister ( player, user, pass, email )
local account = getAccount ( user, pass )
if ( account ~= false ) then
	if (logIn ( player, account, pass ) == true) then
		triggerClientEvent ( "hideLoginWindow", getRootElement())
	else
		outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
	end
else
	account = addAccount ( user, pass )
	setAccountData ( account, "email", email) 
	setAccountData ( account, "acct.money","250") 
	if (logIn ( player, account, pass ) == true) then
		triggerClientEvent ( "hideLoginWindow", getRootElement())
		spawnPlayer(client,spawnX,spawnY,spawnZ)
		fadeCamera(client,true)
		outputChatBox(welcomeMessageNewUser,client)
	else
		outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
	end
end
end
 
addEvent( "on4XRegister", true )
addEventHandler( "on4XRegister", getRootElement(), on4XRegister )
 
function removePlayerHandler()
local playeraccount = getPlayerAccount ( source )
		local playermoney = getPlayerMoney ( source )
		setAccountData ( playeraccount, "acct.money", source )
		kickPlayer(source)
end
addEvent("removePlayer",true)
addEventHandler("removePlayer",getRootElement(),removePlayerHandler)

Link to comment

ok well im reading what u did and first u forgot to add a "end" thats why says is not added serverside, here is new code, im trying to fix your money thing ;)

-- Based Parts and/Or whole from  Icedsun's Login GUI (logingui) by icedsun AND login_register By Dr4x
-- Money System added by Kevin
--Default spawn location, if you wish to use one...
local spawnX = 1959
local spawnY = -1714
local spawnZ = 17
--Default welcome messages...
local welcomeMessageNewUser = "Welcome to our server!"
local welcomeMessageReturningUser = "Welcome back to the server!"
 
 
function on4XLogin ( player, user, pass, thePreviousAccount, theCurrentAccount )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
local playermoney = getAccountData ( account, "acct.money" )
setPlayerMoney ( client, playermoney )
spawnPlayer(client,spawnX,spawnY,spawnZ)
fadeCamera(client,true)
outputChatBox(welcomeMessageReturningUser,client)
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
addEvent( "on4XLogin", true )
addEventHandler( "on4XLogin", getRootElement(), on4XLogin )
 
function on4XRegister ( player, user, pass, email )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
     account = addAccount ( user, pass )
setAccountData ( account, "email", email)
setAccountData ( account, "acct.money","250")
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
spawnPlayer(client,spawnX,spawnY,spawnZ)
fadeCamera(client,true)
outputChatBox(welcomeMessageNewUser,client)
else
outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
end
 
addEvent( "on4XRegister", true )
addEventHandler( "on4XRegister", getRootElement(), on4XRegister )
 
function removePlayerHandler()
local playeraccount = getPlayerAccount ( source )
local playermoney = getPlayerMoney ( source )
setAccountData ( playeraccount, "acct.money", source )
kickPlayer(source)
end
addEvent("removePlayer",true)
addEventHandler("removePlayer",getRootElement(),removePlayerHandler)

btw why just u dont make a second function to save the player money?

Link to comment

Thanks. Now i'm trying to add it to save laction data but its not for some reason when i check the accounts.xml

Here is the script

-- Based Parts and/Or whole from  Icedsun's Login GUI (logingui) by icedsun AND login_register By Dr4x
-- Money System added by Kevin
--Default spawn location, if you wish to use one...
local spawnX = 1959
local spawnY = -1714
local spawnZ = 17
--Default welcome messages...
local welcomeMessageNewUser = "Welcome to our server!"
local welcomeMessageReturningUser = "Welcome back to the server!"
 
 
function on4XLogin ( player, user, pass, thePreviousAccount, theCurrentAccount )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
	triggerClientEvent ( "hideLoginWindow", getRootElement())
	local playermoney = getAccountData ( account, "acct.money" )
	setPlayerMoney ( client, playermoney )
	spawnPlayer(client,spawnX,spawnY,spawnZ)
	fadeCamera(client,true)
	outputChatBox(welcomeMessageReturningUser,client)
else
	outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
addEvent( "on4XLogin", true )
addEventHandler( "on4XLogin", getRootElement(), on4XLogin )
 
function on4XRegister ( player, user, pass, email )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
	triggerClientEvent ( "hideLoginWindow", getRootElement())
else
	outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
account = addAccount ( user, pass )
setAccountData ( account, "email", email)
setAccountData ( account, "acct.money","250")
if (logIn ( player, account, pass ) == true) then
	triggerClientEvent ( "hideLoginWindow", getRootElement())
	spawnPlayer(client,spawnX,spawnY,spawnZ)
	setPlayerMoney ( client, "250" )
	fadeCamera(client,true)
	outputChatBox(welcomeMessageNewUser,client)
else
	outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
end
addEvent( "on4XRegister", true )
addEventHandler( "on4XRegister", getRootElement(), on4XRegister )
function removePlayerHandler()
local playeraccount = getPlayerAccount ( source  )
local x, y, z = getElementPosition( source  )
local interior = getElementInterior( source  )
local playermoney = getPlayerMoney ( source  )
local rotation = getPedRotation ( source  )
setAccountData ( playeraccount, "acct.money", source  )
setAccountData(playeraccount, "savedX", x)
setAccountData(playeraccount, "savedY", y)
setAccountData(playeraccount, "savedZ", z)
setAccountData(playeraccount, "savedInterior", interior)
setAccountData(playeraccount, "Rotation", rotation)
kickPlayer(source)
end
 
addEvent("removePlayer",true)
addEventHandler("removePlayer",getRootElement(),removePlayerHandler)

Link to comment

I dont understand what u realy trying to do, why just u dont make a function to save everything?

i have did it for you, this works.

-- Based Parts and/Or whole from  Icedsun's Login GUI (logingui) by icedsun AND login_register By Dr4x
-- Money System added by Kevin
--Default spawn location, if you wish to use one...
--local spawnX = 1959
--local spawnY = -1714
--local spawnZ = 17
--Default welcome messages...
local welcomeMessageNewUser = "Welcome to our server!"
local welcomeMessageReturningUser = "Welcome back to the server!"
 
 
function on4XLogin ( player, user, pass )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
--spawnPlayer(client,spawnX,spawnY,spawnZ)
fadeCamera(client,true)
outputChatBox(welcomeMessageReturningUser,client)
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
addEvent( "on4XLogin", true )
addEventHandler( "on4XLogin", getRootElement(), on4XLogin )
 
function on4XRegister ( player, user, pass, email )
local account = getAccount ( user, pass )
if ( account ~= false ) then
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
else
outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
else
  account = addAccount ( user, pass )
setAccountData ( account, "email", email)
setAccountData ( account, "acct.money","250")
if (logIn ( player, account, pass ) == true) then
triggerClientEvent ( "hideLoginWindow", getRootElement())
spawnPlayer(client,spawnX,spawnY,spawnZ)
setPlayerMoney ( client, "250" )
fadeCamera(client,true)
outputChatBox(welcomeMessageNewUser,client)
else
outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end
end
addEvent( "on4XRegister", true )
addEventHandler( "on4XRegister", getRootElement(), on4XRegister )
function removePlayerHandler()
kickPlayer(source)
end
addEvent("removePlayer",true)
addEventHandler("removePlayer",getRootElement(),removePlayerHandler)
 
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
if  not (isGuestAccount (getPlayerAccount (source))) then
local accountData = getAccountData (theCurrentAccount, "acct.money")
if (accountData) then
local playerMoney = getAccountData (theCurrentAccount, "acct.money")
local playerX = getAccountData (theCurrentAccount, "cords-x")
local playerY = getAccountData (theCurrentAccount, "cords-y")
local playerZ = getAccountData (theCurrentAccount, "cords-z")
local playerInt = getAccountData (theCurrentAccount, "int")
local playerDim = getAccountData (theCurrentAccount, "dim")
spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerInt, playerDim)
setPlayerMoney (source, playerMoney)
setCameraTarget (source, source)
fadeCamera(source, true, 2.0)
else
spawnPlayer (source, 1962.2475585938, -1674.1062011719, 15.96875, 0, math.random (0, 288), 0, 0 )
setCameraTarget (source, source)
fadeCamera(source, true, 2.0) 
end   
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
 
function onQuit (quitType, reason, responsibleElement,thePreviousAccount)
if not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
if (account) then
local x,y,z = getElementPosition (source)
setAccountData (account, "acct.money", tostring (getPlayerMoney (source)))
setAccountData (account, "cords-x", x)
setAccountData (account, "cords-y", y)
setAccountData (account, "cords-z", z)
setAccountData (account, "int", getElementInterior (source))
setAccountData (account, "dim", getElementDimension (source))
end
end
end
addEventHandler ("onPlayerQuit", getRootElement(), onQuit)

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...