Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Peacekeeper_Entry = x -- Set peacekeeper entry ID here
- local SafeArea = { -- Change area coordinates here, same as C++ script.
- {4513.935, -4256.359},
- {4510.568, -4236.598},
- {4490.970, -4249.030},
- {4489.567, -4194.844},
- {4513.935, -4256.359}
- }
- local function isLeft(pOne, pTwo, pThree)
- local point = ((pTwo[1] - pOne[1]) * (pThree[2] - pOne[2]) - (pThree[1] - pOne[1]) * (pTwo[2] - pOne[2]))
- return point;
- end
- local function isInArea(point)
- local count = 0;
- for i = 1, #SafeArea-1 do
- if (SafeArea[i][2] <= point[2]) then
- if (SafeArea[i+1][2] > point[2]) then
- if (isLeft(SafeArea[i], SafeArea[i+1], point) > 0) then
- count = count + 1;
- end
- end
- else
- if (SafeArea[i+1][2] <= point[2]) then
- if (isLeft(SafeArea[i], SafeArea[i+1], point) < 0) then
- count = count - 1;
- end
- end
- end
- end
- return count ~= 0;
- end
- local function Peacekeeper_OnSpawn(event, creature)
- creature:RegisterEvent(Peacekeeper_OnCheckArea, 1000, 0)
- end
- local function Peacekeeper_OnCheckArea(creature)
- for k, player in pairs(GetPlayersInMap(creature:GetMapId())) do
- if(player) then
- if (player:GetAreaId() == creature:GetAreaId())
- local point = {player:GetX(), player:GetY())
- if(isInArea(point)) then
- player:SetPvP(false)
- else
- player:SetPvP(true)
- end
- end
- end
- end
- end
- RegisterCreatureEvent(Peacekeeper_Entry, 23, Peacekeeper_OnSpawn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement