Jump to content

Registration in the Gui. Help


Sydnej

Recommended Posts

Hello. At the beginning I would like to inform you that I do not know English and use the translate.google, i am a Poland. I wanted to make registrations in the Gui but I have a problem. My code:

Client

function Gui ()
Image = guiCreateStaticImage(0,0,0.9987,0.9983,"image/serwer.png",true)
BTNz = guiCreateButton(0.7138,0.7367,0.1775,0.07,"Zarejestruj",true,Image)
guiSetAlpha(BTNz,0.75)
addEventHandler( "onClientGUIClick", BTNz, Zarejestruj)
BTNp = guiCreateButton(0.5462,0.3933,0.0538,0.2583,">",true,Image)
guiSetAlpha(BTNp,0.75)
addEventHandler( "onClientGUIClick", BTNp, SkinPrawo)
BTNl = guiCreateButton(0.0262,0.3933,0.0538,0.2583,"<",true,Image)
guiSetAlpha(BTNl,0.75)
addEventHandler( "onClientGUIClick", BTNl, SkinLewo)
NapisNick = guiCreateLabel(0.6825,0.375,0.1225,0.0517,"Nick:",true,Image)
EditNick = guiCreateEdit(0.81,0.36,0.1488,0.055,"",true,Image)
guiLabelSetColor(NapisNick,255,255,255)
guiLabelSetVerticalAlign(NapisNick,"top")
guiLabelSetHorizontalAlign(NapisNick,"left",false,Image)
NapisHaslo = guiCreateLabel(0.6825,0.470,0.1225,0.0517,"Haslo:",true,Image)
EditHaslo = guiCreateEdit(0.81,0.455,0.1488,0.055,"",true,Image)
guiLabelSetColor(NapisHaslo,255,255,255)
guiLabelSetVerticalAlign(NapisHaslo,"top")
guiLabelSetHorizontalAlign(NapisHaslo,"left",false,Image)
guiEditSetMasked(EditHaslo,true)
NapisEmail = guiCreateLabel(0.6825,0.569,0.1225,0.0517,"Adres email:",true,Image)
EditEmail = guiCreateEdit(0.81,0.550,0.1488,0.055,"",true,Image)
guiLabelSetColor(NapisEmail,255,255,255)
guiLabelSetVerticalAlign(NapisEmail,"top")
guiLabelSetHorizontalAlign(NapisEmail,"left",false,Image)
end
local localPlayer = getLocalPlayer ( )
local player = getPlayerName(localPlayer)
--[[guiSetVisible ( Image, false )--gui widoczne bo false
local localPlayer = getLocalPlayer ( )
 
function RejestracjaOkno ()
local playername = getPlayerName(localPlayer)
 
guiSetText(EditNick, "" )
guiSetText(EditHaslo, "" )
guiSetText(EditEmail, "" )
 
guiSetInputEnabled(true)--unbind podczas pisania
showCursor ( true )--kursor włączony
end]]--
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function ()
	Gui()
        if (Image ~= nil) then
		guiSetVisible(Image, true)
        end 
 
        showCursor(true)
        guiSetInputEnabled(true)
end
)
 
function Zarejestruj (button,state)
if button == "left" and state == "up" then
	local username = guiGetText(EditNick)
	local password = guiGetText(EditHaslo)
	local email = guiGetText(EditEmail)
	if (source == BTNz) then
		if username and password and email then
			triggerServerEvent("rejestracja", getRootElement(), username, password, email)
 
		end
	end
end
end
 
function Zamykanie()
guiSetInputEnabled(false)
guiSetVisible ( Image, false )
showCursor ( false )
end
--[[function Zarejestruj ()
triggerServerEvent( "Zarejestruj", getRootElement() )
showCursor( true )
end]]
 
--[[function SkinPrawo ()
triggerServerEvent( "SkinPrawo", getRootElement() )
showCursor( true )
end
 
function SkinLewo ()
triggerServerEvent( "SkinLewo", getRootElement() )
showCursor( true )
end]]

and server:

function rejestracja ( username, password, email)
local account = getAccount ( username, password )
if ( account ~= false ) then
	if (logIn ( player, account, password ) == true) then
		triggerClientEvent ( "Zamykanie", getRootElement())
	end
else
	account = addAccount ( username, password )
	setAccountData ( account, "email", email) 
	if (logIn (player, account, password ) == true) then
		triggerClientEvent ( "Zamykanie", getRootElement())
end
end
end
addEvent( "rejestracja", true )
addEventHandler( "rejestracja", getRootElement(), rejestracja )

Where is the error? The script does not work and I have 3 console warningi:

[20:53:37] WARNING: serwer.lua: Access denied @ 'addAccount' - Line: 8
[20:53:37] WARNING: serwer.lua: Bad argument @ 'setAccountData' - Line: 9
[20:53:37] WARNING: serwer.lua: Bad argument @ 'logIn' - Line: 10

account = addAccount ( username, password )
	setAccountData ( account, "email", email) 
	if (logIn (player, account, password ) == true) then

Please help.

Link to comment
  • Discord Moderators

I think the first

WARNING: serwer.lua: Access denied @ 'addAccount' - Line: 8

is causing the other two, since

you can't setAccountData on your new account if it isn't added

WARNING: serwer.lua: Bad argument @ 'setAccountData' - Line: 9

WARNING: serwer.lua: Bad argument @ 'logIn' - Line: 10

and you obviously can't login when it doesn't exist.

Open up acl.xml, and puzzle around with the permissions.

It's good practice to get to know the acl.

https://wiki.multitheftauto.com/wiki/Access_Control_List

Link to comment

I added to the file acl.xml to

<group name="Admin">

my script

<object name="rejestracja" />

the whole group looks like:

<group name="Admin">
       <acl name="Moderator" />
       <acl name="SuperModerator" />
       <acl name="Admin" />
       <acl name="RPC" />
       <object name="resource.admin" />
       <object name="resource.webadmin" />
       <object name="user.Sydnej" />
<object name="rejestracja" />
   </group>

Although this added a further warningi are the same and the script does not work.

Link to comment
I added to the file acl.xml to

<group name="Admin">

my script

<object name="rejestracja" />

the whole group looks like:

<group name="Admin">
       <acl name="Moderator" />
       <acl name="SuperModerator" />
       <acl name="Admin" />
       <acl name="RPC" />
       <object name="resource.admin" />
       <object name="resource.webadmin" />
       <object name="user.Sydnej" />
<object name="rejestracja" />
   </group>

Although this added a further warningi are the same and the script does not work.

Try this:

<group name="Admin">
       <acl name="Moderator" />
       <acl name="SuperModerator" />
       <acl name="Admin" />
       <acl name="RPC" />
       <object name="resource.admin" />
       <object name="resource.webadmin" />
       <object name="user.Sydnej" />
       <object name="resource.rejestracja" />
   </group

EDIT: Make sure you stop your server, edit the ACL.xml and THEN start your server again. The ACL file would reset itself to the value the console is holding otherwise.

Link to comment

It helped but not completely, now I have:

[2010-05-23 12:10:55] WARNING: rejestracja\serwer.lua:10: Bad argument @ 'logIn'
[2010-05-23 12:10:57] WARNING: rejestracja\serwer.lua:4: Bad argument @ 'logIn'

function rejestracja ( username, password, email)
local account = getAccount ( username, password )
if ( account ~= false ) then
	if (logIn ( player, account, password ) == true) then ------------4
		triggerClientEvent ( "Zamykanie", getRootElement())
	end
else
	account = addAccount ( username, password )
	setAccountData ( account, "email", email) 
	if (logIn (player, account, password ) == true) then ----------10
		triggerClientEvent ( "Zamykanie", getRootElement())
end
end
end
addEvent( "rejestracja", true )
addEventHandler( "rejestracja", getRootElement(), rejestracja )

Link to comment
It helped but not completely, now I have:

[2010-05-23 12:10:55] WARNING: rejestracja\serwer.lua:10: Bad argument @ 'logIn'
[2010-05-23 12:10:57] WARNING: rejestracja\serwer.lua:4: Bad argument @ 'logIn'

function rejestracja ( username, password, email)
local account = getAccount ( username, password )
if ( account ~= false ) then
	if (logIn ( player, account, password ) == true) then ------------4
		triggerClientEvent ( "Zamykanie", getRootElement())
	end
else
	account = addAccount ( username, password )
	setAccountData ( account, "email", email) 
	if (logIn (player, account, password ) == true) then ----------10
		triggerClientEvent ( "Zamykanie", getRootElement())
end
end
end
addEvent( "rejestracja", true )
addEventHandler( "rejestracja", getRootElement(), rejestracja )

Try this:

function rejestracja ( player, username, password, email)
local account = getAccount ( username, password )
if ( account ~= false ) then
if (logIn ( player, account, password ) == true) then ------------4
triggerClientEvent ( "Zamykanie", getRootElement())
end
else
	account = addAccount ( username, password )
setAccountData ( account, "email", email) 
if (logIn (player, account, password ) == true) then ----------10
triggerClientEvent ( "Zamykanie", getRootElement())
end
end
end
addEvent( "rejestracja", true )
addEventHandler( "rejestracja", getRootElement(), rejestracja )

Link to comment

Change

triggerServerEvent("rejestracja", getRootElement(), username, password, email)

to

triggerServerEvent("rejestracja", getRootElement(), getLocalPlayer(), username, password, email)

in your client-side script. (player argument was missing)

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