Jump to content

India

Members
  • Posts

    85
  • Joined

  • Last visited

Posts posted by India

  1. 1 hour ago, Tekken said:

    Let me get on the pc

    Okay, there is all of code client/server

    client

    local drawDistance = 70
    g_StreamedInPlayers = {}
    function drawHPBar(x, y, v, d)
      if v < 0 then
        v = 0
      elseif v > 100 then
        v = 100
      end
      dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 255 - d))
      dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor((100 - v) * 2.55, v * 2.55, 0, 255 - d))
    end
    function drawArmourBar(x, y, v, d)
      if v < 0 then
        v = 0
      elseif v > 100 then
        v = 100
      end
      dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 255 - d))
      dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor(255, 255, 255, 255 - d))
    end
    function drawHud()
      healthColor = tocolor(0, 0, 0, 255)
      healthbgColor = tocolor(255, 151, 0, 127)
      healthfgColor = tocolor(255, 151, 0, 185)
      sx, sy = guiGetScreenSize()
      healthx = sx / 800 * 683
      healthy = sy / 600 * 89
      healthxoverlay = sx / 800 * 685
      healthyoverlay = sy / 600 * 91
      vehiclehealthx = sx / 800 * 619
      vehiclehealthy = sy / 600 * 169
      vehiclehealthxoverlay = sx / 800 * 621
      vehiclehealthyoverlay = sy / 600 * 171
      if not normalhealthbar then
        --local health = getElementHealth(getLocalPlayer())
        --local armour = getPedArmor(getLocalPlayer())
        local rate = 500 / getPedStat(getLocalPlayer(), 24)
        if getElementHealth(getLocalPlayer()) == 0 then
          if 500 > getTickCount() - visibleTick then
            do
              local healthRelative = health * rate / 100
              local v = health * rate
              dxDrawRectangle(healthx, healthy, 76, 12, healthColor, false)
              dxDrawRectangle(healthxoverlay, healthyoverlay, 72, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 127), false)
              dxDrawRectangle(healthxoverlay, healthyoverlay, 72 * healthRelative, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 185), false)
            end
          elseif getTickCount() - visibleTick >= 1000 then
            visibleTick = getTickCount()
          end
        else
          local healthRelative = health * rate / 100
          local v = health * rate
          dxDrawRectangle(healthx, healthy, 76, 12, healthColor, false)
          dxDrawRectangle(healthxoverlay, healthyoverlay, 72, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 127), false)
          dxDrawRectangle(healthxoverlay, healthyoverlay, 72 * healthRelative, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 185), false)
        end
      end
    end
    function un:O(text)
      return string.gsub(text, "(#%x%x%x%x%x%x)", function(colorString)
        return ""
      end)
    end
    function onClientRender()
      local cx, cy, cz, lx, ly, lz = getCameraMatrix()
      for k, player in pairs(g_StreamedInPlayers) do
        if isElement(player) and isElementStreamedIn(player) then
          do
            local vx, vy, vz = getPedBonePosition(player, 8)
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
            if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then
              local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
              if x and y then
               local name = getPlayerName(player)
                local w = dxGetTextWidth(name, 1, "default-bold")
                local h = dxGetFontHeight(1, "default-bold")
    			local cargo_player = getElementData(player, "cargo") or ""
    			--local cargo_player = getPlayerName(player)..": "..getElementData(player, "cargo") or ""
    			local cargo_player_cor = getElementData(player, "cargo->cor") or {255, 255, 255, 240}
    			dxDrawText(cargo_player, x - 1 - w / 2, y - 1 - h - 40, w, h, tocolor(0, 0, 0), 2, "default-bold")
                dxDrawColorText(cargo_player, x - w / 2, y - h - 40, w, h, tocolor(unpack(cargo_player_cor)), 2, "default-bold")
    			-- part by AndreiSR
               --dxDrawText(name2, x - 1 - w / 2, y - 1 - h - 12, w, h, tocolor(0, 0, 0), 1, "default-bold")
                --dxDrawColorText(name, x - w / 2, y - h - 12, w, h, tocolor(getPlayerNametagColor(player)), 1, "default-bold")
                --local health = getElementHealth(player)
                --local armour = getPedArmor(player)
                --if health > 0 then
                  local rate = 500 / getPedStat(player, 24)
                  --drawHPBar(x, y - 6, health * rate, dist)
                  --if armour > 0 then
                    --drawArmourBar(x, y - 12, armour, dist)
                end
              end
            end
        else
          table.remove(g_StreamedInPlayers, k)
        end
      end
    end
    addEventHandler("onClientRender", root, onClientRender)
    function onClientElementStreamIn()
      if getElementType(source) == "player" and source ~= getLocalPlayer() then
        setPlayerNametagShowing(source, false)
        table.insert(g_StreamedInPlayers, source)
      end
    end
    addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn)
    function onClientResourceStart(startedResource)
      visibleTick = getTickCount()
      counter = 0
      normalhealthbar = false
      local players = getElementsByType("player")
      for k, v in pairs(players) do
        if isElementStreamedIn(v) and v ~= getLocalPlayer() then
          setPlayerNametagShowing(v, false)
          table.insert(g_StreamedInPlayers, v)
        end
      end
    end
    addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart)
    function dxDrawColorText(str, ax, ay, bx, by, color, scale, font)
      local pat = "(.-)#(%x%x%x%x%x%x)"
      local s, e, cap, col = str:find(pat, 1)
      local last = 1
      while s do
        if cap == "" and col then
          color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
        end
        if s ~= 1 or cap ~= "" then
          local w = dxGetTextWidth(cap, scale, font)
          dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
          ax = ax + w
          color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
        end
        last = e + 1
        s, e, cap, col = str:find(pat, last)
      end
      if last <= #str then
        cap = str:sub(last)
        local w = dxGetTextWidth(cap, scale, font)
        dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
      end
    end

    server

    function setCargo(player)
    	if player then
    		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Kurucu")) then
    			setElementData(player, "cargo", "Sunucu Yazılımcısı")
    			setElementData(player, "cargo->cor", {255, 0, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("KurucuOffline")) then
                removeElementData(player, "cargo_player")		--REMOVE DATA		
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperAdmin")) then
    			setElementData(player, "cargo", "Süper ADMİN")
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperAdminOffline")) then
    			removeElementData(player, "cargo_player")		--REMOVE DATA
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
    			setElementData(player, "cargo", "Admin")
    			setElementData(player, "cargo->cor", {255, 0, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("AdminOffline")) then
    			removeElementData(player, "cargo_player")		--REMOVE DATA
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperModerator")) then
    			setElementData(player, "cargo", "Süper Moderatör")
    			setElementData(player, "cargo->cor", {158, 255, 39})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperModeratorOffline")) then
    			removeElementData(player, "cargo_player")		--REMOVE DATA	
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Moderator")) then
    			setElementData(player, "cargo", "Moderatör")
    			setElementData(player, "cargo->cor", {255, 255, 0, 240})			
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("ModeratorOffline")) then
    			removeElementData(player, "cargo_player")		--REMOVE DATA			
    		end
    	end
    end
    
    setTimer(
    function()
    	for i, pl in pairs(getElementsByType("player")) do
    		if pl ~= (false or nil) then
    			setCargo(pl)
    		end
    	end
    end,
    3000,
    0)

     

  2. 1 hour ago, Tekken said:

    What is the problem then?

    with this 

    local cargo_player = getPlayerName(player)..": "..getElementData(player, "cargo") or ""

    attempt to concatenate a boolean value xD

  3. local cargo_player = getPlayerName(player)..": "..getElementData(player, "cargo") or ""

    Still same

    but with this, no errors,

    local cargo_player = getElementData(player, "cargo") or ""

    I want get playerName also, like this "Admin India"

  4. I do something

    tag are going away when the player is in the AdminOffline ACL Group, exactly as i want but the problem is in clientside.

    ERROR: attempt to concatenate a boolean value

    error line:

    local cargo_player = getPlayerName(player)..": "..getElementData(player, "cargo") or nil

     

    elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
    setElementData(player, "cargo", "Admin") --ADD DATA
    setElementData(player, "cargo->cor", {255, 0, 0, 240})
    elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("AdminOffline")) then
    removeElementData(player, "cargo", "")  --REMOVE DATA
    setElementData(player, "cargo->cor", {255, 0, 0, 240})
  5. 19 hours ago, Tekken said:

    else 

    setElementData(player, "cargo", "")

    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Kurucu")) then
    setElementData(player, "cargo", "Sunucu Yazılımcısı")
    else
    setElementData(player, "cargo", "")
    setElementData(player, "cargo->cor", {255, 0, 0, 240})

    like this?

  6. 9 hours ago, Tekken said:

    There might be something wrong with "cargo" element data ?

    function setCargo(player)
    	if player then
    		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Kurucu")) then
    			setElementData(player, "cargo", "Sunucu Yazılımcısı")
    			setElementData(player, "cargo->cor", {255, 0, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperAdmin")) then
    			setElementData(player, "cargo", "Süper ADMİN")
    			setElementData(player, "cargo->cor", {255, 0, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
    			setElementData(player, "cargo", "Admin")
    			setElementData(player, "cargo->cor", {255, 0, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Rehber")) then
    			setElementData(player, "cargo", "Sunucu Rehberi")
    			setElementData(player, "cargo->cor", {255, 100, 0, 240})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SuperModerator")) then
    			setElementData(player, "cargo", "Süper Moderatör")
    			setElementData(player, "cargo->cor", {158, 255, 39})
    		elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Moderator")) then
    			setElementData(player, "cargo", "Moderatör")
    			setElementData(player, "cargo->cor", {255, 255, 0, 240})
    		end
    	end
    end
    
    setTimer(
    function()
    	for i, pl in pairs(getElementsByType("player")) do
    		if pl ~= (false or nil) then
    			setCargo(pl)
    		end
    	end
    end,
    3000,
    0)

     

    16 hours ago, Haxardous said:

    you need to use

    
    bool removeEventHandler(string eventName, element attachedTo, function functionVar) 

     

    I don't know, can u make for me?

  7. Hi, i have a admintag system, displays the name of the ACL on the character. But the problem is that while the player is not in ACL, her last ACL name remains.

    Example: This player currently has no ACL but the text remains

    Spoiler

    mta-screen-2021-03-17-17-31-59.png

    client.lua

    local drawDistance = 70
    g_StreamedInPlayers = {}
    function drawHPBar(x, y, v, d)
      if v < 0 then
        v = 0
      elseif v > 100 then
        v = 100
      end
      dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 255 - d))
      dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor((100 - v) * 2.55, v * 2.55, 0, 255 - d))
    end
    function drawArmourBar(x, y, v, d)
      if v < 0 then
        v = 0
      elseif v > 100 then
        v = 100
      end
      dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 255 - d))
      dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor(255, 255, 255, 255 - d))
    end
    function drawHud()
      healthColor = tocolor(0, 0, 0, 255)
      healthbgColor = tocolor(255, 151, 0, 127)
      healthfgColor = tocolor(255, 151, 0, 185)
      sx, sy = guiGetScreenSize()
      healthx = sx / 800 * 683
      healthy = sy / 600 * 89
      healthxoverlay = sx / 800 * 685
      healthyoverlay = sy / 600 * 91
      vehiclehealthx = sx / 800 * 619
      vehiclehealthy = sy / 600 * 169
      vehiclehealthxoverlay = sx / 800 * 621
      vehiclehealthyoverlay = sy / 600 * 171
      if not normalhealthbar then
        --local health = getElementHealth(getLocalPlayer())
        --local armour = getPedArmor(getLocalPlayer())
        local rate = 500 / getPedStat(getLocalPlayer(), 24)
        if getElementHealth(getLocalPlayer()) == 0 then
          if 500 > getTickCount() - visibleTick then
            do
              local healthRelative = health * rate / 100
              local v = health * rate
              dxDrawRectangle(healthx, healthy, 76, 12, healthColor, false)
              dxDrawRectangle(healthxoverlay, healthyoverlay, 72, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 127), false)
              dxDrawRectangle(healthxoverlay, healthyoverlay, 72 * healthRelative, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 185), false)
            end
          elseif getTickCount() - visibleTick >= 1000 then
            visibleTick = getTickCount()
          end
        else
          local healthRelative = health * rate / 100
          local v = health * rate
          dxDrawRectangle(healthx, healthy, 76, 12, healthColor, false)
          dxDrawRectangle(healthxoverlay, healthyoverlay, 72, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 127), false)
          dxDrawRectangle(healthxoverlay, healthyoverlay, 72 * healthRelative, 8, tocolor((100 - v) * 2.55, v * 2.55, 0, 185), false)
        end
      end
    end
    function un:O(text)
      return string.gsub(text, "(#%x%x%x%x%x%x)", function(colorString)
        return ""
      end)
    end
    function onClientRender()
      local cx, cy, cz, lx, ly, lz = getCameraMatrix()
      for k, player in pairs(g_StreamedInPlayers) do
        if isElement(player) and isElementStreamedIn(player) then
          do
            local vx, vy, vz = getPedBonePosition(player, 8)
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
            if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then
              local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
              if x and y then
               local name = getPlayerName(player)
                --local name2 = un:O(getPlayerName(player))
                local w = dxGetTextWidth(name, 1, "default-bold")
                local h = dxGetFontHeight(1, "default-bold")
    			-- part by AndreiSR
    			local cargo_player = getElementData(player, "cargo") or ""
    			local cargo_player_cor = getElementData(player, "cargo->cor") or {255, 255, 255, 240}
    			dxDrawText(cargo_player, x - 1 - w / 2, y - 1 - h - 40, w, h, tocolor(0, 0, 0), 2, "default-bold")
                dxDrawColorText(cargo_player, x - w / 2, y - h - 40, w, h, tocolor(unpack(cargo_player_cor)), 2, "default-bold")
    			-- part by AndreiSR
               --dxDrawText(name2, x - 1 - w / 2, y - 1 - h - 12, w, h, tocolor(0, 0, 0), 1, "default-bold")
                --dxDrawColorText(name, x - w / 2, y - h - 12, w, h, tocolor(getPlayerNametagColor(player)), 1, "default-bold")
                --local health = getElementHealth(player)
                --local armour = getPedArmor(player)
                --if health > 0 then
                  local rate = 500 / getPedStat(player, 24)
                  --drawHPBar(x, y - 6, health * rate, dist)
                  --if armour > 0 then
                    --drawArmourBar(x, y - 12, armour, dist)
                end
              end
            end
        else
          table.remove(g_StreamedInPlayers, k)
        end
      end
    end
    addEventHandler("onClientRender", root, onClientRender)
    function onClientElementStreamIn()
      if getElementType(source) == "player" and source ~= getLocalPlayer() then
        setPlayerNametagShowing(source, false)
        table.insert(g_StreamedInPlayers, source)
      end
    end
    addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn)
    function onClientResourceStart(startedResource)
      visibleTick = getTickCount()
      counter = 0
      normalhealthbar = false
      local players = getElementsByType("player")
      for k, v in pairs(players) do
        if isElementStreamedIn(v) and v ~= getLocalPlayer() then
          setPlayerNametagShowing(v, false)
          table.insert(g_StreamedInPlayers, v)
        end
      end
    end
    addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart)
    function dxDrawColorText(str, ax, ay, bx, by, color, scale, font)
      local pat = "(.-)#(%x%x%x%x%x%x)"
      local s, e, cap, col = str:find(pat, 1)
      local last = 1
      while s do
        if cap == "" and col then
          color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
        end
        if s ~= 1 or cap ~= "" then
          local w = dxGetTextWidth(cap, scale, font)
          dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
          ax = ax + w
          color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
        end
        last = e + 1
        s, e, cap, col = str:find(pat, last)
      end
      if last <= #str then
        cap = str:sub(last)
        local w = dxGetTextWidth(cap, scale, font)
        dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
      end
    end

     

  8. 1 hour ago, SpecT said:
    
    	setTimer ( function ( shape, zomb )
    		local attaches = getAttachedElements ( zomb,1)
    		if attaches then
    			for ElementKey, ElementValue in ipairs ( attaches ) do
    				if isElement ( ElementValue ) then
    					destroyElement ( ElementValue )
    				end
    			end
    		end
    		destroyElement ( zomb,1)
    		aliveZ = aliveZ - 1 
    		if isElement ( shape ) then
    			setElementData ( shape, "zSpawned", false )
    			setElementData ( shape, "zombie", false )
    		end
    	end,resptimer, 1, getElementData ( zomb, "spawnShape" ), zomb )

     

    Still same, this lines gives warning;

    local attaches = getAttachedElements ( zomb,1)
    
    destroyElement ( zomb,1)

     

  9. Hello, I get this warning's when i bury up zombies in DayZ game mode

    Bad argument @'getAttachedElements' [Expected element at argument 1]

    Bad argument @'destroyElement' [Expected element at argument 1]

    function respawnZombieInTime ( zomb, immediatly )
    	if exports.npc_hlc:isHLCEnabled ( zomb ) then
    		exports.npc_hlc:disableHLCForNPC (zomb)
    	end
    	--if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end
    	--if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end
    	local resptimer = timeToRespawnZombie
    	if immediatly then
    		resptimer = 20000
    	end
    	setTimer ( function ( shape )
    		local attaches = getAttachedElements ( zomb,1)
    		if attaches then
    			for ElementKey, ElementValue in ipairs ( attaches ) do
    				if isElement ( ElementValue ) then
    					destroyElement ( ElementValue )
    				end
    			end
    		end
    		destroyElement ( zomb,1)
    		aliveZ = aliveZ - 1 
    		if isElement ( shape ) then
    			setElementData ( shape, "zSpawned", false )
    			setElementData ( shape, "zombie", false )
    		end
    	end,resptimer, 1, getElementData ( zomb, "spawnShape" ) )
    	--setElementData ( root, 'zombiesalive', getElementData ( root, 'zombiesalive' )-1 )
    end

     

  10. Hello, i have inventory system for DayZ Gamemode, if i delete the values there, it gives an error. Cause trying to attract a value that is not. If there is no value, i want it to be "1". so you can take 1 item when the value is empty.

    Spoiler

    mta-screen-2021-03-06-16-06-47.png

     

    function onPlayerMoveItemOutOfInventory ()
    	hideRightClickInventoryMenu ()
    	if playerMovedInInventory or getNetworkStats().packetlossLastSecond > 10 then return end
    	itemPlus = tonumber(guiGetText(editBoxInv))
    	if itemPlus > 0 then
    		loot = getElementData(localPlayer,"currentCol")
    		dropItemName = guiGridListGetItemText ( gridlistItems["inventory"], guiGridListGetSelectedItem ( gridlistItems["inventory"] ), 1 )
    		itemName = guiGridListGetItemData(gridlistItems["inventory"], guiGridListGetSelectedItem ( gridlistItems["inventory"] ), 1 )
    		if dropItemName == "" then return end
    		if getElementData(localPlayer,itemName) and getElementData(localPlayer,itemName) >= 1 then
    			if getElementData(localPlayer,itemName) < itemPlus then
    				itemPlus = getElementData(localPlayer,itemName)
    			end
    			if getElementData(localPlayer,itemName) >= itemPlus then
    				move,reason = onPlayerDontMoveItemOutOFInventory(itemName,itemPlus)
    				if move then
    					if loot then
    						if isPlayerInLoot() then
    							if getLootCurrentSlots(loot) + (getItemSlots(itemName)*itemPlus) <= getLootMaxAviableSlots(isPlayerInLoot()) then
    								setElementData(localPlayer,itemName,getElementData(localPlayer,itemName)-itemPlus)
    								if not getElementData(loot,itemName) then setElementData(loot,itemName,0) end
    								setElementData(loot,itemName,getElementData(loot,itemName)+itemPlus)
    								playerMovedInInventory = true
    								setTimer(function() playerMovedInInventory = false end,300,1)
    								if loot and getElementData(loot,"itemloot") then
    									triggerServerEvent("refre:~emLoot",getRootElement(),loot,getElementData(loot,"parent"))
    								end
    							else
    								triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Yeterli alan yok", 255, 0, 0 )
    							end
    						end
    					else
    						if getNetworkStats().packetlossLastSecond < 2 then
    							setElementData(localPlayer,itemName,getElementData(localPlayer,itemName)-itemPlus)
    							triggerServerEvent("playerDropAItem",localPlayer,itemName,itemPlus,dropItemName)
    						else
    							triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Kötü sunucu bağlantısı", 255, 0, 0 )
    						end
    						playerMovedInInventory = true
    						setTimer(function() playerMovedInInventory = false end,800,1)
    					end
    					triggerServerEvent("shiftLoot",localPlayer,itemName,itemPlus,loot)
    				else
    					triggerEvent ("displayClientInfo", localPlayer,"Inventory", reason, 255, 0, 0 )
    				end
    			else
    				triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Çok fazla değer", 255, 0, 0 )
    			end
    		end
    		refreshInventory()
    		if isPlayerInLoot() then
    			if getElementData(loot,"safe") == 1 and guiGetText(lootSlot) == "Yer:" then
    				hideInventoryManual ()
    				triggerEvent ("onClientOpenSafe", localPlayer, loot)
    				return
    			end
    			refreshLoot(loot)
    		end
    	else
    		triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Çok küçük değer", 255, 0, 0 )
    	end
    end
    addEventHandler ( "onClientGUIClick", buttonInv, onPlayerMoveItemOutOfInventory, false )

     

  11. I have a dayz gamemode and there is a system for helmet and vest, player health protection is increased when normally wearing helmet and vest But it's not happening here

    Anyone can help me? I really need it, i could not find a solution

    editor_client.lua

    editor_client.lua

    clothDamageReduce = {
    	[3] = 
    	{ 
    		"clothBody", 
    		{ 
    			["Yelek: Orman Kamuflajı [0 Zırh]"] = 10,
    			["Yelek: Kurşun Geçirmez [30 Zırh]"] = 40,
    			["Yelek: Balistik [60 Zırh]"] = 65, 
    			["Yelek: Orman Kamuflajlı [50 Zırh]"] = 60, 
    			["Yelek: ET-053 [80 Zırh]"] = 85,
    		} 
    	},
    	[9] = 
    	{ 
    		"clothHead", 
    		{ 
    			["Motorsiklet Kaskı [97 Zırh]"] = 99, 
    			["Kamuflajlı Kask [97 Zırh]"] = 99,
    			["Kask: Bandanalı [20 Zırh]"] = 30,
    			["Kask: C.E.L.L [90 Zırh]"] = 95,
    			["Kask: Koyu Yeşil [70 Zırh]"] = 75,
    			["Şapka: Çim Kamuflajlı [0 Zırh]"] = 10,
    			["Bere: Siyah Komando [0 Zırh]"] = 10,
    			["Bere: Kırmızı Komando [0 Zırh]"] = 10,
    			["Şapka: Asker [0 Zırh]"] = 10,
    		} 
    	},
    }
    clothSlots = {
    	["clothHead"] = 
    	{
    		["Motorsiklet Kaskı [97 Zırh]"] = true, 
    		["Kamuflajlı Kask [97 Zırh]"] = true,
    		["Kask: Bandanalı [20 Zırh]"] = true,
    		["Kask: C.E.L.L [90 Zırh]"] = true,
    		["Kask: Koyu Yeşil [70 Zırh]"] = true,
    		["Şapka: Çim Kamuflajlı [0 Zırh]"] = true,
    		["Bere: Siyah Komando [0 Zırh]"] = true,
    		["Bere: Kırmızı Komando [0 Zırh]"] = true,
    		["Şapka: Asker [0 Zırh]"] = true,
    	},
    	["clothBody"] = 
    	{
    		["Yelek: Orman Kamuflajı [0 Zırh]"] = true,
    		["Yelek: Kurşun Geçirmez [30 Zırh]"] = true,
    		["Yelek: Balistik [60 Zırh]"] = true, 
    		["Yelek: Orman Kamuflajlı [50 Zırh]"] = true, 
    		["Yelek: ET-053 [80 Zırh]"] = true,
    	},
    }

     

    survivorSystem_client.lua

    function Damage_ToCloth (bone)
    	if clothDamageReduce[bone] then
    		local cloth = getElementData ( localPlayer, clothDamageReduce[bone][1] ) or "no"
    		for i, v in pairs ( clothDamageReduce[bone][2] ) do
    			if cloth == i then
    				return 1-v/100
    			end
    		end
    	end
    	return 1
    end
    
    function playerGetDamageDayZ ( attacker, weapon, bodypart, loss )
    	cancelEvent()
    	if getElementData(localPlayer,"inGreenZone") or (getElementData(localPlayer,"safe:spawn") or 0) > 0 then
    		return
    	end	
    	if attacker and getElementType(attacker) == "vehicle" then
    		speedx, speedy, speedz = getElementVelocity ( attacker )
    		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
    		kmh = actualspeed * 180
    		if kmh >= 90 then
    			local vehkiller = getVehicleOccupant ( attacker )
    			setElementData(source,"blood",0)
    			if getElementData(source,"blood") <= 0 then
    				triggerServerEvent("kilLDayZPlayer",source,vehkiller)
    			end
    		end
    	end
    	damage = 100
    	headshot = true
    	if weapon == 37 then
    		return
    	end
    	local damageded = Damage_ToCloth (bodypart)
    	if attacker and getElementData(attacker,"zombie") then
    		local number = math.random(1,3)
    		-- local sound = playSound("sounds/attack_"..number..".ogg")
    		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-gameplayVariables["zombiedamage"]*damageded)
    		local number = math.random(1,5)
    		if number == 3 then
    			setElementData(getLocalPlayer(),"infection",true)
    		end
    		local number = math.random(1,7)
    		if number == 4 then
    			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*10))
    		end
    	end
    	if attacker and getElementData(attacker,"bossie") then
    		setElementData(localPlayer,"blood",getElementData(localPlayer,"blood")-(getElementData(attacker,"damage") or 1200) * damageded)
    		local number = math.random(1,5)
    		if number == 3 then
    			setElementData(getLocalPlayer(),"infection",true)
    		end
    		local number = math.random(1,7)
    		if number == 4 then
    			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*10))
    		end
    	end
    	if weapon == 49 then
    		if loss > 30 then
    			setElementData(getLocalPlayer(),"brokenbone",true)
    			-- setPedControlState ("jump",true)
    			setPedControlState ("jump",true)
    			setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.floor(loss*10)*damageded)
    		end
    		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.floor(loss*5)*damageded)
    	elseif weapon == 63 or weapon == 51 or weapon == 19 then
    		setElementData(getLocalPlayer(),"blood",0)
    		if getElementData(getLocalPlayer(),"blood") <= 0 then
    			if not getElementData(getLocalPlayer(),"isDead") == true then
    				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot)
    			end
    		end
    	elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
    		local number = math.random(1,8)
    		if number >= 6 or number <= 8 then
    			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*10))
    		end
    		local number = math.random(1,7)
    		if number == 2 then
    			setElementData(getLocalPlayer(),"pain",true)
    		end
    
    		damage = sWeapons[getElementData(attacker,"selectedWeapon")].damage
    		if bodypart == 9 then
    			damage = damage*3       --Kafadan hasar verme DOĞRU YER BURA XD
    			headshot = true
    		end
    		if bodypart == 7 or bodypart == 8 then
    			setElementData(getLocalPlayer(),"brokenbone",true)
    		end
    --		playRandomHitSound()
    		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(damage*0.5,damage*0.5))   -- Sol/Sağ bacak hasar oranı
    		if not getElementData(getLocalPlayer(),"bandit") then
    			setElementData(attacker,"humanity",getElementData(attacker,"humanity")-math.random(40,200))
    			if getElementData(attacker,"humanity") < 0 then
    				setElementData(attacker,"bandit",true)
    			end
    		else
    			setElementData(attacker,"humanity",getElementData(attacker,"humanity")+math.random(40,200))
    			if getElementData(attacker,"humanity") > 5000 then
    				setElementData(attacker,"humanity",5000)
    			end
    			if getElementData(attacker,"humanity") > 2000 then
    				setElementData(attacker,"bandit",false)
    			end
    		end
    		if getElementData(getLocalPlayer(),"blood") <= 0 then
    			if not getElementData(getLocalPlayer(),"isDead") then
    				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID (weapon))
    				setElementData(getLocalPlayer(),"isDead",true)
    			end
    		end
    	elseif weapon == 54 or weapon == 63 or weapon == 49 or weapon == 51 then
    		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(100,1000)*damageded)
    		local number = math.random(1,5)
    		if loss > 30 then
    			setElementData(getLocalPlayer(),"brokenbone",true)
    			setPedControlState ("jump",true)
    		end
    		if loss >= 100 then
    			setElementData(getLocalPlayer(),"blood",49)
    			setElementData(getLocalPlayer(),"bleeding",50)
    		end
    		local number = math.random(1,11)
    		if number == 3 then
    			setElementData(getLocalPlayer(),"pain",true)
    		end
    		if getElementData(getLocalPlayer(),"blood") <= 0 then
    			if not getElementData(getLocalPlayer(),"isDead") == true then
    				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID (weapon))
    				setElementData(getLocalPlayer(),"isDead",true)
    			end
    		end
    	end
    end
    addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), playerGetDamageDayZ )
    
    function playLocalSound3D_client(x,y,z,music,radius) 
    	local sound = playSound3D(music, x, y, z, true) 
    	if not radius then radius = 50 end 
    	setSoundMaxDistance(sound, radius) 
    	local soundLength = getSoundLength(sound) 
    	setTimer(stopSound, soundLength*1000, 1, sound) 
    end
    addEvent ("playLocalSound3D_client", true) 
    addEventHandler ("playLocalSound3D_client", getRootElement(), playLocalSound3D_client)
    
    
    function pedGetDamageDayZ ( attacker, weapon, bodypart, loss )
    	cancelEvent()
    	if attacker and getElementType(attacker) == "vehicle" and not getElementData(source,"bossie") then
    		speedx, speedy, speedz = getElementVelocity ( attacker )
    		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
    		kmh = actualspeed * 180
    		if kmh >= 50 then
    			local vehkiller = getVehicleOccupant ( attacker )
    			setElementData(source,"blood",0)
    			if getElementData(source,"blood") <= 0 then
    				triggerServerEvent("onZombieGetsKilled",source,vehkiller)
    			end
    		end
    	end
    	if attacker and attacker == getLocalPlayer() then
    		damage = 100
    		if weapon == 37 then
    			return
    		end
    		if weapon == 63 or weapon == 51 or weapon == 19 then
    			setElementData(source,"blood",0)
    			if getElementData(source,"blood") <= 0 then
    				if not getElementData(source,"bossie") then
    					triggerServerEvent("onZombieGetsKilled",source,attacker)
    				else
    					triggerServerEvent("onbossieGetsKilled",source,attacker)
    				end	
    			end
    		elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
    		damage = sWeapons[getElementData(attacker,"selectedWeapon")].damage
    		if bodypart == 9 then
    			damage = damage*1   --KAFA HASAR VERME ORANI
    			headshot = true    -- true olursa ( Kafaya Tek Atıyor )
    		end
    			setElementData(source,"blood",getElementData(source,"blood")-math.random(damage*0.75,damage*1.25))
    			if getElementData(source,"blood") <= 0 then
    				if not getElementData(source,"bossie") then
    					triggerServerEvent("onZombieGetsKilled",source,attacker,headshot)
    				else
    					triggerServerEvent("onbossieGetsKilled",source,attacker,headshot)
    				end
    			end
    		end
    	end
    end
    addEventHandler ( "onClientPedDamage", getRootElement(), pedGetDamageDayZ )

     

  12. 10 hours ago, Patrick said:
    
    for _, area in ipairs(getElementsByType('radararea')) do
        local areaX, areaY = getElementPosition(area)
        local sizeX, sizeY = getRadarAreaSize(area)
        local dx = (((areaX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
        local dy = mapH - (((areaY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
        local dendx = ((((areaX+sizeX)*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
        local dendy = mapH - ((((areaY+sizeY)*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
        local red,green,blue,alpha = getRadarAreaColor(area)
        dxDrawRectangle(dx, dy, dendx-dx, dendy-dy, tocolor(red,green,blue,alpha))
    end

    Should look like something like that, based on the blip's one.

    Thanks ❤️

  13. I tried to add RadarAreas (greenzones) on Map, but i couldn't do, anyone can help me?

     

    Width, Height = guiGetScreenSize()
    IsVisible = false
    Alpha = 205
    Zoom = 1
    mapH = Height
    lBlip = false
    
    function drawBlips()
    	for k,v in ipairs(getElementsByType("blip")) do
    		if not getElementData(v,"DoNotDrawOnMaximap") then
    			local icon=getBlipIcon(v) or 0
    			local size=(getBlipSize(v) or 2)*4
    			local r,g,b,a=getBlipColor(v)
    			
    			if icon~=0 then
    				r,g,b,a=255,255,255,240
    				size=20
    			end
    			
    			local x,y,z=getElementPosition(v)
    			x,y=getMapFromWorldPosition(x,y)
    			
    			local halfsize=size/2
    			
    			dxDrawImage(x-halfsize,y-halfsize,size,size,"images/blips/"..icon..".png",0,0,0,tocolor(r,g,b,a),true)
    		end
    	end
    end
    
    function dxDrawMap()
    	if getElementData(localPlayer,"logedin") then
    		if getElementData(localPlayer,"Harita") <= 0 then
    			startDxmap()
    		end
    		dxDrawImage((Width/2)-(mapH/2), ((Height-mapH)/2),mapH, mapH,"data/world.png",0,0,0,tocolor(255, 255, 255, Alpha))
    		for _, blip in ipairs(getElementsByType('blip')) do
    			local blipX, blipY, blipZ = getElementPosition(blip)
    			local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    			local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    			if getBlipIcon(blip) == 0 then
    				if getElementAttachedTo(blip) ~= localPlayer then
    					red, green, blue, alpha = getBlipColor(blip)
    					dxDrawImage(dx-8,dy-8,16,16,"data/blips/0.png",0,0,0,tocolor(red,green,blue,alpha))
    				end
    			elseif getBlipIcon(blip) == 41 then
    				dxDrawImage(dx-12,dy-12,24,24,"data/blips/label.png",0,0,0,tocolor(25, 25, 255, 255))
    			else
    				dxDrawImage(dx-8,dy-8,16,16,"images/blips/"..getBlipIcon(blip)..".png")
    			end
    		end
    		for _, player in ipairs(getElementsByType("player")) do
    			if getElementData(player,"logedin") then
    				if player == localPlayer then
    					local blipX, blipY, blipZ = getElementPosition(localPlayer)
    					rx,ry,rz = getElementRotation(localPlayer)
    					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    					dxDrawImage(dx-11,dy-11,22,22,"data/blips/2.png", -rz,0,0,tocolor(255, 25, 25, 255))
    				elseif ((getElementData(localPlayer,"gang") == getElementData(player,"gang") and getElementData(player,"gang") ~= "None") or ((getElementData(localPlayer,"gang") == "TRZ" or getElementData(localPlayer,"gang") == "Türkiye'DayZ") and getElementData(localPlayer,"gang_leader") == "leader")) and player ~= localPlayer  then
    					local blipX, blipY, blipZ = getElementPosition(player)
    					rx,ry,rz = getElementRotation(player)
    					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    					local text = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")
    					-- dxDrawImage(dx-6,dy-6,12,12,"data/blips/0.png", -rz,0,0,tocolor(50, 220, 50, 220))
    					dxDrawRectangle(dx, dy+10,dxGetTextWidth(tostring(text), 1, "default")+6,dxGetFontHeight(1, "default"),tocolor(0,0,0,50))
    					dxDrawText(tostring(text),dx+3, dy+11,dxGetTextWidth(tostring(text), 1, "default"),dxGetFontHeight(1, "default"),tocolor(255,255,255),1,"default")
    				elseif (getElementData(player,"gang") == getElementData(localPlayer,"alliance")) and (getElementData(player,"alliance") == getElementData(localPlayer,"gang")) then
    					local blipX, blipY, blipZ = getElementPosition(player)
    					rx,ry,rz = getElementRotation(player)
    					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    					local text = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")
    					-- dxDrawImage(dx-6,dy-6,12,12,"data/blips/0.png", -rz,0,0,tocolor(220, 220, 50, 220))
    					dxDrawRectangle(dx, dy+10,dxGetTextWidth(tostring(text), 1, "default")+6,dxGetFontHeight(1, "default"),tocolor(0,0,0,50))
    					dxDrawText(tostring(text),dx+3, dy+11,dxGetTextWidth(tostring(text), 1, "default"),dxGetFontHeight(1, "default"),tocolor(255,255,255),1,"default")
    				end
    			end
    		end
    		local text = "Sağ Tık - İmlec Göster      Sol Tık - İşaretle     Harita Açmak/Kapatmak Için /openmap [F11]"
    		dxDrawText(text,((Width/2)+20)-200, (Height-10),100,Height,tocolor(0,0,0),1,"default-bold","left","center",false,false,false)
    		dxDrawText(text,((Width/2)+22)-200, (Height-12),100,Height,tocolor(255,255,255),1,"default-bold","left","center",false,false,false)
    	end
    end
    
    function alphaMapUp()
    	if Alpha >= 0 then
    		Alpha = Alpha + 50
    		if Alpha > 255 then Alpha = 255 end
    	else
    		Alpha = 0
    	end
    end
    bindKey("num_div","down",alphaMapUp)
    
    function alphaMapDown()
    	if Alpha <= 255 then
    		Alpha = Alpha - 50
    		if Alpha < 0 then Alpha = 0 end
    	else
    		Alpha = 255
    	end
    end
    bindKey("num_mul","down",alphaMapDown)
    
    function setCursorUp() showCursor(true) end
    function setCursorDown() showCursor(false) end
    
    function onClickOffect(button, state, cursorX, cursorY)
    	if IsVisible then
    		if (button == 'left' and state == 'down') then
    			if isElement(lBlip) then
    				destroyElement(lBlip)
    				setElementData(localPlayer,"labelBlip",nil)
    				lBlip = false
    				return
    			end
    			mX = ((cursorX-((Width/2)-(mapH/2))-(mapH/2))*6000)/mapH
    			mY = ((mapH-cursorY-(mapH/2))*6000)/mapH
    			setElementData(localPlayer,"labelBlip",{mX,mY,getGroundPosition(mX,mY,1000)})
    			lBlip = createBlip (mX, mY, 300, 41)
    		end
    	end
    end
    
    function createMapDot(x,y,z)
    	if isElement(lBlip) then
    		destroyElement(lBlip)
    		setElementData(localPlayer,"labelBlip",nil)
    		lBlip = false
    	end
    	setElementData(localPlayer,"labelBlip",{x,y,getGroundPosition(x,y,1000)})
    	lBlip = createBlip (x,y, 300, 41)
    end
    addEvent( "createMapDot", true )
    addEventHandler( "createMapDot", localPlayer, createMapDot )
    shwochat = false
    function startDxmap()
    	if not getElementData(localPlayer,"logedin") then return end
    	if (getElementData(localPlayer,"Harita") or 0) > 0 then
    		IsVisible = not IsVisible
    		if (IsVisible) then
    			--bindKey("mouse1","down",setPoint)
    			bindKey("mouse2","down",setCursorUp)
    			bindKey("mouse2","up",setCursorDown)
    			addEventHandler('onClientRender', root,dxDrawMap)
    			addEventHandler('onClientClick', root,onClickOffect)
    			if isChatVisible() then
    				showChat(false)
    				shwochat = true
    			end
    		else
    			--unbindKey("mouse1","down",setPoint)
    			unbindKey("mouse2","down",setCursorUp)
    			unbindKey("mouse2","up",setCursorDown)
    			removeEventHandler('onClientRender', root,dxDrawMap)
    			showCursor(false)
    			removeEventHandler('onClientClick', root,onClickOffect)
    			if shwochat then
    				showChat(true)
    				shwochat = false
    			end
    		end
    	end
    end
    bindKey("F11","down",startDxmap)
    addCommandHandler("openmap",startDxmap)
    
    function zoomMap(key)
    	if IsVisible then
    		if key == "num_add" then
    			Zoom = Zoom+0.1
    			if Zoom >= 1.9 then
    				Zoom = 1.9
    			end
    		elseif key == "num_sub" then
    			Zoom = Zoom-0.1
    			if Zoom <= 0.1 then
    				Zoom = 0.1
    			end
    		end
    		mapH = Height * Zoom
    	end
    end
    bindKey("num_add","down",zoomMap)
    bindKey("num_sub","down",zoomMap)

     

×
×
  • Create New...