[YARDIM] Uyku Sistemini Hud'a Nasıl Bağlarım

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı VaTaN

  • Bilgin Üye
  • *
    • İleti: 270
by angel ın kodlamış olduğu uyku sistemini resimdeki hud a aktarmak istiyorum   uyku resimde %100 bunu koştukça veyatta hareket ettikçe azalmasını uyuyuncada uyanmasını istiyorum hud un renklerini değiştirebilirmiyim kaçıncı satır ?

Hud Client

Kod
local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1360), (screenH/768)
local dxfont1_font = dxCreateFont("files/font/font.ttf", 11)
local components = { "area_name", "radio", "vehicle_name" }
 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
for _, component in ipairs( components ) do
setPlayerHudComponentVisible( component, false )
end
end)

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end

return false
end

function dxHud1()
local vida1 = math.floor(getElementHealth(getLocalPlayer()))
local vida2 = getPedMaxHealth(getLocalPlayer())
local colete = math.floor(getPedArmor(getLocalPlayer()))
local money = convertNumber(getPlayerMoney())
local procurado = getPlayerWantedLevel(getLocalPlayer())
local ammoClip = getPedAmmoInClip(getLocalPlayer(), getPedWeaponSlot(getLocalPlayer()))
local ammo = getPedTotalAmmo(getLocalPlayer()) - getPedAmmoInClip(getLocalPlayer())
local armaId = getPedWeapon(getLocalPlayer())
local weapon = getPedWeapon(getLocalPlayer())
local name = getPlayerName(getLocalPlayer())
local fome = getElementData(getLocalPlayer(), "hunger")
local sede = getElementData(getLocalPlayer(), "sede")
local sono = getElementData(getLocalPlayer(), "sono")
avatar = getElementData(getLocalPlayer(), "avatar")
--local ping = getPlayerPing(getLocalPlayer())
--local playerTeam = getPlayerTeam(getLocalPlayer())
-- local team = getTeamName(playerTeam)
local wanted = getPlayerWantedLevel(getLocalPlayer())

        dxDrawImage(x*894, y*-19, x*500, y*250, "files/img/background.png", 0, 0, 0, tocolor(254, 254, 254, 255), false)
        dxDrawText(money, x*998, y*22, x*1090, y*41, tocolor(254, 254, 254, 182), 1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawText(ammoClip.." | "..ammo, x*1003, y*51, x*1095, y*70, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
       
        if wanted > 0 then
        dxDrawText("Nível "..wanted, x*1003, y*84, x*1095, y*103, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        else
        dxDrawText("Suç Yok", x*1003, y*84, x*1095, y*103, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        end

        dxDrawText(vida1.."%", x*1287, y*32, x*1379, y*51, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawImage(x*895, y*124, x*200, y*105, "files/img/"..tostring(weapon)..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1104,y*19, x*161, y*161, "files/avatars/"..avatar..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(colete.."%", x*1302, y*60, x*1394, y*79, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawText(fome.."%", x*1302, y*89, x*1394, y*108, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawText(sede.."%", x*1297, y*118, x*1389, y*137, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawText(sono.."%", x*1292, y*147, x*1384, y*166, tocolor(254, 254, 254, 182), x*1.20, "default", "left", "top", false, false, false, false, false)
        dxDrawImage(x*1104,y*19, x*161, y*161, "files/img/config.png", 0, 0, 0,  isCursorOnElement(x*1105,y*16, x*161, y*161) and tocolor(255, 255, 255, 220) or tocolor(255, 0, 60, 0), false)
end

function avatarMenu()
        dxDrawRectangle(x*1038,y*211, x*262, y*63, tocolor(0, 0, 0, 179), false)
        dxDrawRectangle(x*1095,y*223, x*142, y*41, isCursorOnElement(x*1095,y*223, x*142, y*41) and tocolor(16, 102, 231, 220) or tocolor(0, 0, 0, 129), false)
        dxDrawText("Selecionar", x*1125, y*233, x*1273, y*264, tocolor(255, 255, 255, 255), x*1.00, dxfont1_font, "left", "top", false, false, false, false, false)
        dxDrawImage(x*1048, y*229, x*32, y*29, "files/img/arrow.png", 0, 0, 0, isCursorOnElement(x*1048, y*229, x*32, y*29) and tocolor(16, 102, 231, 220) or tocolor(0, 0, 0, 179), false)
        dxDrawImage(x*1251, y*229, x*32, y*29, "files/img/arrow.png", 180, 0, 0, isCursorOnElement(x*1251, y*229, x*32, y*29) and tocolor(16, 102, 231, 220) or tocolor(0, 0, 0, 179), false)
end

function renderDxHud()
addEventHandler("onClientRender", getRootElement(), dxHud1)
setPlayerHudComponentVisible("armour", false)
setPlayerHudComponentVisible("wanted", false)
setPlayerHudComponentVisible("weapon", false)
setPlayerHudComponentVisible("money", false)
setPlayerHudComponentVisible("health", false)
setPlayerHudComponentVisible("clock", false)
setPlayerHudComponentVisible("breath", false)
setPlayerHudComponentVisible("ammo", false)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), renderDxHud)

function setAvatar(_,state)
    if isEventHandlerAdded("onClientRender", getRootElement(), dxHud1) then 
        if state == "down" then
            if isCursorOnElement(x*1104,y*19, x*161, y*161) then
                playSound("sfx/open.mp3", false)
                addEventHandler("onClientRender", root, avatarMenu)       
            end
        end
    end
    if isEventHandlerAdded("onClientRender", getRootElement(), avatarMenu) then 
        if state == "down" then
            if isCursorOnElement(x*1095,y*223, x*142, y*41) then
                playSound("sfx/open.mp3", false)
                removeEventHandler("onClientRender", root, avatarMenu)       
            end
            if isCursorOnElement(x*1048, y*229, x*32, y*29) then
            if avatar > 1 then
            setElementData(getLocalPlayer(), "avatar", avatar - 1)
            end
            end
            if isCursorOnElement(x*1251, y*229, x*32, y*29) then
            if avatar < 15 then
            setElementData(getLocalPlayer(), "avatar", avatar + 1)
            end
            end
        end
    end
end
addEventHandler("onClientClick", root, setAvatar)


function onStop()
setPlayerHudComponentVisible("armour", true)
setPlayerHudComponentVisible("wanted", true)
setPlayerHudComponentVisible("weapon", true)
setPlayerHudComponentVisible("money", true)
setPlayerHudComponentVisible("health", true)
setPlayerHudComponentVisible("clock", true)
setPlayerHudComponentVisible("breath", true)
setPlayerHudComponentVisible("ammo", true)
end
addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), onStop)

function contornoRetangulo(absX, absY, sizeX, sizeY, color, ancho)
dxDrawRectangle(absX, absY, sizeX, ancho, color)
dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color)
dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color)
dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho*2, color)
end



function getPedMaxHealth(ped)
assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]")
local stat = getPedStat(ped, 24)
local maxhealth = 100 + (stat - 569) / 4.31
return math.max(1, maxhealth)
end

function convertNumber ( number )   
    local formatted = number   
    while true do       
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
        if ( k==0 ) then       
            break   
        end   
    end   
    return formatted
end

function isCursorOnElement( posX, posY, width, height )
  if isCursorShowing( ) then
    local mouseX, mouseY = getCursorPosition( )
    local clientW, clientH = guiGetScreenSize( )
    local mouseX, mouseY = mouseX * clientW, mouseY * clientH
    if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then
      return true
    end
  end
  return false
end

Uykunun Kodları

Kod
 local markerler = { -- {x,y,z -1.1,tip,büyüklük,renk1 or r,renk2 or g,renk3 or b,sefaflik or alpha},

{220.7607421875, 1342.814453125, 10.674425125122 -1.1,"cylinder", 1, 0, 0, 0, 0},

element = {},
renk = {0,0,0},
saniye = 10000,
kac_defa = 1,
}

local panel_durum = "nil" -- :)

local uyuyor = ""
local anim1 = 2
local olay = "nil"

addEventHandler("onClientResourceStart", root, function()
for i,v in ipairs(markerler) do
local marker = createMarker(unpack(markerler[i]))
table.insert(markerler.element, marker)
addEventHandler("onClientMarkerHit",marker,olay1)
addEventHandler("onClientMarkerLeave",marker,olay2)
end
end)

function olay1(markere_giren)
if markere_giren == localPlayer then -- eğer markere giren localPlayer yani sensen paneli tek sana göster.
addEventHandler("onClientRender",root,render)
panel_durum = "panel"
showCursor(true)
button_durum = true
button_durum = true
end
end

function eminim()
removeEventHandler("onClientRender",root,render)
addEventHandler("onClientRender",root,render_yazi)
anim1 = 1
olay = "devam"
durum = true
button_durum = false
fadeCamera(false, 1.0, unpack(markerler.renk))
showChat(false)

setTimer(function()
fadeCamera(true,1)
removeEventHandler("onClientRender",root,render)
removeEventHandler("onClientRender",root,render_yazi)
showChat(true)
showCursor(false)
anim1 = 2
yazi_durum = false
outputChatBox(getPlayerName(localPlayer).." #ff0000Günaydın Asker.",255,255,255,true)
durum = false
button_durum = true
uyuyor = ""
end,markerler.saniye,markerler.kac_defa)
end

function emin_degilim()
removeEventHandler("onClientRender",root,render)
fadeCamera(true,1)
showCursor(false)
panel_durum = "nil"
durum = false
--button_durum = false
end

function olay2()
removeEventHandler("onClientRender",root,render)
fadeCamera(true,1)
showCursor(false)
--button_durum = false
end

local yazi_tipi =  dxCreateFont("font.ttf",15)
local screenW,screenH = guiGetScreenSize()
g,u = 302,120
px,py = screenW/2-g/2 ,screenH/2-u/2

function render()
if panel_durum == "panel" then
panel_olustur(px,py,g,u," Uyku Sistemi",tocolor(170, 22, 173,255),[[
Uyumak istediğinize eminmisiniz?
]])

button_olustur("Uyu",px+22,py+60,250,22,60, 160, 35,yazi_tipi)
button_olustur("Uyuma",px+22,py+90,250,22,165, 8, 8,yazi_tipi)
end
end

function render_yazi()


if olay == "devam" then
anim1 = anim1 + 1
if(anim1<40)then
uyuyor = "UYUYOR."
end
if(anim1>80)then
uyuyor = "UYUYOR.."
if(anim1>90)then
uyuyor = "UYUYOR..."
end
end
end

dxDrawText(uyuyor, 0 - 1, 362 - 1, 1360 - 1, 407 - 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "bottom", false, false, false, true, false)
dxDrawText(uyuyor, 0 + 1, 362 - 1, 1360 + 1, 407 - 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "bottom", false, false, false, true, false)
dxDrawText(uyuyor, 0 - 1, 362 + 1, 1360 - 1, 407 + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "bottom", false, false, false, true, false)
dxDrawText(uyuyor, 0 + 1, 362 + 1, 1360 + 1, 407 + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "bottom", false, false, false, true, false)
dxDrawText(uyuyor, (screenW - 1360) / 2, (screenH - 45) / 2, ((screenW - 1360) / 2) + 1360, ( (screenH - 45) / 2) + 45, tocolor(254, 254, 254, 255), 2.00, "default-bold", "center", "bottom", false, false, false, true, false)

dxDrawRectangle(screenW - 337 - 10, (screenH - 20) / 2, 337, 20, tocolor(10,10,10, 187), false)
    dxDrawText("#ffffff Uyanmak isterseniz #cc0000'space' #fffffftuşuna basınız.", screenW - 337 - 10, (screenH - 20) / 2, (screenW - 337 - 10) + 337, ( (screenH - 20) / 2) + 20, tocolor(255, 255, 255, 255), 0.7,yazi_tipi, "center", "center", false, false, false, true, false)
end

function panel_olustur(x,y,w,h,yazi,renk,bilgi)
dxDrawRectangle(x,y,w,h,tocolor(0,0,0,180))
dxDrawRectangle(x,y,w,25,tocolor(0,0,0,120))
dxDrawRectangle(x,y+25,w,1,renk)
dxDrawText(yazi,x,y,w+x,y+25,tocolor(255,255,255,255),0.8,yazi_tipi,"center","center")
dxDrawText(bilgi,x,y+55,w+x,y+25,tocolor(255,255,255,255),0.6,yazi_tipi,"center","center")
end


function button_olustur(yazi,x,y,w,h,r,g,b,font)

if isInSlot(x, y, w, h) then
dxDrawRectangle(x, y, w, h,tocolor(r,g,b,120));

--dxDrawText(yazi,x-1,y-1,w+x,25+y,tocolor(0,0,0,255),0.7,font,"center","center",false,false,false,true)
dxDrawText(yazi,x,y,w+x,22+y,tocolor(255,255,255,255),0.7,font,"center","center",false,false,false,true)

-- çizgiler
dxDrawRectangle(x,y,w,1,tocolor(0,0,0,255))
dxDrawRectangle(x,y+h,w,1,tocolor(0,0,0,255))
dxDrawRectangle(x,y,1,h,tocolor(0,0,0,255))
dxDrawRectangle(x+w-1,y,1,h,tocolor(0,0,0,255))
else

dxDrawRectangle(x, y, w, h,tocolor(r,g,b,200));

--dxDrawText(yazi,x-1,y-1,w+x,20+y,tocolor(0,0,0,255),0.7,font,"center","center",false,false,false,true)
dxDrawText(yazi,x,y,w+x,22+y,tocolor(255,255,255,255),0.7,font,"center","center",false,false,false,true)

-- çizgiler
dxDrawRectangle(x,y,w,1,tocolor(0,0,0,255))
dxDrawRectangle(x,y+h,w,1,tocolor(0,0,0,255))
dxDrawRectangle(x,y,1,h,tocolor(0,0,0,255))
dxDrawRectangle(x+w-1,y,1,h,tocolor(0,0,0,255))

end
end

function inBox(dX, dY, dSZ, dM, eX, eY)
if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
return true
else
return false
end
end

function isInSlot(xS,yS,wS,hS)
if(isCursorShowing()) then
XY = {guiGetScreenSize()}
local cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX*XY[1], cursorY*XY[2]
if(inBox(xS,yS,wS,hS, cursorX, cursorY)) then
return true
else
return false
end
end
end

--/ tıklama işlemi /--
function tiklama_olay(button,state)
if button_durum == true then
if button == "left" and state == "down" and panel_durum == "panel" then
--* misafir girdi *--
if isInSlot(px+22,py+60,250,22) and panel_durum == "panel" then  -- eminim
eminim()

return end
if isInSlot(px+22,py+90,250,22) and panel_durum == "panel" then
emin_degilim()
return end
end
end
end
addEventHandler("onClientClick",root,tiklama_olay)

--// TUŞ OLAYI //--
function tus(tus,pres)
if durum == true  then
  if tus == "space" or pres == "down" then
  fadeCamera(true,1)
removeEventHandler("onClientRender",root,render)
removeEventHandler("onClientRender",root,render_yazi)
showChat(true)
showCursor(false)
outputChatBox(getPlayerName(localPlayer).." #ff0000Günaydın Asker.",255,255,255,true)
anim1 = 2
yazi_durum = false
durum = false
uyuyor = ""
end
  end
end
addEventHandler("onClientKey",root,tus)

local pickup = createPickup(220.7607421875, 1342.814453125, 10.674425125122, 3, 1272, 1)
[code]
« Son Düzenleme: 15 Mart 2019, 21:24:42 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Uyku Sistemini Hud'a Nasıl Bağlarım
« : 04 Mart 2019, 17:14:24 »

Çevrimdışı Ky

  • Uzman Üye
  • *
    • İleti: 614
Bu attığın kodlar uyku sisteminin tamamımı yoksa sadece client mi ?
 


Çevrimdışı VaTaN

  • Bilgin Üye
  • *
    • İleti: 270
Linki görebilmek için Kayıt olun yada Giriş yapın.
Bu attığın kodlar uyku sisteminin tamamımı yoksa sadece client mi ?

Niye Sordun Client i ?
 


Çevrimdışı Strong

  • Deneyimli Üye
  • *
    • İleti: 455
  • After Roleplay Developer
export gereklidir biraz araştır. Örnek:
        exports["scriptadı"]:fonksiyon ()

hatırladığıma göre böyle birşeydi internetten araştırarak daha detaylı bilgi alabilirsin.