Advertisement
Guest User

To Ryan#USNS

a guest
Aug 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. -- To Ryan#USNS
  2. -- I Have this code
  3. -- X => X position of the cursor
  4. -- Y => Y position of the cursor
  5. -- zoneID => the zone ID
  6.  
  7. function isWithinZone(x,y,zoneID)
  8.     local cx,cy = zones[zoneID]["x"],zones[zoneID]["x"]
  9.     local sx,sy = zones[zoneID]["sx"],zones[zoneID]["sx"]
  10.     if cx == x and cy == y then return true end
  11.     if x-cx <= sx and cy == y then return true end
  12.     if cx == x and y-cy <= sy then return true end
  13.     if x-cx <= sx and y-cy <= sy then return true end
  14.     return false
  15. end
  16.  
  17. -- Just will make something like this:
  18.         local el = createObject(model, x, y, z, rx, ry, rz)
  19.         local objectZone = getElementData(source, "zoneEditing")
  20.         if not isWithinZone(x,y,objectZone) then
  21.             destroyElement(el)
  22.             exports.CSTtexts:output("Object must be in the zone!",source,255,0,0)
  23.             return false
  24.         end
  25.  
  26. -- The problem that it always return false
  27. -- Means if the object inside , it will say Object must be in the zone!, and if the object outside, it will say the same..
  28. -- Wish you understand
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement