IIIIlllllIII Posted September 7, 2011 Share Posted September 7, 2011 hi i make afk system for basemode and the code not working pleez fix it server local BaseModeState = "" local enableMessages = true local messageColor = "#FF5555" function afkMsg(mtype) if(getResourceState ( getResourceFromName("BaseMode") ) == "running") then local isFinished = call(getResourceFromName("BaseMode"), "isPlayerFinished", source) if(not isFinished and BaseModeState == "Running") then if(enableMessages) then if(mtype == 1) then outputChatBox(messageColor.."* "..getPlayerName(source)..messageColor.." has been killed by Anti-AFK.", getRootElement(), 255,100,100, true) elseif(mtype == 2) then outputChatBox(messageColor.."* You are AFK and you will be killed after 1 Minute!", source, 255,100,100, true) end end end end end addEvent( "afkWarn", true ) addEventHandler( "afkWarn", getRootElement(), afkMsg) function afkKill() if(getResourceState ( getResourceFromName("BaseMode") ) == "running") then local isFinished = call(getResourceFromName("BaseMode"), "isPlayerFinished", source) if(not isFinished and BaseModeState == "Running") then setElementHealth(source, 0) end end end addEvent( "afkSlap", true ) addEventHandler( "afkSlap", getRootElement(), afkKill) function changeBaseModeState(newStateName) BaseModeState = newStateName end addEvent("onBaseModeStateChanging", true) addEventHandler( "onBaseModeStateChanging", getRootElement(), changeBaseModeState) function clientLoaded() local msgenable = get( "msgenable" ) local msgcol = get( "msgcolor" ) if(msgenable) then if(msgenable == "true") then enableMessages = true else enableMessages = false end if(msgcol) then messageColor = msgcol end end local maxtime = get( "maxafktime" ) local wtime = get( "warnTime" ) triggerClientEvent ( "onSettingsReady", getRootElement(), maxtime, wtime) end addEvent("onClientLoaded", true) addEventHandler( "onClientLoaded", getRootElement(), clientLoaded) client local MaxAFKtime = 30 local warnTime = 20 local v = 0 local AFKtime = 0 local sx,sy = guiGetScreenSize() local wEvent = false function rWarn() dxDrawImage( sx/2 - 300, sy/2 - 100, 600, 200, 'warn.png' ) end function stopWarn() if(wEvent) then removeEventHandler("onClientRender", getRootElement(), rWarn) wEvent = false end end function checkMain() if isPedInVehicle ( getLocalPlayer() ) then v = getElementVelocity ( getPedOccupiedVehicle ( getLocalPlayer() ) ) if(v == 0) then aTimeAdd() else aTimeClear() end end end function aTimeAdd() AFKtime = AFKtime + 0.1 local isFinished = getElementData ( getLocalPlayer(), "BaseMode.finished") if(isVehicleFrozen ( getPedOccupiedVehicle ( getLocalPlayer() )) and isFinished == false) then aTimeClear() end if(AFKtime >= MaxAFKtime) then AFKtime = 0 triggerServerEvent ( "afkSlap", getLocalPlayer()) stopWarn() triggerServerEvent ( "afkWarn", getLocalPlayer(), 1) elseif(AFKtime == warnTime) then triggerServerEvent ( "afkWarn", getLocalPlayer(), 2) if(not wEvent) then addEventHandler("onClientRender", getRootElement(), rWarn) wEvent = true end end end function aTimeClear() AFKtime = 0 end setTimer ( checkMain, 100, -1) function onClientLoaded(res) triggerServerEvent("onClientLoaded",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onClientLoaded) function loadSettings(maxtime, wtime ) MaxAFKtime = tonumber(maxtime) warnTime = tonumber(wtime) end addEvent( "onSettingsReady", true ) addEventHandler( "onSettingsReady", getRootElement(), loadSettings ) pleeez fix it not working with me i test it Link to comment
TAPL Posted September 7, 2011 Share Posted September 7, 2011 you make it? or you just take it from community ? https://community.multitheftauto.com/ind ... ls&id=1283 Link to comment
Cadu12 Posted September 7, 2011 Share Posted September 7, 2011 You are using scripts for RACE not Basemode, CREATE YOUR OWN SCRIPTS FOR BASEMODE. I did created my own. Link to comment
IIIIlllllIII Posted September 7, 2011 Author Share Posted September 7, 2011 You are using scripts for RACE not Basemode, CREATE YOUR OWN SCRIPTS FOR BASEMODE.I did created my own. give me ur code pleez i dont have time Link to comment
JR10 Posted September 7, 2011 Share Posted September 7, 2011 Are you kidding me? You don't have time? Then don't play MTA at all. Link to comment
Cadu12 Posted September 8, 2011 Share Posted September 8, 2011 Agree with JR10. Im not giving to anyone source/code. "i dont have time" Then don't play MTA at all.² Link to comment
IIIIlllllIII Posted September 8, 2011 Author Share Posted September 8, 2011 ok shut up and this forum for help each other im not english to learn some lua scripts i dont know how to make scripts so dont insult me because im really i dont have time and stop Mockery of me Link to comment
JR10 Posted September 8, 2011 Share Posted September 8, 2011 No one insulted you, but this forum is for helping you ... with your code. Not making you one, or giving you one we made. Stop saying you don't have time, because you do, you ask too much for a guy that doesn't have time. Link to comment
solidsnake Posted September 8, 2011 Share Posted September 8, 2011 No time For Scripting + No English = Syntax Error Link to comment
Headshot4Fun Posted September 8, 2011 Share Posted September 8, 2011 No time For Scripting + No English = Syntax ErrorNice story bro.By The way, if you don't have time to learn lua, try study a little everyday, you can't just learn everything in 1 hour or something like that. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now