Jump to content

Black screen after logging in


Ryan2233

Recommended Posts

Hello. 

I have a login panel, and a spawn panel. Once the player has logged in/registered, a login panel should show up as soon as the login is successful and when the player dies, the spawn menu should show. But the panel only shows when the player dies, and a black screen when logging in. What do I do? 

Spoiler

local copTeams = {
["Gobierno"] = true,
["Policias"] = true,
["Squads"] = true,
["Navy Seals"] = true,
}

local immunityToStars = {
["Administradores"] = true,
["Exotic Cars"] = true,
["Navy Seals"] = true,
["Gobierno"] = true,
}

local immunityToFriendlyFire = {
["Administradores"] = true,
["Emergencias"] = true,
["Policias"] = true,
["Squads"] = true,
["Gobierno"] = true,
}

local immunityToBlip = {
["Gobierno"] = true,
}

local specialGroups = {
["Navy Seals"] = true,
["Talibanes"] = true,
["Gobierno"] = true,
}

local classesNoAccessToHospital = {
["Car Shooter"] = true,
["Alpha Team"] = true,
["Bravo Team"] = true,
["Recruitment Participator"] = true,
}

local playerCache = {}
local pip = 0

setGameType("SALT:RPG")
setMapName("San Andreas")

-- // Order Teams // -----------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function teamCreation()
createTeam("Administradores", 0, 102, 102)
createTeam("Gobierno", 180, 230, 230)
createTeam("San Andreas Eventos", 160, 220, 55)
createTeam("Talibanes", 75, 56, 35)
createTeam("Navy Seals", 0, 100, 0)
createTeam("Emergencias", 0, 255, 0)
createTeam("Policias", 144, 147, 198)
createTeam("Squads", 200, 202, 249)
createTeam("Civiles", 255, 200, 0)
createTeam("Compañias", 238, 240, 115)
createTeam("Criminales", 150, 10, 10)
createTeam("Crews", 250, 10, 10)
createTeam("Cartel de Los Santos", 42, 10, 10)
createTeam("San Andreas Construccion", 204, 153, 10)
end
addEventHandler("onResourceStart", resourceRoot, teamCreation)

-- // Spawn Player // -----------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function receiveSpawnData(player, x, y, z, rotation, interior, dimension, nameOfTeam, nameOfClass, idOfSkin, colorsOfClass, weaponsOfClass, cityOfClass, restrictionOfClass)
if player then
if x then
if y then
if z then
if rotation then
if interior then
if dimension then
if nameOfTeam then
if nameOfClass then
if nameOfClass then
if idOfSkin then
if colorsOfClass then
if weaponsOfClass then
if cityOfClass then
if restrictionOfClass then
if not player then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar al reproductor.") end
if not x then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar la coordenada X del spawn.") end
if not y then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar la coordenada Y del spawn.") end
if not z then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar la coordenada Z del spawn.") end
if not rotation then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar la coordenada R del spawn.") end
if not interior then return outputConsole("[SPAWN] An error has occured while trying to identify the interior of the spawn.") end
if not dimension then return outputConsole("[SPAWN] An error has occured while trying to identify the dimension of the spawn.") end
if not nameOfTeam then return outputConsole("[SPAWN] An error has occured while trying to identify the name of the team.") end
if not nameOfClass then return outputConsole("[SPAWN] An error has occured while trying to identify the name of the spawn.") end
if not idOfSkin then return outputConsole("[SPAWN] An error has occured while trying to identify the skin id of the spawn.") end
if not colorsOfClass then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar el color del spawn.") end
if not weaponsOfClass then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar los identificadores de arma del spawn.") end
if not cityOfClass then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar el id de ciudad del spawn.") end
if not restrictionOfClass then return outputConsole("[SPAWN] Se ha producido un error al intentar identificar la restricción del spawn.") end
if exports.SALTacl:isPlayerInGroup(player, "hq") or requestPermissionSuccess(player, restrictionOfClass, nameOfClass, nameOfTeam) then
local team = getTeamFromName(nameOfTeam)
if (not team) then
team = createTeam(nameOfTeam, tonumber(colorsOfClass[1]), tonumber(colorsOfClass[2]), tonumber(colorsOfClass[3]))
end
spawnPlayer(player, tonumber(x), tonumber(y), tonumber(z), tonumber(rotation), tonumber(idOfSkin), tonumber(interior), tonumber(dimension), team)
triggerClientEvent(player, "SALTrpg.deleteSelection", player)
if immunityToFriendlyFire[nameOfTeam] then
setTeamFriendlyFire(team, false)
end
if immunityToStars[nameOfTeam] then
exports.SALTpolice:setWantedLevel(player, 0)
end
if specialGroups[nameOfTeam] then
setPedArmor(player, 100)
end
if immunityToBlip[nameOfTeam] then
createBlipAttachedTo(player, 0, 2, tonumber(colorsOfClass[1]), tonumber(colorsOfClass[2]), tonumber(colorsOfClass[3]), 0, 0, 0)
else
createBlipAttachedTo(player, 0, 2, tonumber(colorsOfClass[1]), tonumber(colorsOfClass[2]), tonumber(colorsOfClass[3]), 255, 0, 400)
end
setPlayerNametagColor(player, tonumber(colorsOfClass[1]), tonumber(colorsOfClass[2]), tonumber(colorsOfClass[3]))
setElementData(player, "class", tostring(nameOfClass))
setElementData(player, "team", tostring(nameOfTeam))
fadeCamera(player, true)
setCameraTarget(player, player)
if (weaponsOfClass) then
for weapon, ammo in pairs(weaponsOfClass) do
if weapon and ammo then
giveWeapon(player, tonumber(weapon), tonumber(ammo), false)
end
end
end
if getPlayerMoney(player) == 0 then
exports.SALTcommands:giveMoney(player, 100)
end
setPlayerHudComponentVisible(player, "all", true)
triggerEvent("onPlayerSpawned", player, x, y, z, rotation, interior, dimension, nameOfTeam, nameOfClass, idOfSkin, colorsOfClass, weaponsOfClass, cityOfClass, restrictionOfClass)
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
addEvent("sendSpawnData", true)
addEventHandler("sendSpawnData", getRootElement(), receiveSpawnData)
	 
function requestPermissionSuccess(player, restriction, class, team)
if player then
if restriction then
if (getElementType(player) == "player") then
if copTeams[team] and tonumber(getElementData(player, "wanted")) > 0 then return end
local getRestriction = split(restriction, string.byte(","))
if getRestriction[1] == "everyone" or getRestriction[1] == "none" then
for _, v in ipairs(getRestriction) do
return true
end
elseif getRestriction[1] == "gang" then
for _, v in ipairs(getRestriction) do
local check = tostring(getElementData(player, "SALTgang"))
if check == v then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "Necesitas ser parte de ".. v .." para acceder a este spawn.")
end
end
elseif getRestriction[1] == "group" then
for _, group in ipairs(getRestriction) do
if exports.SALTacl:isPlayerInGroup(player, group) then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes acceso a este spawn ya que no eres parte de este grupo.")
end
end
elseif getRestriction[1] == "acl" then
for _, acl in ipairs(getRestriction) do
local account = getAccountName(getPlayerAccount(player))
if isObjectInACLGroup("user."..account, aclGetGroup(getRestriction[2])) then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes acceso a este spawn ya que no eres parte de este grupo.")
end
end
elseif getRestriction[1] == "account" then
for _, v in ipairs(getRestriction) do
local account = getElementData(player, "username")
if account == v then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes acceso a este spawn ya que no eres parte de este grupo.")
end
end
elseif getRestriction[1] == "wanted" then
for _, wanted in ipairs(getRestriction) do
local wanted = getElementData(player, "wanted")
if getRestriction[2] == "false" and tonumber(wanted) == 0 then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "Necesitas perder tus estrellas deseadas para engendrar como esta clase.")
end
end
elseif getRestriction[1] == "level" then
for _, v in ipairs(getRestriction) do
local level = getElementData(player, "level")
if tonumber(level) >= tonumber(getRestriction[2]) then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes el nivel adecuado para desovar como esta clase.")
end
end
elseif getRestriction[1] == "police" then
for _, v in ipairs(getRestriction) do
local level = getElementData(player, "policelevel")
local wanted = getElementData(player, "wanted")
if tonumber(level) >= tonumber(getRestriction[2]) and tonumber(wanted) == 0 then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes el nivel adecuado para desovar como esta clase.")
end
end
elseif getRestriction[1] == "limited" then
for _, v in ipairs(getRestriction) do
local limited = tonumber(getMembersInProfession(class))
if tonumber(limited) <= tonumber(getRestriction[2]) then
return true
else
triggerClientEvent(player, "SALTrpg.showError", player, "No tienes el nivel adecuado para desovar como esta clase.")
end
end
end
end
end
end
end

function getMembersInProfession(profession)
pip = 0
for i, v in ipairs(getElementsByType("player")) do
if getElementData(v, "class") == profession then
pip = pip + 1
end
end
return tonumber(pip) or 0
end

addEventHandler("onResourceStart",resourceRoot,function()
for k, v in ipairs(getElementsByType("player")) do
if getElementData(v, "loggedIn") then
triggerEvent("onPlayerLogOut", v)
end
if not isPedDead(v) then
killPed(v)
end
setElementData(v, "class", "N/A")
end
end)

function onPlayerWastedTriggerHospital()
if getElementData(source, "loggedIn") then
if classesNoAccessToHospital[getElementData(source, "class")] then return
triggerClientEvent(source, "SALTrpg.showSelection", source)
end
triggerClientEvent(source, "SALTrpg.showHospital", source)
setElementData(source, "reanimation", false)
setElementData(source, "reanimationtime", true)
end
local blips = getAttachedElements(source)
if blips then
for _, blip in ipairs(blips) do
if isElement(blip) and getElementType(blip) == "blip" then
destroyElement(blip)
end
end
end
end
addEventHandler("onPlayerWasted", root, onPlayerWastedTriggerHospital)

addEventHandler("onPlayerLogIn", getRootElement(), function(id, username)
if playerCache and playerCache[id] then
local cache = playerCache[id]
local class = cache["class"]
if classesNoAccessToHospital[class] then 
return 
triggerClientEvent(source, "SALTrpg.showSelection", source) 
end
if cache["x"] and cache["y"] and cache["z"] and cache["skin"] and cache["interior"] and cache["dimension"] and cache["class"] and cache["r"] and cache["g"] and cache["b"] then
if not getTeamFromName(cache["team"]) then
triggerClientEvent(source, "SALTrpg.showSelection", source)
end
local nameOfTeam = cache["team"]
spawnPlayer(source, cache["x"], cache["y"], cache["z"], 0, cache["skin"], cache["interior"], cache["dimension"], getTeamFromName(cache["team"]))
setElementData(source, "class", cache["class"])
setElementData(source, "team", cache["team"])
local weps = cache["weapons"]
if weps and weps ~= "" then
local theWeps = split(weps,string.byte(";"))
for k,v in ipairs(theWeps) do
local wepData = split(v,string.byte(","))
giveWeapon(source, wepData[1], wepData[2], false)
end
end
if getPlayerMoney(source) == 0 then
exports.SALTcommands:giveMoney(source, 100)
end
setPlayerHudComponentVisible(source, "all", true)
setPlayerNametagColor(source, cache["r"], cache["g"], cache["b"])
if immunityToBlip[nameOfTeam] then
createBlipAttachedTo(source, 0, 2, cache["r"], cache["g"], cache["b"], 0, 0, 0)
else
createBlipAttachedTo(source, 0, 2, cache["r"], cache["g"], cache["b"], 255, 0, 400)
end
setCameraTarget(source)
fadeCamera(source, true)
else
triggerClientEvent(source, "SALTrpg.showSelection", source)
end
else
triggerClientEvent(source, "SALTrpg.showSelection", source)
end
end)

function onPlayerQuitHandler()
local blips = getAttachedElements(source)
if blips then
for k,v in ipairs(blips) do
if isElement(v) and getElementType(v) == "blip" then
destroyElement(v)
end
end
end
if not isPedDead(source) then
if classesNoAccessToHospital[getElementData(source, "class")] then return end
local cache = {}
cache["class"] = getElementData(source,"class")
cache["skin"] = getElementModel(source)
local team = getPlayerTeam(source)
if team then
cache["team"] = getTeamName(team)
end
local x,y,z = getElementPosition(source)
local int = getElementInterior(source)
local dim = getElementDimension(source)
cache["x"], cache["y"], cache["z"], cache["interior"], cache["dimension"] = x, y, z, int, dim
local r, g, b = getPlayerNametagColor(source)
cache["r"], cache["g"], cache["b"] = r, g, b
local wepStr = ""
for slot=0,12 do
if getPedWeapon(source,slot) ~= 0 then
local weapon = getPedWeapon(source,slot)
local ammo = getPedTotalAmmo(source,slot)
if wepStr == "" then
wepStr = tostring(weapon)..","..tostring(ammo)
else
wepStr = wepStr..";"..tostring(weapon)..","..tostring(ammo)
end
end
end
cache["weapons"] = wepStr
local id = getElementData(source, "id")
if id then
playerCache[id] = cache
end
end
end
addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuitHandler)

addEventHandler("onPlayerJoin", root, function() setElementData(source, "class", "N/A") end)

function queryHouses()
local username = getElementData(source, "username")
local query = executeSQLQuery("SELECT * FROM `housing` WHERE `Owner`=?",username)
local propTable = {}
for i, v in ipairs(query) do
local result = executeSQLQuery("SELECT * FROM `housing` WHERE `id`=?", v.id)
if result and #result > 0 then
local houseN = string.gsub(v.Name, "_", " ")
local houseName = string.gsub(houseN, "%.", " ")
propTable[houseName] = {result[1].ColX, result[1].ColY, result[1].ColZ, 0, 0}
end
end
triggerClientEvent(source, "SALTrpg.fillHousesGrid", source, propTable)
end
addEvent("SALTrpg.queryHouses", true)
addEventHandler("SALTrpg.queryHouses", root, queryHouses)


local spawnHospital = {
{2024.896484375, -1403.8828125, 17.206462860107, 180}, -- [Los Santos] --
{1172.7059326172, -1323.3139648438, 15.401785850525, 270}, -- [Los Santos 2] --
{-2642.9506835938, 638.62683105469, 14.453125, 180}, -- [San Fierro] --
{1615.5603027344, 1816.6477050781, 10.8203125, 2.2782709598541}, -- [Las Venturas] --
{-321.97262573242, 1055.2932128906, 19.7421875, 360}, -- [Bone County] --
{-2198.998046875, -2305.5822753906, 30.625, 233.57861328125}, -- [Whestone] --
{1244.3660888672, 331.98379516602, 19.5546875, 335.95263671875}, -- [Red County] --
{-432.65588378906, 2191.4252929688, 42, 312.96881103516}, -- [Ghost Town] --
}

function findNearestHospital(player)
distanceToHospital = 9999999999
local wastedX, wastedY, wastedZ = getElementPosition(player)
for k, v in ipairs(spawnHospital) do
local loopX, loopY, loopZ, loopRot = v[1], v[2], v[3], v[4]
newDistance = getDistanceBetweenPoints3D(wastedX, wastedY, wastedZ, loopX, loopY, loopZ)
if newDistance < distanceToHospital then
distanceToHospital = newDistance
hospitalX = loopX
hospitalY = loopY
hospitalZ = loopZ
hospitalRot = loopRot
end
end
return hospitalX, hospitalY, hospitalZ, hospitalRot
end

-- local hospitalTimer = {}
function spawnAtNearestHospital(savedWeapons)
local team = getPlayerTeam(source)
if not team then return end
if team then
local nameOfTeam = getTeamName(team)
local r, g, b = getPlayerNametagColor(source)
local skin = getElementModel(source)
local posX, posY, posZ, posRot = findNearestHospital(source)
spawnPlayer(source, posX, posY, posZ, posRot, skin, 0, 0, team)
if immunityToBlip[nameOfTeam] then
createBlipAttachedTo(source, 0, 2, r, g, b, 0, 0, 0)
else
createBlipAttachedTo(source, 0, 2, r, g, b, 255, 0, 400)
end
-- if isTimer(hospitalTimer[source]) then killTimer(hospitalTimer[source]) end
-- if getElementData(source, "hospitaltimer") then setElementData(source, "hospitaltimer", false) end
-- setElementData(source, "hospitaltimer", true)
-- hospitalTimer[source] = setTimer(setElementData, 30000, 1, source, "hospitaltimer", false)
setPlayerNametagColor(source, r, g, b)
for i, t in ipairs(savedWeapons) do
giveWeapon(source, t[1], t[2])
end
fadeCamera(source,true)
setCameraTarget(source, source)
end
end
addEvent("spawnPlayerAtHospital", true)
addEventHandler("spawnPlayerAtHospital", root, spawnAtNearestHospital)

function reanimatePlayer(savedWeapons, dimP, intP)
setElementData(source, "reanimation", false)
setElementData(source, "time", false)
local skin = getPedSkin(source)	
local team = getPlayerTeam(source)
if not team then return end
if team then
local nameOfTeam = getTeamName(team)
local r, g, b = getPlayerNametagColor(source)
local posX, posY, posZ = getElementPosition(source)
local interior = getElementInterior(source)
local dimension = getElementDimension(source)
spawnPlayer(source, posX, posY, posZ, 0, skin, interior, dimension, team)
if immunityToBlip[nameOfTeam] then
createBlipAttachedTo(source, 0, 2, r, g, b, 155, 0, 0)
else
createBlipAttachedTo(source, 0, 2, r, g, b, 255, 0, 400)
end
setPlayerNametagColor(source, r, g, b)
setElementInterior(source, intP)
setElementDimension(source, dimP)
setElementHealth(source, 30)

for i, t in ipairs(savedWeapons) do
giveWeapon(source, t[1], t[2])
end

fadeCamera(source,true)
setCameraTarget(source,source)
end
end
addEvent("REANIMATEPLAYER", true)
addEventHandler("REANIMATEPLAYER", root, reanimatePlayer)

function callFromRevive()
triggerClientEvent("resetReanimation", root)
end
addEvent("callRevive",true)
addEventHandler("callRevive",root, callFromRevive)

function resetPlayerCache(source, cmd, id)
if not exports.SALTacl:isPlayerInGroup(source, "hq") or not id then return end
if playerCache[id] then
playerCache[id] = nil
exports.SALTcommands:sendMessage("*INFO* Player id reset.", 0, 255, 0, source)
else
exports.SALTcommands:sendMessage("*INFO* El id no existe.", 255, 0, 0, source)
end
end
addCommandHandler("resetid", resetPlayerCache)

function findPlayerId(source, cmd, account)
if not exports.SALTacl:isPlayerInGroup(source, "hq") or not account then return end
local query = executeSQLQuery("SELECT id FROM playerdata WHERE account = '"..account.."' LIMIT 1")
if query and query[1] then
exports.SALTcommands:sendMessage("*INFO* ".. account .." id: ".. tostring(query[1].id) ..".", 0, 255, 0, source)
else
exports.SALTcommands:sendMessage("*INFO* Cuenta no encontrada.", 255, 0, 0, source)
end
end
addCommandHandler("id", findPlayerId)

The spawn panel server.lua ^ 

 

Spoiler


local bannedUsernames = {
["everyone"] = true,
["nil"] = true,
["none"] = true,
["guest"] = true,
["console"] = true,
["admin"] = true,
["moderator"] = true,
["supermoderator"] = true,
["rpg"] = true,
["SALT"] = true,
["[SALT]"] = true,
["s_a_c_h"] = true,
["housing"] = true,
["staff"] = true,
["housing_agent"] = true,
["larpg"] = true,
};

function logInPlayer(username, password)
if getElementData(source, "loggedIn") then
return triggerClientEvent(source, "showLoginError", source, "Account already connected.")
end
local name = getPlayerName(source)
local query = executeSQLQuery("SELECT `id`,`log` FROM `playerdata` WHERE `account`=? AND `password`=? LIMIT 1", username, password)
if query and #query > 0 then
if (query[1].log == 1) then 
return triggerClientEvent(source, "showLoginError", source, "Account already connected.")
end
local data = setElementData(source, "username", username)
local id = setElementData(source, "id", query[1].id)
if data and id then
local ip = getPlayerIP(source)
local serial = getPlayerSerial(source)
local time = getRealTime()
local months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
local day = ("%02d"):format(time.monthday)
local month = months[time.month + 1]
local year = ("%02d"):format(time.year + 1900)
local weekday = days[time.weekday + 1]
local hours = time.hour
local minutes = time.minute
local seconds = time.second
if (hours >= 0 and hours < 10) then
hours = "0"..time.hour
end
if (minutes >= 0 and minutes < 10) then
minutes = "0"..time.minute
end
if (seconds >= 0 and seconds < 10) then
seconds = "0"..time.second
end
executeSQLQuery("UPDATE playerdata SET login = '".. month .." ".. day ..", ".. year .."', serial = '"..serial.."', username = '".. getPlayerName(source) .."', log = 1, ip ='".. ip .."' WHERE account = '".. username .."'")
setElementData(source, "loggedIn", true)
triggerEvent("onPlayerLogIn", source, query[1].id, username, password)
triggerClientEvent(source, "deleteLoginPanels", source)
outputChatBox("You have successfully logged in as #00FF00".. username .."#FFFFFF.", source, 255, 255, 255, true)
else
triggerClientEvent(source, "showLoginError", source, "An error occurred while trying to sign in.")
end
elseif query then
triggerClientEvent(source, "showLoginError", source, "Incorrect password.")
else
triggerClientEvent(source, "showLoginError", source, "An error has occurred. Please try again.")
end
end
addEvent("sendLogin", true)
addEventHandler("sendLogin", getRootElement(), logInPlayer)

function registerInPlayer(username, password, email, serial)
if username and email then
if not bannedUsernames[username] then
if not username:match("[%s%p]") then
local serialQuery = executeSQLQuery("SELECT * FROM `playerdata` WHERE `serial`=?", serial)
if serialQuery and #serialQuery == 1 then return
triggerClientEvent(source, "showRegisterError", source, "You already have an account on this server.")
end
local query = executeSQLQuery("SELECT id FROM playerdata WHERE account=? LIMIT 1", username)
local account = getAccount(username)
if query and #query == 0 and account == false then
local time = getRealTime()
local months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
local day = ("%02d"):format(time.monthday)
local month = months[time.month + 1]
local year = ("%02d"):format(time.year + 1900)
local weekday = days[time.weekday + 1]
local hours = time.hour
local minutes = time.minute
local seconds = time.second
if (hours >= 0 and hours < 10) then
hours = "0"..time.hour
end
if (minutes >= 0 and minutes < 10) then
minutes = "0"..time.minute
end
if (seconds >= 0 and seconds < 10) then
seconds = "0"..time.second
end
local ip = getPlayerIP(source)
local accountConvert = math.random(100,900)
if executeSQLQuery("INSERT INTO `playerdata` (`account`,`password`,`email`,`serial`,`groups`,`money`,`wanted`,`sentenced`,`registered`,`username`,`login`,`log`,`ip`) VALUES('".. username .."','".. password .."','".. email .."','".. serial .."','everyone','0','0','0','".. weekday ..", ".. month .." ".. day .." ".. year .." ".. hours ..":".. minutes ..":".. seconds .."','".. getPlayerName(source) .."','".. month .." ".. day ..", ".. year .."','0','".. ip .."')") then
triggerClientEvent(source, "showRegisterError", source, "¡Registrado exitosamente! Cuenta: ".. username ..".")
addAccount(username, password)
else
triggerClientEvent(source, "showRegisterError", source, "An error occurred while trying to register.")
end
elseif query and #query > 0 then
triggerClientEvent(source, "showRegisterError", source, "This username is already in use.")				
else
triggerClientEvent(source, "showRegisterError", source, "An error occurred while trying to register.")		
end
else
triggerClientEvent(source, "showRegisterError", source, "An error occurred while trying to register.")
end
else
triggerClientEvent(source, "showRegisterError", source, "This username is prohibited to be used on the server.")
end
end
end
addEvent("sendRegistration", true)
addEventHandler("sendRegistration", getRootElement(), registerInPlayer)

function checkPlayer(player, serial)
if player and serial then
local query = executeSQLQuery("SELECT `account`,`password` FROM `playerdata` WHERE `serial`=?", serial)
if query and #query > 0 then
local account = query[1]["account"]
local password = query[1]["password"]
triggerClientEvent(player, "loadUpDetails", player, account, password)
end
end
end
addEvent("checkPlayer", true)
addEventHandler("checkPlayer", getRootElement(), checkPlayer)

function setLogOutData()
local id = getElementData(source, "id")
if id then
executeSQLUpdate("playerdata","log = 0","id = "..id)
end
end
addEventHandler("onPlayerQuit", root, setLogOutData)

addEvent("onPlayerLogOut",true)
addEventHandler("onPlayerLogOut",root,function()
setElementData(source, "loggedIn", false)
local username = getElementData(source, "username")
local id = getElementData(source, "id")
if id then
executeSQLUpdate("playerdata","log = 0","id = "..id)
end
if not username then username = "N/A" end
setElementData(source, "username", nil)
setElementData(source, "id", nil)
triggerClientEvent(source, "showLoginCreation", source)
killPed(source)
setElementInterior(source, 0)
setElementDimension(source, 0)
end)

 

^ login panel server

 


Thanks

 

 

 

 

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