Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Recurso: MJ-Varios
- --Archivo: afkCliente.lua
- --Proposito: Funcionamiento del sistema antiafk por parte del Cliente
- --Creado por Tomas Navarro (GamerCarl)
- local tiempoAFK = 10
- local tiempoADV = 10
- local v = 0
- local afkt = 0
- local afkc = 1
- local sx,sy = guiGetScreenSize()
- local evento = false
- local conteo = 10
- function advertenciaDraw()
- local arreglo = dxGetFontHeight(sy/450,"default-bold")
- dxDrawText("Advertencia!",1, sy/2 -((sy/450)/2)-((arreglo*3))+1,sx,sy,tocolor(0,0,0,255),sy/450,"default-bold","center")
- dxDrawText("Advertencia!",0, sy/2 -((sy/450)/2)-((arreglo*3)),sx,sy,tocolor(255,0,0,255),sy/450,"default-bold","center")
- dxDrawText("Tu moriras en "..tostring(conteo).." segundos!",1, sy/2 -((sy/450)/2)+1,sx,sy,tocolor(0,0,0,255),sy/450,"default-bold","center")
- dxDrawText("Tu moriras en "..tostring(conteo).." segundos!",0, sy/2 -((sy/450)/2),sx,sy,tocolor(255,255,255,255),sy/450,"default-bold","center")
- end
- function detenerADV()
- if(evento) then
- removeEventHandler("onClientRender", root, advertenciaDraw)
- evento = false
- end
- end
- function jugadormuere()
- detenerADV()
- end
- addEventHandler("onClientPlayerWasted", getLocalPlayer(), jugadormuere)
- function verificarjugador()
- if isPedInVehicle(getLocalPlayer()) then
- tiempoR()
- end
- end
- function tiempoR()
- afkt = afkt + 1
- local finalizado = getElementData ( getLocalPlayer(), "dead")
- if (isElementFrozen ( getPedOccupiedVehicle ( getLocalPlayer() )) and finalizado == false) then
- limpiartiempo()
- end
- local nuevoEstado = getElementData (getLocalPlayer(), "state")
- if nuevoEstado == "waiting" or nuevoEstado == "dead" then
- limpiartiempo()
- end
- if(getPedOccupiedVehicle ( getLocalPlayer() ) ~= false) then
- local jugador = getLocalPlayer()
- if(afkt >= tiempoAFK) then
- if (afkc <= 2) then
- triggerServerEvent ( "afkADV", jugador, 1, afkc)
- afkc = afkc+1
- triggerServerEvent ( "afkMuerte", jugador)
- detenerADV()
- elseif (afkc > 2) then
- triggerServerEvent ( "afkADV", jugador, 1, afkc)
- triggerServerEvent ( "afkADV", jugador, 2)
- afkc = 1
- triggerServerEvent ( "ExpulsionAFK", jugador , jugador)
- end
- elseif(afkt >= tiempoADV) then
- conteo = conteo - 1
- if(not evento) then
- addEventHandler("onClientRender", getRootElement(), advertenciaDraw)
- evento = true
- end
- end
- end
- end
- setTimer ( verificarjugador, 1000, -1)
- function limpiartiempo()
- afkt = 0
- conteo = 10
- detenerADV()
- end
- bindKey("accelerate","down",limpiartiempo)
- bindKey("vehicle_left","down",limpiartiempo)
- bindKey("vehicle_right","down",limpiartiempo)
- bindKey("brake_reverse","down",limpiartiempo)
- function jugadorafk(elJugador)
- matarporafk = 0
- end
- function resetearpormuerte()
- if matarporafk == 0 then
- afkc = 1
- else
- end
- end
- addEventHandler("onClientPlayerWasted", getLocalPlayer(), resetearpormuerte)
- function jugadorafk2()
- matarporafk = 0
- end
- function cargaCliente(res)
- triggerServerEvent("onClientLoaded", getLocalPlayer())
- end
- addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),cargaCliente)
- function cargarOpciones(tiempomaximo, wtiempo)
- tiempoAFK = tonumber(tiempomaximo)
- tiempoADV = tonumber(wtiempo)
- end
- addEvent("onSettingsReady", true)
- addEventHandler("onSettingsReady", root, cargarOpciones)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement