Jump to content

setElementData HUD visible problem


Burak5312

Recommended Posts

hello when I logging in this script my hud is visible but reconnect and login after never see my hud help please

if i restart this resource visible only one time

i check with ZR:ShowMyHud visible

setFPSLimit(60)
function gInit_join()
setCameraMatrix(source, 0, 0, 400, 90, 360, 180, 0)
toggleControl(source, "radar", false)
end
addEventHandler("onPlayerJoin", getRootElement(), gInit_join)

function gInit_login(_, theCurrentAccount)
local playerEXP = getAccountData(theCurrentAccount, "ZR:EXP")
local playerLevel = getAccountData(theCurrentAccount, "ZR:Level")
setElementData(source, "ZR:EXP", playerEXP)
setElementData(source, "ZR:Level", playerLevel)
setElementData(source, "ZR:ShowMyHud", true)
fadeCamera(source, true)
showCursor(source, false)
end
addEventHandler("onPlayerLogin", getRootElement(), gInit_login)

function gInit_saveaccount()
local accounts = getPlayerAccount(source)
if (accounts) then
local EXP = getElementData(source, "ZR:EXP")
local Level = getElementData(source, "ZR:Level")
setAccountData(accounts, "ZR:EXP", EXP)
setAccountData(accounts, "ZR:Level", Level)
setElementData(source, "ZR:ShowMyHud", false)
end
end
addEventHandler("onPlayerQuit", getRootElement(), gInit_saveaccount)

function gInit_restart()                                   
local players = getElementsByType("player")
for key, player in ipairs(players) do
local account = getPlayerAccount(player)
if (not isGuestAccount(account)) then
      logOut(player)
 end
 setElementData(player, "ZR:ShowMyHud", false)
  end
end
addEventHandler("onResourceStart", getResourceRootElement(), gInit_restart)

function gInit_account(username, password)
if (username and password) then
local hashedPassword = passwordHash(password, "bcrypt", {})
if (hashedPassword) then
local account = addAccount(username, hashedPassword)
if (account) then
setAccountData(account, "hash_password", hashedPassword)
setAccountData(account, "ZR:Level", 5)
setAccountData(account, "ZR:EXP", 3533)
outputChatBox("REGISTER: Account successfuly created!", source, 0, 128, 0)
else 
	outputChatBox("REGISTER: Account already exists.", source, 255, 71, 61)
	end
 end
end

gInit_loginplayer(username, password)
end

addEvent("AcceptPlayer", true)
addEventHandler("AcceptPlayer", root, gInit_account)

function gInit_loginplayer(username, password)
if (username and password) then
local account = getAccount(username)
if (account) then
local hashedPassword = getAccountData(account, "hash_password")
if (passwordVerify(password, hashedPassword)) then
	if logIn(source, account, hashedPassword) then
	triggerClientEvent(source, "removePanel", source)
	setElementData(source, "ZR:ShowMyHud", true)
	end
	else
	outputChatBox("REGISTER: Username or Password is incorrect.", source, 255, 71, 61)
  end
end
else
	outputChatBox("REGISTER: Account doesn't exists.", 255, 71, 61)
	end
end
addEvent("loginPlayer", true)
addEventHandler("loginPlayer", root, gInit_loginplayer)

function gInit_logoutplayer(_, theCurrentAccount)
local exp = getElementData(source, "ZR:EXP")
local level = getElementData(source, "ZR:Level")
setAccountData(theCurrentAccount, "ZR:EXP", exp)
setAccountData(theCurrentAccount, "ZR:Level", level)
end
addEventHandler("onPlayerLogout", root, gInit_logoutplayer)

 

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