Jump to content

Painel de login


Recommended Posts

4 minutes ago, Tommy. said:

Bom, sem nenhum código fica um pouco difícil de ajudar, Mesmo para logar não precisando de permissão, sabe se o painel de login está com as permissão na acl?

sim está como mando o código

o elemento que ele seta ao logar e este ("CharLoggedIn") eu o coloco nas permissões se sim quais e como ou você fala em adicioanar o recurso na ACL Admin?

Link to comment
addEvent("onCharacterLogin", false)
addEvent("onClientCharacterRequest", true)
addEventHandler("onClientCharacterRequest", getRootElement(),
	function(charname)
		playerSource = client
		local id = getElementData(client, "char.accountID")
		local qh = dbQuery(connection, "SELECT * FROM `players` WHERE `account` = ?", id)
		local row = dbPoll(qh, -1)
		if row then
			for k, row in ipairs (row) do
				local id = tonumber(row["id"])
				local x = tonumber(row["x"])
				local y = tonumber(row["y"])
				local z = tonumber(row["z"])
				local rot = tonumber(row["rot"])
				local interior = tonumber(row["intID"])
				local dimension = tonumber(row["dimID"])
				local health = tonumber(row["health"])
				local hunger = tonumber(row["hunger"])
				local armor = tonumber(row["armor"])
				local skin = tonumber(row["skin"])
				local money = tonumber(row["money"])
				local npoints = tonumber(row["npoints"])
				local nsujo = tonumber(row["nsujo"])
				local carlicense = tostring(row["drivinglicense"])
				local bankmoney = tonumber(row["bankMoney"])
				local playedMinutes = tonumber(row["playedMinutes"])
				local lastLogin = tonumber(row["lastlogin"])
				local gender = tonumber(row["gender"])
				local age = tonumber(row["age"])
				local weight = tonumber(row["weight"])
				local height = tonumber(row["height"])
				local adminnick = tostring(row["adminnick"])
				local charname = tostring(row["charname"])
				charname = string.gsub(tostring(charname), " ", "_")
				--local walkingstyle = tonumber(row["walkingstyle"])
				local jobID = tonumber(row["jobID"])
				local jobName = tostring(row["jobName"])
				local radiochannel = tonumber(row["radiochannel"])
				local factionID = tonumber(row["factionID"])
				local factionLeader = tonumber(row["factionLeader"])
				local factionRank = tonumber(row["factionRank"])
				local badgeNumber = tonumber(row["badgeNumber"])
				local dutySkin = tonumber(row["dutySkin"])
				local showHUD = tonumber(row["showHUD"])
				local showOOC = tonumber(row["showOOC"])
				local showRadar = tonumber(row["showRadar"])
				local payTime = tonumber(row["payTime"])
				local adminlevel = getElementData(playerSource, "char.adminlevel")
				local adminduty = getElementData(playerSource, "char.adminduty")

				setElementData(playerSource, "char.factionID", tonumber(factionID))
				setElementData(playerSource, "char.factionLeader", tonumber(factionLeader))
				setElementData(playerSource, "char.factionRank", tonumber(factionRank))
				setElementData(playerSource, "char.badgeNumber", tonumber(badgeNumber))
				setElementData(playerSource, "char.dutySkin", tonumber(dutySkin))
				setElementData(playerSource, "age", tonumber(age))
				setElementData(playerSource, "weight", tonumber(weight))
				setElementData(playerSource, "height", tonumber(height))
				--setElementData(playerSource, "walkingstyle", tonumber(walkingstyle))
				setElementData(playerSource, "char.jobID", tonumber(jobID))
				setElementData(playerSource, "char.jobName", tostring(jobName))
				if carlicense == "true" then
				setElementData(playerSource, "char.drivingLicense", true)
				else 
                setElementData(playerSource, "char.drivingLicense", false)
				end
				setElementData(playerSource, "charname", tostring(charname))
				setElementData(playerSource, "char.playedMinutes", tonumber(playedMinutes))
				setElementData(playerSource, "char.lastLogin", tonumber(lastLogin))
				setElementData(playerSource, "char.UID", tonumber(id))
				setElementData(playerSource, "char.skin", tonumber(skin))
				setElementData(playerSource, "char.adminlevel", tonumber(adminlevel))
				setElementData(playerSource, "char.adminnick", adminnick)
				setElementData(playerSource, "char.bankMoney", tonumber(bankmoney))
				setElementData(playerSource, "char.money",tonumber(money))
				setElementData(playerSource, "char.diamante",tonumber(npoints))
				setElementData(playerSource, "char.moneysujo",tonumber(nsujo))
				setElementData(playerSource, "char.radio",tonumber(radiochannel))
				setElementData(playerSource, "char.payTime",tonumber(payTime))
				setElementData(playerSource, "gender", tonumber(gender))
				setElementData(playerSource, "visibleName", tostring(charname))
				setElementData(playerSource, "char.phoneNumber", tonumber(id))
				setElementData(playerSource, "showHUD", tonumber(showHUD))
				setElementData(playerSource, "showOOC", tonumber(showOOC))
				setElementData(playerSource, "showRadar", tonumber(showRadar))						
				setPlayerName(playerSource, tostring(charname))
				local name = string.gsub(tostring(charname), "_", " ")
				setPlayerNametagText(source, tostring(name))
				setElementData(playerSource,"char.hunger",hunger)
				setElementData(playerSource, "dbid", getElementData(playerSource, "char.UID"))
				setElementData(playerSource, "char.health", tonumber(health))
				setPedAnimation(playerSource, false)
				setElementHealth(playerSource, health)
				setPedArmor(playerSource, armor)
				setPedSkin(playerSource, skin)
				spawnPlayer(playerSource, x, y, z+2, rot, skin, interior, dimension)
				--setElementDimension(playerSource, dimension)
				--setElementInterior(playerSource, interior)
				--setCameraInterior(playerSource, interior)
				--setPedWalkingStyle(client, walkingstyle)
				--exports.ph_ignora:loadPlayerItems(playerSource)					
				dbExec(connection,"UPDATE `players` SET `lastlogin`=NOW() WHERE `id`=?",id)
				toggleAllControls(playerSource, true, true, true)
				fadeCamera(playerSource, true)
				triggerEvent("onCharacterLogin", playerSource, charname)
				
			if getElementData(playerSource, "char.jailTime") > 0 then
				setElementDimension(playerSource, 60000 + getElementData(playerSource, "charID"))
				setElementInterior(playerSource, 6)
				setElementPosition(playerSource, 263.821807, 77.848365, 1001.0390625)
				setPedRotation(playerSource, 267.438446)	
				setElementData(playerSource, "char.jailTime", getElementData(playerSource, "char.jailTime"))
				setElementData(playerSource, "char.jailReason", getElementData(playerSource, "char.jailReason"))
				setElementData(playerSource, "char.adminJail", true)
				outputChatBox("[Prisão]: Você está na cadeia, motivo: "..getElementData(playerSource, "char.jailReason")..".", playerSource, 124, 9, 9, true)
				outputChatBox("[Prisão]: Tempo: "..getElementData(playerSource, "char.jailTime")..".", playerSource, 124, 9, 9, true)
				exports.ng_bans:loginPlayerJailed()
			else
				setElementData(playerSource, "char.jailTime", 0)
				setElementData(playerSource, "char.jailReason", nil)
				setElementData(playerSource, "char.adminJail", false)
			    end
			end
		else
			outputDebugString( "Conexão com o MySQL falhou!")
		end
	end
)

addEvent("onPlayerLogin", false)
addEvent("onClientLoginRequest", true)
addEventHandler("onClientLoginRequest", getRootElement(),
	function(username, password)
		if (string.len(password)~=64) then
			password = string.reverse((key) .. (password))
		end	
		local lgnQuery = dbQuery(connection, "SELECT * FROM `users` WHERE `username`=? AND `password`=?", username, password )
		playerSource = client
		local lgnResult = dbPoll ( lgnQuery, -1 )
		if #lgnResult > 0 then
			for k, row in ipairs ( lgnResult ) do
				triggerEvent("onPlayerLogin", playerSource, username, password)
				local id = tonumber(row["id"])
				local pass = tonumber(row["password"])
				local found = false
				for key, v in ipairs(getElementsByType("player")) do
					local accid = tonumber(getElementData(v, "char.accountID"))
					if (accid) then
						if (accid==id) and (v~=playerSource) then
							found = true
							break
						end
					end
				end
				if not (found) then
					local admin = tonumber(row["admin"])
					local adminduty = tonumber(row["adminduty"])
					local adminjail = tonumber(row["adminjail"])
					local adminJailTime = tonumber(row["adminjail_time"])
					local adminJailBy = tostring(row["adminjail_by"])
					local adminJailReason = row["adminjail_reason"]
					local banned = tonumber(row["banned"])
					if tonumber(admin) == 0 then adminduty = 0 end
					setElementData(playerSource, "char.adminlevel", tonumber(admin))
					
					local lasethp = tonumber(row["asethp"])
			        local lasetarmor = tonumber(row["asetarmor"])
					local lasethunger = tonumber(row["asethunger"])
			        local lagoto = tonumber(row["agoto"])
			        local lagethere = tonumber(row["agethere"])
			        local lagivemoney = tonumber(row["agivemoney"])
			        local lasetmoney = tonumber(row["asetmoney"])
					local lagiveitem = tonumber(row["agiveitem"])
			        local laadutyminute = tonumber(row["adutyminute"])
			        local lafuelveh = tonumber(row["afuelveh"])	
			        local lafixveh = tonumber(row["afixveh"])
			        local lareply = tonumber(row["areply"])
			        local lapm = tonumber(row["apm"])
			        local lamakeveh = tonumber(row["amakeveh"])
			        local lajail = tonumber(row["ajail"])
			        local laban = tonumber(row["aban"])
					if (banned==1) then
						kickPlayer(source,"Brasil Play Hard","Sua conta está bloqueada")
					else
						setElementData(playerSource, "char.defaultUserName", username)
						setElementData(playerSource, "char.accountID", tonumber(id))
						setElementData(playerSource, "char.adminduty", tonumber(adminduty))
	                    setElementData(playerSource, "char.jailTime", adminJailTime)
						setElementData(playerSource, "char.jailReason", adminJailReason)
						setElementData(playerSource, "admin.sethp", lasethp)
			            setElementData(playerSource, "admin.setarmor", lasetarmor)
			            setElementData(playerSource, "admin.sethunger", lasethunger)
			            setElementData(playerSource, "admin.goto", lagoto)
			            setElementData(playerSource, "admin.gethere", lagethere)
			            setElementData(playerSource, "admin.givemoney", lagivemoney)
			            setElementData(playerSource, "admin.setmoney", lasetmoney)
						setElementData(playerSource, "admin.giveitem", lagiveitem)
			            setElementData(playerSource, "admin.adutyminute", laadutyminute)
			            setElementData(playerSource, "admin.fuelveh", lafuelveh)	
			            setElementData(playerSource, "admin.fixveh", lafixveh)
			            setElementData(playerSource, "admin.reply", lareply)
			            setElementData(playerSource, "admin.pm", lapm)
			            setElementData(playerSource, "admin.makeveh", lamakeveh)
			            setElementData(playerSource, "admin.jail", lajail)
			            setElementData(playerSource, "admin.ban", laban)
						setElementData(playerSource, "onPlayerJoin", true )
						
						fadeCamera(playerSource, true)
						requestAccounts(playerSource, id)
						local ip = getPlayerIP(playerSource)
						local serial = getPlayerSerial(playerSource)
						dbExec(connection,"UPDATE `users` SET `ip`=?, serial=? WHERE `id`=?",ip,serial,id)
					end
				end
			end
		else
		exports.ph_info:showBoxS(playerSource, "Nome de usuário ou senha inválidos", "error")
	end
end
)

 

Link to comment
10 hours ago, Angelo Pereira said:

Este painel de login ele faz login utilizando elemento, e não um LogIn.

Para resolver isto, você precisa adapta-lo para criar uma conta usando a função addAccount e depois LogIn.

Nesse meio, você precisará adiciona verificações para verificar a conta já não existe para não bugarem.

entendi vou tentar faze-lo

Link to comment
addEvent("onClientTryToCreateAccount", true)
addEventHandler("onClientTryToCreateAccount", getRootElement(),
	function(username, password)
		local value = dbQuery(connection, "SELECT * FROM `users`")
		local result = dbPoll (value, -1 )
		local serial = getPlayerSerial(source)
		password = string.reverse((key) .. (password))
		if result then
			for _, row in ipairs ( result ) do
				if string.lower(row["username"]) == username then
				   exports.ph_info:showBoxS(source, "Esse nome de usuário já existe", "error")
					return
				end
				if row["mtaserial"] == serial then
					exports.ph_info:showBoxS(source, "Você já tem uma conta", "error")
					return
				end
			end
		end
		exports.ph_info:showBoxS(source, "Registro bem sucedido!", "info")
		local data = dbExec(connection, "INSERT INTO users SET username = ?, password = ?, mtaserial = ?", username, password, serial)
		triggerClientEvent(source,"onRegisterFinish",source)
	end
)

No caso no onClientTryToCreateAccount eu colocaria o addAccount? E no onPlayerLogin o logIN?

addEvent("onPlayerLogin", false)
addEvent("onClientLoginRequest", true)
addEventHandler("onClientLoginRequest", getRootElement(),
	function(username, password)
		if (string.len(password)~=64) then
			password = string.reverse((key) .. (password))
		end	
		local lgnQuery = dbQuery(connection, "SELECT * FROM `users` WHERE `username`=? AND `password`=?", username, password )
		playerSource = client
		local lgnResult = dbPoll ( lgnQuery, -1 )
		if #lgnResult > 0 then
			for k, row in ipairs ( lgnResult ) do
				triggerEvent("onPlayerLogin", playerSource, username, password)
				local id = tonumber(row["id"])
				local pass = tonumber(row["password"])
				local found = false
				for key, v in ipairs(getElementsByType("player")) do
					local accid = tonumber(getElementData(v, "char.accountID"))
					if (accid) then
						if (accid==id) and (v~=playerSource) then
							found = true
							break
						end
					end
				end
				if not (found) then
					local admin = tonumber(row["admin"])
					local adminduty = tonumber(row["adminduty"])
					local adminjail = tonumber(row["adminjail"])
					local adminJailTime = tonumber(row["adminjail_time"])
					local adminJailBy = tostring(row["adminjail_by"])
					local adminJailReason = row["adminjail_reason"]
					local banned = tonumber(row["banned"])
					if tonumber(admin) == 0 then adminduty = 0 end
					setElementData(playerSource, "char.adminlevel", tonumber(admin))
					
					local lasethp = tonumber(row["asethp"])
			        local lasetarmor = tonumber(row["asetarmor"])
					local lasethunger = tonumber(row["asethunger"])
			        local lagoto = tonumber(row["agoto"])
			        local lagethere = tonumber(row["agethere"])
			        local lagivemoney = tonumber(row["agivemoney"])
			        local lasetmoney = tonumber(row["asetmoney"])
					local lagiveitem = tonumber(row["agiveitem"])
			        local laadutyminute = tonumber(row["adutyminute"])
			        local lafuelveh = tonumber(row["afuelveh"])	
			        local lafixveh = tonumber(row["afixveh"])
			        local lareply = tonumber(row["areply"])
			        local lapm = tonumber(row["apm"])
			        local lamakeveh = tonumber(row["amakeveh"])
			        local lajail = tonumber(row["ajail"])
			        local laban = tonumber(row["aban"])
					if (banned==1) then
						kickPlayer(source,"Brasil Play Hard","Sua conta está bloqueada")
					else
						setElementData(playerSource, "char.defaultUserName", username)
						setElementData(playerSource, "char.accountID", tonumber(id))
						setElementData(playerSource, "char.adminduty", tonumber(adminduty))
	                    setElementData(playerSource, "char.jailTime", adminJailTime)
						setElementData(playerSource, "char.jailReason", adminJailReason)
						setElementData(playerSource, "admin.sethp", lasethp)
			            setElementData(playerSource, "admin.setarmor", lasetarmor)
			            setElementData(playerSource, "admin.sethunger", lasethunger)
			            setElementData(playerSource, "admin.goto", lagoto)
			            setElementData(playerSource, "admin.gethere", lagethere)
			            setElementData(playerSource, "admin.givemoney", lagivemoney)
			            setElementData(playerSource, "admin.setmoney", lasetmoney)
						setElementData(playerSource, "admin.giveitem", lagiveitem)
			            setElementData(playerSource, "admin.adutyminute", laadutyminute)
			            setElementData(playerSource, "admin.fuelveh", lafuelveh)	
			            setElementData(playerSource, "admin.fixveh", lafixveh)
			            setElementData(playerSource, "admin.reply", lareply)
			            setElementData(playerSource, "admin.pm", lapm)
			            setElementData(playerSource, "admin.makeveh", lamakeveh)
			            setElementData(playerSource, "admin.jail", lajail)
			            setElementData(playerSource, "admin.ban", laban)
						setElementData(playerSource, "onPlayerJoin", true )
						
						fadeCamera(playerSource, true)
						requestAccounts(playerSource, id)
						local ip = getPlayerIP(playerSource)
						local serial = getPlayerSerial(playerSource)
						dbExec(connection,"UPDATE `users` SET `ip`=?, serial=? WHERE `id`=?",ip,serial,id)
					end
				end
			end
		else
		exports.ph_info:showBoxS(playerSource, "Nome de usuário ou senha inválidos", "error")
	end
end
)

 

Bem coloquei o addAccount no onClientTryToCreateAccount  e o logIN no onPlayerLogin , testei no meu local server e deu tudo certo, vou fazer mais alguns testes no local depois testo no meu Servidor.

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