Dimos7 Posted February 23, 2018 Share Posted February 23, 2018 (edited) Hello there i have make some afk zone and i want when player is that possition not get kicked what mater the time afk there are and cancel the damange local AFKZones = { {-2697.25, 366.05, 4.4, 100, 100}, {1222.77, -1424.77, 13.35, 100, 100}, {1898.62, 2317.56, 10.82, 100, 100}, }, function createAFKZones(player) for #AFKZones do AFKCols = createColRectangle(unpack(AFKZones)) AFKarea = createRadarArea(unpack(AFKZones)) setRadarAreaColor(AFKarea, 0, 255, 0) end end addEventHandler("onColShapeHit", root, createAFKZOnes) Edited February 23, 2018 by Dimos7 Link to comment
Dimos7 Posted February 23, 2018 Author Share Posted February 23, 2018 (edited) can someone help i want player when are in colshpae not be able kicked for be afk can you help me local AFKZones = { {-2697.25, 366.05, 4.4, 100, 100}, {1222.77, -1424.77, 13.35, 100, 100}, {1898.62, 2317.56, 10.82, 100, 100}, }, local AFKZoneArea = { {-2697.25, 366.05, 100, 100}, {1222.77, -1424.77, 100, 100}, {1898.62, 2317.56, 100, 100}, }, function createAFKZones() for #AFKZones do AFKCols = createColRectangle(unpack(AFKZones)) end for #AFKZoneArea do AFKarea = createRadarArea(unpack(AFKZoneArea)) setRadarAreaColor(AFKarea, 0, 255, 0) end end addEventHandler("onResourceStart", resourceRoot, createAFKZones) addEventHandler("onColShapeHit", root, function(player) setPedWeaponSlot(player, 0) toggleControl(player, "next_weapon", false) toggleControl(player, "previous_weapon", false) toggleControl(player, "fire", false) toggleControl(player, "aim_weapon", false) setElementData(player , "afk", true) end) addEventHandler("onColShapeLeave", root, function(player) toggleControl(player, "next_weapon", true) toggleControl(player, "previous_weapon", true) toggleControl(player, "fire", true) toggleControl(player, "aim_weapon", true) setElementData(player, "afk", false) end) Edited February 23, 2018 by Dimos7 Link to comment
Craigster Posted February 23, 2018 Share Posted February 23, 2018 local Zone_settings = { disable_controls = {"next_weapon", "previous_weapon", "fire", "aim_weapon"}}; local AFKElements = {}; local AFKZones = { {-2697.25, 366.05, 4.4, 100, 100}, {1222.77, -1424.77, 13.35, 100, 100}, {1898.62, 2317.56, 10.82, 100, 100}, }; function initAFKZones(player) for id, v in ipairs(AFKZones) do local col = createColRectangle(unpack(v)); local area = createRadarArea(unpack(v)); AFKElements[col] = id; addEventHandler("onColshapeHit", col, onAFKZoneEnter) addEventHandler("onColshapeLeave", col, onAFKZoneLeave) if (area and isElement(area)) then setRadarAreaColor(area, 0, 255, 0); end end end addEventHandler("onResourceStart", resourceRoot, initAFKZones) function onAFKZoneEnter(element) if not isElement(element) or getElementType(element) ~= "player" then return end addEventHandler("onPlayerDamage", element, onPlayerDamage) setPedWeaponSlot(element, 0) return toggleZoneControls(element, false); end function onAFKZoneLeave(element) if not isElement(element) or getElementType(element) ~= "player" then return end removeEventHandler("onPlayerDamage", element, onPlayerDamage) return toggleZoneControls(element, true); end function toggleZoneControls(element, bool) if not isElement(element) then return end for _, control in ipairs(Zone_settings.disable_controls) do toggleControl(element, control, bool); end end local function onPlayerDamage(_, _, _, loss) if (source and isElementWithinAFKZone(source)) then setElementHealth(source, getElementHealth(source) + loss); end end -- Export this function: function isElementWithinAFKZone(element) if not (element and isElement(element)) then return false; end for col, _ in pairs(AFKElements) do if isElement(col) then if isElementWithinColShape(element, col) then return true; end end end return false; end I've quickly and rapidly created a base script for you to start to work on, untested. But assuming that the array has the correct values, and assuming you have a seperate AFK script. You will need to integrate it within the script. Which you will need to do so by exporting the function: isElementWithinAFKZone. I would also suggest to have the 'no damage' client-sided, but is not necessary, as it reduces the server-stress. 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