[YARDIM] Greenzone Ayar

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı ardaabo

  • Acemi Üye
  • *
    • İleti: 145
: 12 Nisan 2020, 01:44:22
Oyuncu yeşil alana girdiği zaman, eline silah alamasın istiyorum. Yardımcı olacak var mı

client
Kod
function onPDamage()
if getElementData (source, "greenzone") then
cancelEvent()
end
end
addEventHandler ("onClientPlayerDamage", localPlayer, onPDamage)

function onPSKill(target)
if getElementData (target, "greenzone") then
cancelEvent()
end
end
addEventHandler ("onClientPlayerStealthKill", localPlayer, onPSKill)

function invisible()
        setElementAlpha(localPlayer, 0)
end
addCommandHandler ( "invisible", invisible )

function renderGreenzoneTag()
local streamedPlayers = getElementsByType ("player", root, true)
if streamedPlayers and #streamedPlayers ~= 0 then
local lpos = {getElementPosition(localPlayer)}
for _,p in ipairs (streamedPlayers) do
if p and isElement (p) then
if getElementData (p, "greenzone") then
local ppos = {getElementPosition(p)}
if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then
local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2)
if x and y then
dxDrawText ("GÜVENLİ BÖLGE", x+1, y+1, x, y, tocolor (0, 0, 0), 0.5, "bankgothic", "center")
dxDrawText ("GÜVENLİ BÖLGE", x, y, x, y, tocolor (0, 220, 0), 0.5, "bankgothic", "center")
end
end
end
end
end
end
end
addEventHandler ("onClientRender", root, renderGreenzoneTag)

server
Kod
-- By default it adds greenzone to the Freeroam/play standard spawnpoints to prevent spawnkills, you can add greenzone areas to it using the coordinate format
-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0},
local greenzones = {
{x = 1435, y = -1795., z = 10, width = 93, depth = 200, height = 20}, -- Grove Street
}

-- initialize all zones on resource start
local z = {}
function initGreenzones()
if greenzones and #greenzones ~= 0 then
for _,v in ipairs (greenzones) do
if v then
if v.x and v.y and v.z and v.width and v.depth and v.height then
local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height)
local rarea = createRadarArea (v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
setElementParent (rarea, c)
if c then
z[c] = true
for _,p in ipairs (getElementsWithinColShape(c, "player")) do
setElementData (p, "greenzone", true)
end
addEventHandler ("onElementDestroy", c,
function()
if z[source] then
z[source] = nil
end
end
)
addEventHandler ("onColShapeHit", c,
function (h, d)
if h and d and isElement(h) and getElementType (h) == "player" then
setElementData (h, "greenzone", true)
outputChatBox ("[SERVER] Güvenli alana geçiş yaptın!", h, 0, 220, 0)
end
end
)
addEventHandler ("onColShapeLeave", c,
function (h, d)
if h and d and isElement(h) and getElementType (h) == "player" then
removeElementData (h, "greenzone")
outputChatBox ("[SERVER] Güvenli alandan ayrıldın!", h, 220, 220, 0)
end
end
)
end
end
end
end
end
end
addEventHandler ("onResourceStart", resourceRoot, initGreenzones)

function resetGreenzoneData()
for _,p in ipairs (getElementsByType("player")) do
if isElement(p) then
removeElementData (p, "greenzone")
end
end
end
addEventHandler ("onResourceStop", resourceRoot, resetGreenzoneData)
 


MTASATURK

[YARDIM] Greenzone Ayar
« : 12 Nisan 2020, 01:44:22 »

Çevrimdışı yafes

  • Bilişim Teknolojileri
  • Moderatör
  • *
    • İleti: 446
  • C++
    • MTASATURK
Yanıtla #1 : 12 Nisan 2020, 10:13:33
server.lua içindeki initGrenzones() fonksiyonunu alttaki ile değiştirip denermisin

Kod
function initGreenzones()
if greenzones and #greenzones ~= 0 then
for _,v in ipairs (greenzones) do
if v then
if v.x and v.y and v.z and v.width and v.depth and v.height then
local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height)
local rarea = createRadarArea (v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
setElementParent (rarea, c)
if c then
z[c] = true
for _,p in ipairs (getElementsWithinColShape(c, "player")) do
setElementData (p, "greenzone", true)
end
addEventHandler ("onElementDestroy", c,
function()
if z[source] then
z[source] = nil
end
end
)
addEventHandler ("onColShapeHit", c,
function (h, d)
if h and d and isElement(h) and getElementType (h) == "player" then
setElementData (h, "greenzone", true)
outputChatBox ("* Greenzone * You have entered the greenzone", h, 0, 220, 0)
toggleControl (h, "fire", false)
    toggleControl (h, "next_weapon", false)
    toggleControl (h, "previous_weapon", false)
    toggleControl (h, "aim_weapon", false)
    toggleControl (h, "vehicle_fire", false)
end
end
)
addEventHandler ("onColShapeLeave", c,
function (h, d)
if h and d and isElement(h) and getElementType (h) == "player" then
removeElementData (h, "greenzone")
outputChatBox ("* Greenzone * You have left the greenzone", h, 220, 220, 0)
toggleControl (h, "fire", true)
    toggleControl (h, "next_weapon", true)
    toggleControl (h, "previous_weapon", true)
    toggleControl (h, "sprint", true)
    toggleControl (h, "aim_weapon", true)
    toggleControl (h, "vehicle_fire", true)
end
end
)
end
end
end
end
end
end
« Son Düzenleme: 12 Nisan 2020, 10:15:11 Gönderen: MertTozcu »
 


Çevrimdışı ardaabo

  • Acemi Üye
  • *
    • İleti: 145
Yanıtla #2 : 12 Nisan 2020, 12:46:54
Maalesef, verdiğin kodu yaptığım da greenzone yok oluyor
Linki görebilmek için Kayıt olun yada Giriş yapın.