[YARDIM] Scripte Komut Eklemek

Ky · 1 · 1066

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı Ky

  • Uzman Üye
  • *
    • İleti: 614
: 24 Aralık 2018, 14:39:13
Arkadaşlar Yabancı Forumdan Aldığım Bi Script Oyuncuların Yerini Görme Ben Bu Scripte Kod Eklemek İstiyorum Örneğin Oyuncu /yergorme Yazdığında Bu Script çalışsın onun haricinde çalışmasın
Kod
local function getPedsOnScreen() 
    local peds = {}
    for key, ped in ipairs(getElementsByType("player", root, true)) do
        if isElementOnScreen(ped) then
            table.insert(peds, ped)
             
        end
    end
    return peds
end
 
local function dxDrawCircle(posX, posY, radius, width, angleAmount, color, postGUI)
    radius = radius or 45
    width = width or 1
    angleAmount = angleAmount or 1
    color = color or tocolor(255, 255, 255, 200)
    postGUI = postGUI or false
 
    for i=0,360,angleAmount do
        local _i = i*(math.pi/180)
        dxDrawLine(math.cos(_i)*(radius-width)+posX, math.sin(_i)*(radius-width)+posY, math.cos(_i)*(radius+width)+posX, math.sin(_i)*(radius+width)+posY, tocolor(0, 0, 255), width, postGUI)
    end
    return true
end 
 
local function findRotation(x1,y1,x2,y2)
 
  local t = -math.deg(math.atan2(x2-x1,y2-y1))
  if t < 0 then t = t + 360 end;
  return t;
 
end
 
 
local function sortbyrot(a, b)
    local _, _, rz = getElementRotation(localPlayer)
    local x, y = getElementPosition(localPlayer)
    local ax, ay = getElementPosition(a)
    local bx, by = getElementPosition(b)
    local arz = findRotation(x, y, ax, ay)
    arz = math.abs(rz - arz)
    local brz = findRotation(x, y, bx, by)
    brz = math.abs(rz - brz)
    return arz < brz
end
 
 
addEventHandler("onClientRender", root,
function()
    local weapon = getPedWeapon(localPlayer)
    if weapon and weapon > 0 then
        local peds = getPedsOnScreen()
        if #peds > 0 then
            table.sort(peds, sortbyrot)
            local chosen = peds[1]
            local hx, hy, hz = getPedBonePosition(chosen, 2)
            local sx, sy = getScreenFromWorldPosition(hx, hy, hz)
            if sx then
                dxDrawCircle(sx, sy)
            end
        end
    end
end)
« Son Düzenleme: 26 Aralık 2018, 01:19:43 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Scripte Komut Eklemek
« : 24 Aralık 2018, 14:39:13 »