Jump to content

Agencia Empregos Sem Funcionar


Recommended Posts

Opa eu quero ligar um sistema de level junto com uma agencia de empregos pois ela n ta funcionando abre o menu e na hr de selecionar o emprego n acontece nada

 

Vou deixar os dois aqui

 

 

Sistema Level

Arc._c.Lua

local sx,sy = guiGetScreenSize() 
local px,py = 1366,768
local x,y =  (sx/px),(sy/py)

function drawLevel ()
	local levelProgress = (getElementData(localPlayer,"minutes") or 0)
	dxDrawRectangle(x*803, y*743, x*160/58*levelProgress, y*19, tocolor(0, 0, 0, 130), false)
	dxDrawRectangle(x*800, y*740, x*170, y*25, tocolor(0, 0, 0, 120), false)
	dxDrawText("LEVEL: "..(getElementData(localPlayer,"Level") or 0), x*854, y*746, x*10, y*10, tocolor(255, 255, 255, 255), x*0.9, "default", "left", "top", false, false, false, false, false)
end
addEventHandler("onClientRender",getRootElement(),drawLevel)

 

Arc_s.Lua

 

function upLevel (thePlayer)
    for i,player in ipairs(getElementsByType("player")) do
        if ( player ) then
            if ( getPlayerAccount(player) ) and not ( isGuestAccount(getPlayerAccount(player)) ) then
                setElementData(player,"minutes",(getElementData(player,"minutes") or 0) +1)
                if ( getElementData(player,"minutes") > 59 ) then
                    setElementData(player,"minutes",0)
                    setElementData(player,"Level",(getElementData(player,"Level") or 0) +1)
                        local bonus = math.random(25,950)
                        local interest = math.random(25,150)
                        local value = (bonus-interest)
                    givePlayerMoney(player,value)
                        outputChatBox("#FFFFFF[ #FAAC58Level #FFFFFF]", player, 255, 255, 255, true )
                        outputChatBox("#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true )
                    local accName = getAccountName ( getPlayerAccount ( player ) )
                    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then
                    end
                end
            end
        end
    end
end
setTimer(upLevel,9000,0)

function setLevelLogin ()
	local account = getPlayerAccount(source)
	if ( account ) then
		local Level = (getAccountData(account,"Level") or 0)
		local minutes = (getAccountData(account,"minutes") or 0)
		setElementData(source,"Level",Level)
		setElementData(source,"minutes",minutes)
	end
end
addEventHandler("onPlayerLogin",getRootElement(),setLevelLogin)

function setLevelJoin ()
	setElementData(source,"Level",0)
	setElementData(source,"minutes",0)
end
addEventHandler("onPlayerJoin",getRootElement(),setLevelJoin)

function setLevelQuit ()
	local account = getPlayerAccount(source)
	if ( account ) then
		local minutes = (getElementData(source,"minutes") or 0)
		local Level = (getElementData(source,"Level") or 0)
		setAccountData(account,"minutes",minutes)
		setAccountData(account,"Level",Level)
	end
end
addEventHandler("onPlayerQuit",getRootElement(),setLevelQuit)



Agencia

interior_S

 

Entrar = createMarker(1481.0498046875,-1772.3115234375,19.595755386353, "arrow", 1.2,16, 111, 231, 90)
Sair = createMarker(246.3935546875,107.3017578125,1004.10575, "arrow", 1.2,16, 111, 231, 90)
Painel_Open = createMarker(246.69653, 118.40524, 1003.21875 -1, "cylinder", 1.2,16, 111, 231, 90)

Blip = createBlipAttachedTo ( Entrar, 61 )
setBlipVisibleDistance(Blip, 150)
setElementInterior(Painel_Open, 10)
setElementInterior(Sair,10)

function entrar (thePlayer)
	setElementInterior(thePlayer, 10)
	setElementPosition(thePlayer, 246.583984375,109.3369140625,1003.21875)
	setElementDimension(thePlayer, 0)
end
addEventHandler("onMarkerHit", Entrar, entrar)

function sair (thePlayer)
	setElementInterior(thePlayer, 0)
	setElementPosition(thePlayer, 1481.0185546875,-1768.4638671875,18.795755386353)
	setElementDimension(thePlayer, 0)
end
addEventHandler("onMarkerHit", Sair, sair)

function OpenguiAG(thePlayer)
	local account = getPlayerAccount (thePlayer)
    if isGuestAccount (account) then outputChatBox ( "#106FE7✘ #ffffffAGENCIA #106FE7✘➺ #FFFFFFVocê não pode trabalhar deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end
    if isElementWithinMarker(thePlayer, Painel_Open) then
		triggerClientEvent(thePlayer,"AG:Abrir",thePlayer)	 
  end
end
addEventHandler( "onMarkerHit", Painel_Open, OpenguiAG )

Save_S.Lua

function Loadind_Empregos ( conta )
	if not isGuestAccount ( conta ) then
		if conta then	
			local source = getAccountPlayer ( conta )
			
			local Emprego = getAccountData ( conta, "Emprego" ) or "Desempregado"
			setElementData ( source, "Emprego", Emprego )
			
			setElementData ( source, "DNL:Categoria(Nenhuma)", true )
		end
	end	
end
		
function Save_Empregos ( conta )
	if conta then
		local source = getAccountPlayer ( conta )
		
		local Empregos = getElementData ( source, "Emprego" ) or "Desempregado"
		setAccountData ( conta, "Emprego", Empregos )
	end
end

addEventHandler ( "onPlayerLogin", root,
  function ( _, acc )
	setTimer ( Loadind_Empregos, 60, 1, acc )
  end
)

function Start_Empregos ( res )
	if res == getThisResource ( ) then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				Loadind_Empregos ( acc )
			end
		end
	end
end
addEventHandler ( "onResourceStart", getRootElement ( ), Start_Empregos )

function Stop_Empregos ( res )
    if res == getThisResource ( ) then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				Save_Empregos ( acc )
			end
		end
	end
end 
addEventHandler ( "onResourceStop", getRootElement(), Stop_Empregos )

function Quit_Server ( quitType )
	local acc = getPlayerAccount(source)
	if not isGuestAccount ( acc ) then
		if acc then
			Save_Empregos ( acc )
		end
	end
end
addEventHandler ( "onPlayerQuit", getRootElement(), Quit_Server )



 

Danilin_C.Lua

local screenW,screenH = guiGetScreenSize()
local resW,resH = 1366,768
local x,y =  (screenW/resW), (screenH/resH)

local Font_1 = dxCreateFont("font/font.ttf", y*11)
local Font_2 = dxCreateFont("font/font1.ttf", y*11)
local Font_3 = dxCreateFont("font/fontNick.ttf", y*10)
local Font_4 = dxCreateFont("font/OpenSans-Bold.ttf", y*11)

------------- ############################################ -------------
------------- #     Edite aqui (Level, Habilitação)      # -------------
------------- ############################################ -------------
Trabalhos = {
    {"Lixeiro", 0, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Carregador", 3, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Pescaria", 20, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Mineirador", 25, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Pizzaboy", 5, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Sedex", 10, "Nenhuma"}, -- Emprego, Level, Habilitação
    {"Caminhoneiro", 15, "Nenhuma"}, -- Emprego, Level, Habilitação
}
	                               --===================================--
                                   ------------- Abrir/Fechar ------------
                                   --===================================--
function Abrir_agencia ()
	if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Agencia) then return end
	showCursor(true)
	ListaTrabalhos:SetVisible(true)
	addEventHandler("onClientRender", root, Dx_Agencia)
end
addEvent("AG:Abrir", true)
addEventHandler("AG:Abrir", root, Abrir_agencia)

function CloseAgencia ()
	if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Agencia) then  
		showCursor(false)
		ListaTrabalhos:SetVisible(false)
		removeEventHandler("onClientRender", root, Dx_Agencia)
	end
end
	                               --=======================================--
                                   ------------- Interface Painel ------------
                                   --=======================================--
function Dx_Agencia ()
		exports["Blur"]:dxDrawBluredRectangle(x*488, y*138, x*391, y*491, tocolor(255, 255, 255, 255))
        dxDrawRectangle(x*488, y*138, x*391, y*491, tocolor(0, 0, 0, 170), false)
        dxDrawRectangle(x*489, y*138, x*391, y*38, tocolor(0, 0, 0, 212), false)
        dxDrawLine(x*488, y*176, x*880, y*176, tocolor(16, 111, 231, 255), x*2, false)
        dxDrawText("Agencia de Empregos", x*621, y*146, x*746, y*161, tocolor(255, 255, 255, 255), 1.00, Font_1, "left", "top", false, false, false, false, false)
		
        dxDrawImage(x*500, y*494, x*366, y*37, "Img/botao.png", 0, 0, 0, CorEmprego, false)
        dxDrawText("Pegar Emprego", x*639, y*502, x*729, y*519, tocolor(0, 0, 0, 255), 1.00, Font_1, "left", "top", false, false, false, false, false)
		CorEmprego = tocolor(16, 111, 231, 170)
	if isCursorOnElement(x*500, y*494, x*366, y*37) then
		CorEmprego = tocolor(16, 111, 231, 200)
	end
		
        dxDrawImage(x*500, y*538, x*366, y*37, "Img/botao.png", 0, 0, 0, CorDemissao, false)
        dxDrawText("Pedir Demissão", x*640, y*546, x*726, y*563, tocolor(0, 0, 0, 255), 1.00, Font_1, "left", "top", false, false, false, false, false)
		CorDemissao = tocolor(16, 111, 231, 170)
	if isCursorOnElement(x*500, y*538, x*366, y*37) then
		CorDemissao = tocolor(16, 111, 231, 200)
	end
		
        dxDrawImage(x*500, y*582, x*366, y*37, "Img/botao.png", 0, 0, 0, CorSair, false)
        dxDrawText("Sair Agencia", x*650, y*590, x*719, y*609, tocolor(0, 0, 0, 255), 1.00, Font_1, "left", "top", false, false, false, false, false)
		CorSair = tocolor(16, 111, 231, 170)
	if isCursorOnElement(x*500, y*582, x*366, y*37) then
		CorSair = tocolor(16, 111, 231, 200)
	end
end
	                               --================================--
                                   ------------- GridTable ------------
                                   --================================--

addEventHandler("onClientResourceStart", resourceRoot,
  function ()
    ListaTrabalhos = dxGridW:Create(494, 183, 379, 302)
    ListaTrabalhos:AddColumn("Emprego", 140)
    ListaTrabalhos:AddColumn("Level", 105)
    ListaTrabalhos:AddColumn("Habilitação", 120)
    ListaTrabalhos:SetVisible(false)
	
	for i,v in ipairs (Trabalhos) do
		ListaTrabalhos:AddItem(1, tostring(v[1]))
		ListaTrabalhos:AddItem(2, tostring(v[2]))
		ListaTrabalhos:AddItem(3, tostring(v[3]))
	end
end)

	                               --=============================--
                                   ------------- Clicks ------------
                                   --=============================--
function Pegar_Trabalho ( _,state )
	if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Agencia) then  
		if state == "down" then
			if isCursorOnElement(x*500, y*582, x*366, y*37) then -- Fechar Agencia
				CloseAgencia () 
			end
			if isCursorOnElement(x*500, y*494, x*366, y*37) then -- Pegar Emprego	
				if ListaTrabalhos:GetSelectedItem() > -1 then  
					local Trab = ListaTrabalhos:GetItemDetails(1, ListaTrabalhos:GetSelectedItem())
					local Level = ListaTrabalhos:GetItemDetails(2, ListaTrabalhos:GetSelectedItem())
					local Hab = ListaTrabalhos:GetItemDetails(3, ListaTrabalhos:GetSelectedItem())
					playSoundFrontEnd(12)
					triggerServerEvent("DNL:Pegar_Emprego", root, localPlayer, Trab, Level, Hab)
				else				   
					triggerEvent("addNotification", root, "#ffffffINFO: #ffffffSelecione o Emprego que Você Deseja Trabalhar", "info")
				end 
			elseif isCursorOnElement(x*500, y*538, x*366, y*37) then -- Demissão
					playSoundFrontEnd(12)
					triggerServerEvent("DNL:Pedir_Demissao", root, localPlayer)
			end
		end
	end
end
addEventHandler ( "onClientClick", root, Pegar_Trabalho )

	                               --=============================--
                                   ------------- IGNORA ------------
                                   --=============================--
--==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-

addEventHandler("onClientKey", root, 
	function (button, press)
    if isEventHandlerAdded("onClientRender", getRootElement(), Dx_Agencia) then  
			if button == "F1" or button == "F2" or button == "F3" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" or button == "p" or button == "m" then
				cancelEvent()
			end
		end
	end
)

--==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-
						  
function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
	if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
			for i, v in ipairs( aAttachedFunctions ) do
				if v == func then
					return true
				end
			end
		end
	end
	return false
end

--==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-

local x,y = guiGetScreenSize()
function isCursorOnElement(x, y, w, h)
	if (not isCursorShowing()) then
		return false
	end
	local mx, my = getCursorPosition()
	local fullx, fully = guiGetScreenSize()
	cursorx, cursory = mx*fullx, my*fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

--==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-

 

Link to comment
20 minutes ago, Angelo Pereira said:

1. Você precisa verificar no /debugscript 3 para saber o motivo pelo qual o resource não esta funcionando da melhor forma.

2. setTimer(upLevel,9000,0) --/> 9 segundos / setTimer(upLevel,60000,0) --/> 60 segundos.

3. Aparentemente, esta certo, o problema, é que falta ainda uma parte do server-side no script.

Qual deles que falta

O do sistema de level ou da agencia?

aqui uma print do debug

mwiJb6P.png

 

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