ENTÃO GALERA ESTOU COMEÇANDO AGORA A MEXER COM MYSQL TENHO UM SERVER E EU BOTEI UMA PAINEL LOGIN LIGADO NO MEU SQL MAIS ELE SÓ REGISTRA E LOGA CONTAS NO MYSQL EU QUERIA QUE REGISTRA-SE E LOGA-SE NO MTA TAMBÉM PODEM ME AJUDAR ?
ESSE ABAIXO É O CLIENT !!!!!!!!!!!!!!!!!!!!
addEventHandler("onClientResourceStart", resourceRoot,
function()
setTimer(function()
if getElementData(localPlayer, "CharLoggedIn") then
triggerServerEvent("saveChar",localPlayer,localPlayer)
end
end, 5000, 0)
end
)
addEventHandler("onClientResourceStop", resourceRoot, function()
if getElementData(localPlayer, "CharLoggedIn") then
triggerServerEvent("saveChar",localPlayer,localPlayer)
end
end
)
local screenX,screenY = guiGetScreenSize ()
local sX, sY = guiGetScreenSize()
local sx, sy = guiGetScreenSize()
local s = {guiGetScreenSize()}
characterMainPosition = {2013.326171875, -1199.5458984375, 20.0234375, 292.23}
camPosition = {2020.1691894531, -1197.8117675781, 21.294700622559, 2019.2813720703, -1198.2447509766, 21.138776779175}
offX = math.sin (math.rad(characterMainPosition[4]+150)) * 3.5
offY = math.cos (math.rad(characterMainPosition[4]+150)) * 3.5
camPosition2 = {characterMainPosition[1]+offX, characterMainPosition[2]+offY, characterMainPosition[3]+1.5, characterMainPosition[1],characterMainPosition[2],characterMainPosition[3]+0.8}
local registrationData = {}
registrationData.rectangleX = sx/2-175
registrationData.rectangleY = sy/2-108
local camFading = 0
local camID = 0
local cams = {}
cams[1] = {}
cams[1]["start"] = {989.42987060547, -1145.4051513672, 50.296298980713, 990.40814208984, -1145.4158935547, 50.089214324951}
cams[1]["end"] = {1289.6910400391, -1145.3928222656, 60.02209854126, 1290.6010742188, -1145.3928222656, 59.607643127441}
cams[1]["duration"] = 30000
cams[1]["type"] = "Linear"
cams[2] = {}
cams[2]["start"] = {1903.8286132813, -1045.7442626953, 59.611099243164, 1904.4039306641, -1046.5063476563, 59.314086914063}
cams[2]["end"] = {2190.9453125, -1133.1026611328, 59.537700653076, 2190.1284179688, -1133.6090087891, 59.261646270752}
cams[2]["duration"] = 25000
cams[2]["type"] = "Linear"
cams[3] = {}
cams[3]["start"] = {2599.8889160156, -1843.7497558594, 31.999000549316, 2599.0422363281, -1844.1947021484, 31.707214355469}
cams[3]["end"] = {2591.3696289063, -1628.0297851563, 31.608600616455, 2590.4177246094, -1627.7821044922, 31.428340911865}
cams[3]["duration"] = 20000
cams[3]["type"] = "Linear"
cams[4] = {}
cams[4]["start"] = {182.54559326172, -1894.5426025391, 17.28630065918, 183.43125915527, -1894.0866699219, 17.198135375977}
cams[4]["end"] = {445.75, -1873.6237792969, 25.646200180054, 445.55960083008, -1872.6608886719, 25.455194473267}
cams[4]["duration"] = 25000
cams[4]["type"] = "Linear"
local lastCamTick = 0
camID = math.random(1,#cams)
lastCamTick = getTickCount ()
local loginData = {}
loginData.windowWidth = 283
loginData.windowHeight = 520
loginData.windowX = sx/2-(loginData.windowWidth/2)
loginData.windowY = sy/2-(loginData.windowHeight/2)
local progress = 0
local progress2 = 0
info = {}
local renderData = {}
renderData.font = dxCreateFont("files/font.ttf", 19, false, "cleartype")
renderData.font2 = guiCreateFont( "files/font.ttf", 10.8)
renderData.sWidth, renderData.sHeight = guiGetScreenSize()
renderData.wWidth, renderData.wHeight = renderData.sWidth / 2, renderData.sHeight / 2
local charselectData = {}
charselectData["charname"] = {}
charselectData["hunger"] = {}
charselectData["health"] = {}
charselectData["armor"] = {}
charselectData["lastarea"] = {}
charselectData["skin"] = {}
local data = {}
data.defaultWidth = 240
data.defaultHeight = 45
data.posX = sX - data.defaultWidth - 70
data.posY = 20
info.posX = sx/2
info.posY = sy/2
info.charSelectFont = dxCreateFont("files/font.ttf", 21, false, "cleartype")
function updateCamPosition ()
if cams[camID] then
local cTick = getTickCount ()
local delay = cTick - lastCamTick
local duration = cams[camID]["duration"]
local easing = cams[camID]["type"]
if duration and easing then
local progress = delay/duration
if progress < 1 then
local cx,cy,cz = interpolateBetween (
cams[camID]["start"][1],cams[camID]["start"][2],cams[camID]["start"][3],
cams[camID]["end"][1],cams[camID]["end"][2],cams[camID]["end"][3],
progress,easing
)
local tx,ty,tz = interpolateBetween (
cams[camID]["start"][4],cams[camID]["start"][5],cams[camID]["start"][6],
cams[camID]["end"][4],cams[camID]["end"][5],cams[camID]["end"][6],
progress,easing
)
setCameraMatrix (cx,cy,cz,tx,ty,tz)
if camFading == 1 then
local left = duration-delay
if left <= 3000 then
camFading = 1
fadeCamera (true,10,0,0,0)
end
elseif camFading == 2 then
local left = duration-delay
if left >= 2000 then
camFading = 0
end
end
else
local nextID = false
while nextID == false do
local id = math.random(1,#cams)
if id ~= camID then
nextID = id
end
end
camFading = 2
fadeCamera (true,60)
lastCamTick = getTickCount ()
camID = nextID
fadeCamera(true, 60)
setCameraMatrix (cams[camID]["start"][1],cams[camID]["start"][2],cams[camID]["start"][3],cams[camID]["start"][4],cams[camID]["start"][5],cams[camID]["start"][6])
end
end
end
end
function enableLoginInput (state)
if isElement(renderData.username) then
if guiGetEnabled(renderData.username) ~= state then
guiSetEnabled (renderData.username,state)
guiSetEnabled (renderData.password,state)
end
end
end
screenWidth, screenHeight = guiGetScreenSize()
windowWidth, windowHeight = 950, 600
left = (screenWidth/2) - (windowWidth/2)
top = (screenHeight/2) - (windowHeight/2)
windowLogoWidth, windowLogoHeight = 100, 100
lleft = (screenWidth/2) - (windowLogoWidth/2)
ltop = (screenHeight/2) - (windowLogoHeight/2)
function onClientClickToGui(dX, dY, dSz, dM, eX, eY)
if(eX >= dX and eX <= dX+dSz and eY >= dY and eY <= dY+dM) then
return true
else
return false
end
end
local showingLoginWindow = false
function showLoginWindow(state)
if state == true then
showingLoginWindow = true
if not isElement(musicElement) then
musicElement = playSound ("files/login.mp3")
setSoundVolume (musicElement,0.5)
end
addEventHandler("onClientRender",getRootElement(),drawRectangles)
addEventHandler("onClientKey", getRootElement(), onLoginKeyClick)
addEventHandler("onClientRender",getRootElement(),renderPanelText)
registrationData.loginButton = guiCreateButton(registrationData.rectangleX+330, registrationData.rectangleY+70, 110, 145, "Login", false)
registrationData.registerButton = guiCreateButton(registrationData.rectangleX-115, registrationData.rectangleY+65, 90, 145, "Inscreva-se", false)
guiSetAlpha(registrationData.loginButton, 0)
guiSetAlpha(registrationData.registerButton, 0)
addEventHandler("onClientGUIClick", registrationData.registerButton, registrationElements)
addEventHandler("onClientGUIClick", registrationData.loginButton, tryToLogin)
showNormalGui(true)
showCursor(true)
elseif state == false then
showingLoginWindow = false
destroy(registrationData.loginButton)
destroy(registrationData.registerButton)
removeEventHandler ("onClientPreRender",getRootElement(),updateCamPosition)
removeEventHandler("onClientKey", getRootElement(), onLoginKeyClick)
removeEventHandler("onClientRender",getRootElement(),drawRectangles)
removeEventHandler("onClientRender",getRootElement(),renderPanelText)
showNormalGui(false)
showCursor(false)
end
end
function drawRectangles()
exports.vz_blur:createBlur()
dxDrawRectangle(0, 0, sx, sy, tocolor(0, 0, 0, 120 ))
setFarClipDistance(1500)
setWeather (0)
renderData.bg = dxDrawImage(left-11, top, 950, 600, "files/loginbg.png")
end
function renderPanelText()
if renderData.uText or renderData.pwText then
local pwLength = string.len(renderData.pwText)
if pwLength > 0 then
renderData.pwText = ""
end
for i=1, pwLength do
renderData.pwText = renderData.pwText.."*"
end
dxDrawText(renderData.uText,renderData.wWidth - 100, renderData.wHeight - 11, 269, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(renderData.pwText,renderData.wWidth - 100, renderData.wHeight + 45, 269, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
end
end
function joinHandler()
if not getElementData(localPlayer, "CharLoggedIn") then
showLoginWindow (true,true)
local dim = getElementDimension(localPlayer)
local int = getElementDimension(localPlayer)
fadeCamera(true)
setElementData(localPlayer, "CharLoggedIn", false)
addEventHandler("onClientRender", getRootElement(), updateCamPosition)
local playerid = tonumber(getElementData(localPlayer, "dbid")) or 0
myDim = 10 + playerid
setElementDimension(localPlayer, myDim)
setElementDimension(localPlayer, dim)
setElementData(localPlayer, "char.timeSpent", 0, false)
setElementData(localPlayer, "dbid", false)
setElementData(localPlayer, "user.adminlevel", 0)
setElementData(localPlayer, "char.name", getPlayerName(localPlayer))
end
end
addEventHandler("onClientResourceStart", resourceRoot, joinHandler)
function stopDamage()
if not getElementData(localPlayer, "CharLoggedIn") then
cancelEvent()
end
end
addEvent("onRegisterFinish", true)
addEventHandler("onRegisterFinish", getRootElement(),
function ()
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
setTimer (
function ()
fadeCamera (true,2)
showLoginWindow (true,true)
showRegistrationPanel(false)
showCursor(true)
end
,1500,1)
end
)
addEvent("onSuccessLogin", true)
addEventHandler("onSuccessLogin", getRootElement(),
function ()
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
setTimer (
function ()
fadeCamera (true,2)
showCursor(false)
showRegistrationPanel(false)
showCharacterCreation(false)
showLoginWindow(false,false)
end
,1500,1)
end
)
local showNormalGuiState = false
function showNormalGui(state)
if showNormalGuiState ~= state then
if state == true then
showChat(false)
renderData.username = guiCreateEdit(renderData.wWidth - 105, renderData.wHeight - 17, 180, 25, "", false)
guiSetFont(renderData.username, renderData.font2)
guiSetAlpha(renderData.username, 0)
guiEditSetMaxLength(renderData.username, 25)
renderData.password = guiCreateEdit(renderData.wWidth - 105, renderData.wHeight + 35, 180, 25, "", false)
guiSetFont(renderData.password, "default-small")
guiSetAlpha(renderData.password, 0)
guiEditSetMaxLength(renderData.password, 25)
showNormalGuiState = true
elseif state == false then
destroy(renderData.username)
destroy(renderData.password)
showNormalGuiState = false
end
end
end
function registrationElements()
if isElement(registrationData.registerButton) then
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
setTimer (
function ()
fadeCamera (true,2)
showLoginWindow (false,false)
showRegistrationPanel(true)
showNormalGui(false)
end
,1500,1)
end
end
local registrationPanelState = false
function showRegistrationPanel(state)
if registrationPanelState ~= state then
if state == true then
registrationData.userNameEdit = guiCreateEdit(registrationData.rectangleX-48, registrationData.rectangleY+90, 230, 25, "", false)
guiSetFont(registrationData.userNameEdit, renderData.font2)
guiSetAlpha(registrationData.userNameEdit, 0)
guiEditSetMaxLength(registrationData.userNameEdit, 23)
registrationData.passwordEdit = guiCreateEdit(registrationData.rectangleX-48, registrationData.rectangleY+144, 230, 25, "", false)
guiSetFont(registrationData.passwordEdit, "default-small")
guiEditSetMasked(registrationData.passwordEdit, true)
guiSetAlpha(registrationData.passwordEdit, 0)
guiEditSetMaxLength(registrationData.passwordEdit, 23)
registrationData.passwordAgainEdit = guiCreateEdit(registrationData.rectangleX+210, registrationData.rectangleY+90, 230, 25, "", false)
guiSetFont( registrationData.passwordAgainEdit, "default-small")
guiEditSetMasked(registrationData.passwordAgainEdit, true)
guiSetAlpha(registrationData.passwordAgainEdit, 0)
guiEditSetMaxLength(registrationData.passwordAgainEdit, 23)
registrationData.emailEdit = guiCreateEdit(registrationData.rectangleX+210, registrationData.rectangleY+144, 230, 25, "", false)
guiSetFont(registrationData.emailEdit, renderData.font2)
guiSetAlpha(registrationData.emailEdit, 0)
guiEditSetMaxLength(registrationData.emailEdit, 50)
registrationData.acceptButton = guiCreateButton(registrationData.rectangleX+470, registrationData.rectangleY+70, 110, 145, "Inscreva-se", false)
registrationData.leftButton = guiCreateButton(registrationData.rectangleX-248, registrationData.rectangleY+65, 90, 145, "Voltar", false)
guiSetAlpha(registrationData.acceptButton, 0)
guiSetAlpha(registrationData.leftButton, 0)
addEventHandler("onClientGUIClick", registrationData.acceptButton, processRegistrationButton)
addEventHandler("onClientGUIClick", registrationData.leftButton, leftToLogin)
addEventHandler("onClientRender", getRootElement(), renderRegistration)
addEventHandler("onClientRender",getRootElement(),renderText)
registrationPanelState = true
showCursor(true)
elseif state == false then
destroy(registrationData.acceptButton)
destroy(registrationData.leftButton)
destroy(registrationData.userNameEdit)
destroy(registrationData.passwordEdit)
destroy(registrationData.passwordAgainEdit)
destroy(registrationData.emailEdit)
removeEventHandler("onClientRender", getRootElement(), renderRegistration)
removeEventHandler("onClientRender",getRootElement(),renderText)
registrationPanelState = false
showCursor(false)
end
end
end
function leftToLogin()
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
setTimer (
function ()
fadeCamera (true,2)
showLoginWindow (true,true)
showRegistrationPanel(false)
showCharacterCreation(false)
showCursor(true)
end
,1500,1)
end
addEventHandler("onClientGUIChanged", getRootElement(),
function (element)
if not getElementData(localPlayer, "CharLoggedIn") then
if isElement(registrationData.userNameEdit) or isElement(registrationData.passwordEdit) or isElement(registrationData.passwordAgainEdit) or isElement(registrationData.emailEdit) then
renderData.uname = guiGetText(registrationData.userNameEdit)
renderData.pw = guiGetText(registrationData.passwordEdit)
renderData.pw2 = guiGetText(registrationData.passwordAgainEdit)
renderData.email = guiGetText(registrationData.emailEdit)
end
end
end
)
function renderText()
if renderData.uname or renderData.pw or renderData.pw2 or renderData.email then
local lenght = string.len(renderData.pw)
if lenght > 0 then
renderData.pw = ""
end
for i=1, lenght do
renderData.pw = renderData.pw.."*"
end
local lenght1 = string.len(renderData.pw2)
if lenght1 > 0 then
renderData.pw2 = ""
end
for i=1, lenght1 do
renderData.pw2 = renderData.pw2.."*"
end
dxDrawText(renderData.uname,registrationData.rectangleX-45, registrationData.rectangleY+97, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(renderData.pw,registrationData.rectangleX-45, registrationData.rectangleY+155, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(renderData.pw2,registrationData.rectangleX+213, registrationData.rectangleY+101, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(renderData.email,registrationData.rectangleX+213, registrationData.rectangleY+151, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
end
end
function renderRegistration()
exports.vz_blur:createBlur()
renderData.bg = dxDrawImage(left-11, top, 950, 600, "files/register.png")
end
function processRegistrationButton()
if source == registrationData.acceptButton then
local username = tostring(guiGetText(registrationData.userNameEdit))
local password1 = tostring(guiGetText(registrationData.passwordEdit))
local password2 = tostring(guiGetText(registrationData.passwordAgainEdit))
local email = tostring(guiGetText(registrationData.emailEdit))
if string.len(username) >= 5 and string.len(username) <= 18 then
if password1 == password2 then
if string.len(password1) >= 6 and string.len(password2) <= 32 then
if email and (email):match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?") then
triggerServerEvent ("onClientTryToCreateAccount", localPlayer, guiGetText(registrationData.userNameEdit), guiGetText(registrationData.passwordEdit))
else
exports.vz_info:showBox("Endereço de email inválido","error")
end
else
exports.vz_info:showBox("A senha que você digitou é muito curta ou muito longa","error")
end
else
exports.vz_info:showBox("Senhas não coincidem","error")
end
else
exports.vz_info:showBox("O nome de usuário fornecido é muito curto ou longo","error")
end
end
end
addEventHandler("onClientGUIChanged", getRootElement(),
function (element)
if not getElementData(localPlayer, "CharLoggedIn") then
if isElement(renderData.username) and isElement(renderData.password) then
renderData.uText = guiGetText(renderData.username)
renderData.pwText = guiGetText(renderData.password)
end
end
end
)
function onLoginKeyClick (button,pressed)
if button == "enter" and pressed == true then
if isElement(renderData.username) and isElement(renderData.password) then
tryToLogin()
end
end
end
function tryToLogin ()
if guiGetEnabled (renderData.username) == true then
local username = guiGetText (renderData.username)
local password = guiGetText (renderData.password)
if string.len(username) >= 3 and string.len(username) <= 22 then
if string.len(password) >= 3 and string.len(password) <= 32 then
triggerServerEvent("onClientLoginRequest", getLocalPlayer(), username, password)
else
exports.vz_info:showBox("A senha que você digitou é muito curta ou muito longa", "error")
end
else
exports.vz_info:showBox("O nome de usuário fornecido é muito curto ou longo", "error")
end
end
end
function showChar(requestAcc)
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
removeEventHandler("onClientRender", getRootElement(), updateCamPosition)
playSoundFrontEnd(19)
setTimer(function()
showLoginWindow (false,false)
fadeCamera (true,2)
if #requestAcc > 0 then
setCameraMatrix (camPosition[1],camPosition[2],camPosition[3],camPosition[4],camPosition[5],camPosition[6])
charSelect()
destroy(renderData.username)
destroy(renderData.password)
showChat(false)
for k, v in pairs(requestAcc) do
charselectData["charname"][k] = requestAcc[k][1]
charselectData["skin"][k] = requestAcc[k][2]
end
if isElement(charselectPed) then return end
charselectPed = createPed(charselectData["skin"][1], 2013.326171875, -1199.5458984375, 20.0234375)
setElementDimension(charselectPed, 9999)
setElementRotation(charselectPed, 0, 0, 292)
setTimer (function()
end,7200,1)
setElementDimension(localPlayer, 9999)
setElementData (charselectPed,"visibleName",(string.gsub(charselectData["charname"][1], "_", " ")),false)
setElementData (charselectPed,"nameEnabled",true,false)
else
showCharacterCreation(true)
end
end, 1500, 1)
end
addEvent("createCharacterLogin", true)
addEventHandler("createCharacterLogin", getRootElement(), showChar)
local cameraMoveStartTick = nil
local cameraMoveDuration = 4000
function drawDxElements()
local name = string.gsub(charselectData["charname"][1], "_", " ")
selectimage = dxDrawImage(data.posX-350, data.posY+300, 950, 600, "files/select.png")
dxDrawText(name, data.posX+200, data.posY+562, data.posX, data.posY, tocolor(65, 105, 225, 255), 0.5, info.charSelectFont, "center")
end
function charSelect ()
bindKey("space", "down", spawnSelected)-- Botão usado para iniciar a sessão apos logar no servidor
addEventHandler("onClientRender", getRootElement(), drawDxElements)
end
function spawnSelected()
playSoundFrontEnd(19)
unbindKey("space", "down", spawnSelected)
setPedAnimation (charselectPed,"ped",-1)
removeEventHandler("onClientRender", getRootElement(), drawDxElements)
dxFadeCamera (true, 1500, 0,0,0)
fadeCamera (false,1.5,0,0,0)
setTimer(function()
fadeCamera (true,2)
triggerServerEvent("onClientCharacterRequest", getLocalPlayer(), string.gsub(charselectData["charname"][1], "_", " "))
showChat(true)
setFarClipDistance(700)
destroy(musicElement)
setTimer(function()
setElementData(localPlayer, "CharLoggedIn", true)
end,1000,1)
end, 1500, 1)
end
dxFadeState = nil
dxFade = {}
function dxFadeCamera (state, czas, r, g, b)
if state == true then
if dxFadeState == true then
removeEventHandler ("onClientRender", getRootElement(), renderFading)
else
removeEventHandler ("onClientRender", getRootElement(), renderHiding)
end
dxFade.startTime = getTickCount ()
dxFade.endTime = dxFade.startTime + czas
dxFade.startColor = {r,g,b,255}
dxFade.endColor = {r,g,b,0}
addEventHandler ("onClientRender", getRootElement(), renderFading)
dxFadeState = true
elseif state == false then
if dxFadeState == false then
removeEventHandler ("onClientRender", getRootElement(), renderHiding)
else
removeEventHandler ("onClientRender", getRootElement(), renderFading)
end
dxFade.startTime = getTickCount ()
dxFade.endTime = dxFade.startTime + czas
dxFade.startColor = {r,g,b,0}
dxFade.endColor = {r,g,b,255}
addEventHandler ("onClientRender", getRootElement(), renderHiding)
dxFadeState = false
end
end
function renderFading ()
local r1,g1,b1,a1 = dxFade.startColor[1],dxFade.startColor[2],dxFade.startColor[3],dxFade.startColor[4]
local r2,g2,b2,a2 = dxFade.endColor[1],dxFade.endColor[2],dxFade.endColor[3],dxFade.endColor[4]
local now = getTickCount()
local elapsedTime = now - dxFade.startTime
local duration = dxFade.endTime - dxFade.startTime
local progress = math.abs(elapsedTime / duration)
if elapsedTime < duration then
alpha = interpolateBetween (a2, 0, 0, a1, 0, 0, progress, "Linear")
else
alpha = 255
end
if alpha == 255 then
removeEventHandler ("onClientRender", getRootElement(), renderFading)
end
dxDrawRectangle (0,0, screenX, screenY, tocolor(r1, g1, b1, alpha), true)
end
function renderHiding ()
local r1,g1,b1,a1 = unpack(dxFade.startColor)
local r2,g2,b2,a2 = unpack(dxFade.endColor)
local now = getTickCount()
local elapsedTime = now - dxFade.startTime
local duration = dxFade.endTime - dxFade.startTime
local progress = math.abs(elapsedTime / duration)
if elapsedTime < duration then
local alpha = interpolateBetween (a1, 0, 0, a2, 0, 0, progress, "Linear")
else
local alpha = 0
end
dxDrawRectangle (0,0, screenX, screenY, tocolor(r1, g1, b1, alpha), true)
end
local showCharacterCreationState = false
characterData = {}
characterData.rectangleX = sx/2-175
characterData.rectangleY = sy/2-108
local skins = {1}
local skinPos = 1
function showCharacterCreation(state)
if showCharacterCreationState ~= state then
if state == true then
setCameraMatrix(2190.9453125, -1133.1026611328, 59.537700653076, 2190.1284179688, -1133.6090087891, 59.261646270752)
exports.vz_info:showBox("Agora crie um personagem", "info")
characterData.acceptButton = guiCreateButton(characterData.rectangleX+470, characterData.rectangleY+70, 110, 145, "", false)
guiSetAlpha(characterData.acceptButton,0)
guiSetFont(characterData.acceptButton, "default-bold-small")
guiSetProperty(characterData.acceptButton, "NormalTextColour", "FFAAAAAA")
addEventHandler("onClientGUIClick", characterData.acceptButton, processCharacterCreationButtons)
characterData.lastNameEdit = guiCreateEdit(characterData.rectangleX-48, characterData.rectangleY+90, 230, 25, "", false)
guiSetFont(characterData.lastNameEdit, renderData.font2)
guiSetAlpha(characterData.lastNameEdit,0)
characterData.ageEdit = guiCreateEdit(characterData.rectangleX-52, characterData.rectangleY+144, 100, 25, "", false)
guiSetFont(characterData.ageEdit, renderData.font2)
guiSetAlpha(characterData.ageEdit,0)
guiEditSetMaxLength(characterData.ageEdit, 2)
characterData.weightEdit = guiCreateEdit(characterData.rectangleX+210, characterData.rectangleY+90, 100, 25, "", false)
guiSetFont(characterData.weightEdit, renderData.font2)
guiSetAlpha(characterData.weightEdit,0)
guiEditSetMaxLength(characterData.weightEdit, 3)
characterData.heightEdit = guiCreateEdit(characterData.rectangleX+58, characterData.rectangleY+144, 100, 25, "", false)
guiSetFont(characterData.heightEdit, renderData.font2)
guiSetAlpha(characterData.heightEdit,0)
guiEditSetMaxLength(characterData.heightEdit, 3)
characterData.descriptionMemo = guiCreateMemo(characterData.rectangleX, characterData.rectangleY+10, 10, 10, "
[email protected]", false)
guiSetAlpha(characterData.descriptionMemo,0)
characterData.man = guiCreateButton(characterData.rectangleX+215, characterData.rectangleY+120, 25, 50, "Homem", false)
guiSetAlpha(characterData.man,0)
characterData.woman = guiCreateButton(characterData.rectangleX+320, characterData.rectangleY+120, 25, 50, "Mulher", false)
characterData.leftButton = guiCreateButton(characterData.rectangleX-248, characterData.rectangleY+65, 90, 145, "Voltar", false)
guiSetAlpha(characterData.leftButton,0)
guiSetAlpha(characterData.woman,0)
addEventHandler("onClientGUIClick", getRootElement(), button_click)
addEventHandler("onClientGUIClick", characterData.leftButton, leftToLogin)
addEventHandler("onClientRender", getRootElement(), renderCharacterCreation)
addEventHandler("onClientRender", getRootElement(), renderCharacterText)
showCharacterCreationState = true
showCursor(true)
elseif state == false then
destroy(characterData.acceptButton)
destroy(characterData.ageEdit)
destroy(characterData.weightEdit)
destroy(characterData.heightEdit)
destroy(characterData.lastNameEdit)
destroy(characterData.descriptionMemo)
destroy(characterData.leftButton)
destroy(characterData.man)
destroy(characterData.woman)
removeEventHandler("onClientRender", getRootElement(), renderCharacterCreation)
removeEventHandler("onClientRender", getRootElement(), renderCharacterText)
showCharacterCreationState = false
showCursor(false)
destroy(manimg)
destroy(womanimg)
end
end
end
addEventHandler("onClientGUIChanged", getRootElement(),
function (element)
if not getElementData(localPlayer, "CharLoggedIn") then
if isElement(characterData.lastNameEdit) or isElement(characterData.ageEdit) or isElement(characterData.weightEdit) or isElement(characterData.heightEdit) then
characterData.nameedit = guiGetText(characterData.lastNameEdit)
characterData.age = guiGetText(characterData.ageEdit)
characterData.weight = guiGetText(characterData.weightEdit)
characterData.height = guiGetText(characterData.heightEdit)
end
end
end
)
function renderCharacterText()
if characterData.nameedit or characterData.age or characterData.weight or characterData.height then
dxDrawText(characterData.nameedit,characterData.rectangleX-45, characterData.rectangleY+97, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(characterData.age,characterData.rectangleX-45, characterData.rectangleY+152, 230, 10, tocolor(235, 235, 255, 255), 0.5, renderData.font)
dxDrawText(characterData.weight,characterData.rectangleX+213, characterData.rectangleY+97, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
dxDrawText(characterData.height,characterData.rectangleX+65, characterData.rectangleY+152, 230, 10, tocolor(255, 255, 255, 204), 0.5, renderData.font)
end
end
function renderCharacterCreation()
exports.vz_blur:createBlur()
renderData.logo = dxDrawImage(left-11, top, 950, 600, "files/charcreation.png")
end
sex = 2
function button_click()
if (source==characterData.woman) and sex == 1 or sex == 2 then
womanimg = guiCreateStaticImage(characterData.rectangleX+314, characterData.rectangleY+131, 28, 37, "files/woman.png", false)
sex = 0
destroy(manimg)
elseif (source==characterData.man) and sex == 0 or sex == 2 then
manimg = guiCreateStaticImage(characterData.rectangleX+215, characterData.rectangleY+130, 28, 37, "files/man.png", false)
sex = 1
destroy(womanimg)
end
end
function processCharacterCreationButtons()
if source == characterData.createButton then
showCharacterCreation(not showCharacterCreationState)
elseif source == characterData.acceptButton then
local data = {}
local charname = tostring(guiGetText(characterData.lastNameEdit))
local age = tonumber(guiGetText(characterData.ageEdit))
local weight = tonumber(guiGetText(characterData.weightEdit))
local height = tonumber(guiGetText(characterData.heightEdit))
local sex = sex
local description = tostring(guiGetText(characterData.descriptionMemo))
if string.len(charname) >= 5 and string.len(charname) <= 20 then
if age >= 15 and age <= 90 then
if weight >= 40 and weight <= 200 then
if height >= 140 and height <= 220 then
if sex == 1 or sex == 0 then
if sex == 0 then
sex = 0
elseif sex == 1 then
sex = 1
end
if sex then
if string.len(description) >= 5 and string.len(description) <= 1000 then
data["age"] = age
data["weight"] = weight
data["height"] = height
data["gender"] = skins[skinPos]
data["description"] = description
data["skin"] = skin
triggerServerEvent("OnClientTryToCreateCharacter", localPlayer, charname,skins,age,sex)
end
end
else
exports.vz_info:showBox("Selecione um gênero para o seu personagem", "error")
end
else
exports.vz_info:showBox("A altura especificada é muito baixa ou muito alta", "error")
end
else
exports.vz_info:showBox("O peso especificado é muito pequeno ou muito grande", "error")
end
else
exports.vz_info:showBox("Muito baixa ou muito alta a idade especificada", "error")
end
else
exports.vz_info:showBox("O nome que você digitou é muito curto ou longo", "error")
end
end
end
function destroy(element)
if isElement(element) then
destroyElement(element)
end
end
-----------------------------------------------------------
ESSE ABAIXO É O SERVER
--------------------------------------------------------------
-- © [2019] Varzen Advanced [2019] © --
-- © Creditos: Varzen Advanced © --
-- © Facebook: https://www.facebook.com/VarzenAdvanced © --
-- © Youtube: http://www.youtube.com/c/VarzenBR © --
-- © Blog: https://varzenadvanced.blogspot.com/ © --
--------------------------------------------------------------
local connection = dbConnect("mysql",exports['vz_dbConnect']:getSQLData())
local key = "varzenadvanced2019"
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 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, "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)
setPedWalkingStyle(client, walkingstyle)
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.vz_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,"Server Name","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)
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.vz_info:showBoxS(playerSource, "Nome de usuário ou senha inválidos", "error")
end
end
)
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.vz_info:showBoxS(source, "Esse nome de usuário já existe", "error")
return
end
if row["mtaserial"] == serial then
exports.vz_info:showBoxS(source, "Você já tem uma conta", "error")
return
end
end
end
exports.vz_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
)
addEvent("OnClientTryToCreateCharacter", true)
addEventHandler("OnClientTryToCreateCharacter", getRootElement(),
function(charname, skins, age, sex)
local value = dbQuery(connection, "SELECT `charname` FROM `players` WHERE `charname` = ?", tostring(charname))
local result = dbPoll (value, -1)
local count = 0
local pw
cname = nil
if result then
for _, row in ipairs ( result ) do
cname = string.lower(row["charname"])
end
if cname ~= nil then
exports.vz_info:showBoxS(source, "O nome desse personagem já existe", "error")
return
end
end
dbFree(value)
local accountID = getElementData(source, "char.accountID")
data = dbExec( connection, "INSERT INTO `players` SET charname=?, account=?, intID=0, dimID=0, x=1481.06226, y=-1770.94824, z=18.79576, skin=0, age=?, gender=?", charname, accountID, age, sex)
setPlayerName(source, charname)
triggerClientEvent(source,"onSuccessLogin",source)
requestAccounts(source, accountID)
triggerClientEvent(source, "createCharacterLogin", source)
end
)
function requestAccounts(playerSource, id)
local requestAcc = {}
local query = dbQuery(connection, "SELECT id, charname,money, age, gender, skin, DATEDIFF(NOW(), lastlogin) FROM players WHERE account=?", id)
local result = dbPoll(query, -1)
if (#result>0) then
for k, data in ipairs (result) do
local i = 1
requestAcc[i] = {}
requestAcc[i][0] = tonumber(data["id"])
requestAcc[i][1] = tostring(data["charname"])
requestAcc[i][2] = tonumber(data["skin"])
requestAcc[i][3] = tonumber(data["money"])
i = i + 1
end
end
triggerClientEvent(playerSource, "createCharacterLogin", playerSource, requestAcc, true, true)
end
addEvent("requestAccounts", true)
addEventHandler("requestAccounts", getRootElement(), requestAccounts)
function saveChar()
if getElementData(source, "CharLoggedIn") then
local x, y, z = getElementPosition(source)
local rot = getPedRotation(source)
local health = getElementHealth(source)
local hunger = getElementData(source, "char.hunger") or 0
local age = getElementData(source, "age")
local gender = getElementData(source, "gender")
local armor = getPedArmor(source)
local interior = getElementInterior(source)
local dimension = getElementDimension(source)
local charname = getElementData(source, "charname")
local skin = getElementData(source, "char.skin")
local playedMinutes = getElementData(source, "char.playedMinutes")
local money = getElementData(source, "char.money")
local npoints = getElementData(source,"char.diamante")
local nsujo = getElementData(source,"char.moneysujo")
local factionID = getElementData(source,"char.factionID")
local factionLeader = getElementData(source,"char.factionLeader")
local factionRank = getElementData(source,"char.factionRank")
local badgeNumber = getElementData(source,"char.badgeNumber")
local dutySkin = getElementData(source,"char.dutySkin")
local bankMoney = getElementData(source, "char.bankMoney")
local adminlevel = getElementData(source, "char.adminlevel")
local jobID = getElementData(source, "char.jobID")
local jobName = getElementData(source, "char.jobName")
local radio = getElementData(source, "char.radio")
local showOOC = getElementData(source, "showOOC")
local showRadar = getElementData(source, "showRadar")
local drivingLicense = tostring(getElementData(source, "char.drivingLicense"))
local jailTime = getElementData(source, "char.jailTime")
local jailReason = getElementData(source, "char.jailReason") or "null"
local adminJail = getElementData(source, "char.adminJail")
local payTime = getElementData(source, "char.payTime")
local asethp = getElementData(source, "admin.sethp")
local asetarmor = getElementData(source, "admin.setarmor")
local asethunger = getElementData(source, "admin.sethunger")
local agoto = getElementData(source, "admin.goto")
local agethere = getElementData(source, "admin.gethere")
local agivemoney = getElementData(source, "admin.givemoney")
local agiveitem = getElementData(source, "admin.giveitem")
local asetmoney = getElementData(source, "admin.setmoney")
local aadutyminute = getElementData(source, "admin.adutyminute")
local afuelveh = getElementData(source, "admin.fuelveh")
local afixveh = getElementData(source, "admin.fixveh")
local areply = getElementData(source, "admin.reply")
local apm = getElementData(source, "admin.pm")
local amakeveh = getElementData(source, "admin.makeveh")
local ajail = getElementData(source, "admin.jail")
local aban = getElementData(source, "admin.ban")
local update = dbExec(connection,"UPDATE players SET x=?, y=?, z=?, rot=?, health=?,hunger=?, armor=?, dimID=?, intID=?, money=?, npoints=?, nsujo=?, factionID=?, factionLeader=?, factionRank=?, badgeNumber=?, dutySkin=?, lastlogin=NOW(), playedMinutes=?, skin=?, charname=?, jobID=?, jobName=?, bankMoney=?, drivinglicense=?, radiochannel=?, showHUD=?, showOOC=?, showRadar=?, payTime=?, age=?, gender=? WHERE id=?",x,y,z,rot,health,hunger,armor,dimension,interior,money,npoints,nsujo,factionID,factionLeader,factionRank,badgeNumber,dutySkin,playedMinutes,skin,charname,jobID,jobName,bankMoney,drivingLicense,radio,showHUD,showOOC,showRadar,payTime,age,gender,getElementData(source, "char.UID"))
local update2 = dbExec(connection,"UPDATE users SET lastlogin=NOW(), `admin`=?, adminjail_time=?, adminjail_reason=?, adminjail=? WHERE id = " .. getElementData(source,"char.accountID"),adminlevel, jailTime, jailReason, adminJail)
local update3 = dbExec(connection,"UPDATE users SET asethp=?, asetarmor=?, asethunger=?, agoto=?, agethere=?, agivemoney=?, asetmoney=?, agiveitem=?, adutyminute=?, afuelveh=?, afixveh=?, areply=?, apm=?, amakeveh=? WHERE id = " .. getElementData(source,"char.accountID"), asethp, asetarmor, asethunger, agoto, agethere, agivemoney, asetmoney, agiveitem, aadutyminute, afuelveh, afixveh, areply, apm, amakeveh, ajail, aban)
end
end
addEvent("saveChar", true)
addEventHandler("saveChar",getRootElement(),saveChar)
addEventHandler("onPlayerQuit", getRootElement(), saveChar)
addCommandHandler("ban",
function(playerSource,commandName,targetPlayer,ttime,...)
if getElementData(playerSource, "char.adminlevel") >= 5 then -- Administrador acima do nivel *5 pode banir
local ttime = tonumber ( ttime )
if targetPlayer and ttime then
local targetPlayer, targetPlayerName = exports.vz_main:findPlayerByPartialNick(source, targetPlayer)
if (getElementData(targetPlayer, "char.adminlevel") or 0) < getElementData(playerSource, "char.adminlevel") then
local pSerialC = getPlayerSerial(targetPlayer)
local duration = (ttime*60)*60
local reason = table.concat({...}, " ")
local adminName = getElementData(playerSource,"char.adminnick")
if ttime == 0 then
dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?",getElementData(targetPlayer, "char.accountID"), adminName ,23414590357, pSerialC, reason, targetPlayerName)
else
dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?",getElementData(targetPlayer, "char.accountID"), adminName ,getRealTime()["timestamp"]+duration, pSerialC, reason, targetPlayerName)
end
if ttime == 0 then
text = "Eterno"
else
text = ttime .. " hora"
end
dbExec(connection, "UPDATE users SET banned=1, banned_by=?, banned_reason=? WHERE id=?", adminName, reason, getElementData(targetPlayer, "char.accountID"))
kickPlayer(targetPlayer, adminName, reason )
setElementData(playerSource, "admin.ban", getElementData(playerSource, "admin.ban") + 1)
outputChatBox("#4169E1[Ban]: #ffffff" ..adminName .. " baniu o jogador " .. targetPlayerName .. "", root, 255, 255, 255, true)
outputChatBox("#4169E1[Ban]: #ffffffHora do banimento: " .. text .. " - Motivo: #4169E1" .. reason .. "", root, 255, 255, 255, true)
else
outputChatBox("#ff0000[Error]: #ffffffVocê não pode banir um administrador superior a você", playerSource, 255, 255, 255, true)
outputChatBox("#4169E1[Ban]: #ffffff"..getElementData(playerSource,"char.adminnick").." tentou banir um administrador do servidor", targetPlayer, 255, 255, 255, true)
end
else
outputChatBox("#4169E1[Use]:#ffffff /" .. commandName .. " [ID] [hora (0 - eterno)] [motivo]", playerSource, 208, 101, 29, true)
end
end
end
)
addCommandHandler("offban", -- Administrador acima do nivel *5 pode banir jogadores offline
function (thePlayer, commandName, targetPlayer, tttime, ...)
if getElementData(thePlayer, "char.adminlevel") >= 5 then
local tttime = tonumber(tttime)
if not (targetPlayer) or not (tttime) or not (...) then
outputChatBox("#4169E1[Use]: #ffffff/" .. commandName .. " [Nome Completo] [hora (0 - eterno)] [Motivo]", thePlayer , 255, 255, 255, true)
else
local targetPlayer = targetPlayer:gsub(" ", "_")
local targetPlayerName = targetPlayer:gsub("_", " ")
local adminName = getElementData(thePlayer,"char.adminnick")
local reason = table.concat({...}, " ")
local duration = (tttime*60)*60
if targetPlayer then
if (getElementData(targetPlayer, "char.adminlevel") or 0) < getElementData(thePlayer, "char.adminlevel") then
local qh = dbQuery(connection, "SELECT * FROM players WHERE charname='" .. targetPlayer .. "'")
local result, num = dbPoll (qh, -1)
if num == 0 then outputChatBox("#ff0000[Falha]: #ffffffEsse banimento não existe", thePlayer, 255, 255, 255, true) return end
if result then
for _, row in ipairs ( result ) do
id = tonumber(row["id"])
accountid = tonumber(row["account"])
end
if (accountid) then
local qh2 = dbQuery(connection, "SELECT * FROM users WHERE id='" .. accountid .. "'")
local result2 = dbPoll ( qh2, -1 )
if result2 then
for _2, row2 in ipairs ( result2 ) do
admin = tonumber(row2["admin"])
serial = row2["mtaserial"]
ip = row2["ip"]
end
if (admin) > (getElementData(thePlayer, "char.adminlevel")) then
outputChatBox("#ff0000[Falha]: #ffffffVocê não tem permissão", thePlayer, 255, 255, 255, true)
return
end
if tttime == 0 then
text = "Eterno"
else
text = tttime .. " Hora"
end
if tttime == 0 then
dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?", accountid, adminName ,23414590357, serial, reason, targetPlayer)
else
dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?", accountid, adminName ,getRealTime()["timestamp"]+duration, serial, reason, targetPlayer)
end
setElementData(thePlayer, "admin.ban", getElementData(thePlayer, "admin.ban") + 1)
dbExec(connection, "UPDATE users SET banned=1, banned_by=?, banned_reason=? WHERE id=?", adminName, reason, accountid)
outputChatBox("#4169E1[BAN Offline]: #ffffff" ..adminName .. " baniu " .. targetPlayerName .. "", root, 255, 255, 255, true)
outputChatBox("#4169E1[BAN Offline]: #ffffff" .. text .. " - Motivo: #4169E1" .. reason .. "", root, 255, 255, 255, true)
end
end
else
outputChatBox("#ff0000[Error]: #ffffffNenhum resultado encontrado", thePlayer, 255, 255, 255, true)
end
else
outputChatBox("#ff0000[Error]: #ffffffVocê não pode banir um administrador superior a você", thePlayer, 124, 9, 9, true)
outputChatBox("[BAN]:#ffffff "..adminName.." tentou banir um administrador do servidor", targetPlayer, 124, 9, 9, true) -- Quando um administrador tentar banir outro administrador, então aparece para todos administradores essa mensaguem
end
end
end
end
end)
addCommandHandler( "desbanir",
function (playerSource, cmd, target, ...)
if getElementData(playerSource, "char.adminlevel") >= 5 then
local reason = table.concat ( { ... }, " " )
local acc
local bannedNames = {}
local bannedSerials = {}
local bannedAccs = {}
local bannedBy = {}
if target and reason then
local query = dbQuery ( connection, "SELECT * FROM `bans`" )
local result = dbPoll ( query, -1 )
if result then
for k, rows in ipairs ( result ) do
if string.find( rows["playername"]:lower(), target:lower() ) then
table.insert ( bannedNames, rows["playername"] )
table.insert ( bannedSerials, rows["playerSerial"] )
table.insert ( bannedAccs, rows["accountid"] )
table.insert ( bannedBy, rows["bannedBy"] )
end
end
else
outputChatBox("#ff0000[Error]: #ffffffNão foi possível encontrar uma punição no nome dado", playerSource, 255, 255, 255, true)
end
if #bannedNames > 1 then
outputChatBox("#4169E1[SERVER NAME]: #ffffffTodas punições existentes do servidor", playerSource, 255, 255, 255, true)
for k, bans in ipairs ( bannedNames ) do
outputChatBox(bans, playerSource, 208, 101, 29, true)
end
bannedName = nil
bannedSerial = nil
bannedAccs = nil
bannedBy = nil
return
end
if #bannedNames == 0 then
outputChatBox("#ff0000[Error]: #ffffffNenhuma punição encontrada", playerSource, 124, 9, 9, true)
return
end
local exec = dbExec ( connection, "DELETE FROM bans WHERE playername = ?", bannedNames[1])
local exec = dbExec ( connection, "UPDATE `users` SET banned = 0 WHERE `id` = ?", bannedAccs[1])
outputChatBox("#4169E1[SERVER NAME]: #ffffffVocê desbaniu o jogador com sucesso", playerSource, 255, 255, 255, true)
bannedName = nil
bannedSerial = nil
bannedAccs = nil
bannedBy = nil
else
outputChatBox ("#4169E1[Use]: #ffffff/" .. cmd .. " [Nome Completo] [Motivo]", playerSource, 255, 255, 255, true)
end
end
end
)
--------------------------------------------------------
ALÉM DISSO QUANDO LOGA APARECE DOIS HUD AS VEZES E TODA VEZ O JOGADOR PERDE O DINHEIRO E NASCE COM 11K500 SE EU N ME ENGANO !!!!