Jump to content

marker weapon


Recommended Posts

local marker

function markerc(command, ...)
    local weaponIDs = {...}
    if #weaponIDs < 1 then return outputChatBox("You must provide at least one weapon ID.", source, 255, 0, 0) end

    local weapons = {}
    for _, weaponID in ipairs(weaponIDs) do
        local id = tonumber(weaponID)
        if not id then return outputChatBox("Invalid weapon ID: " .. tostring(weaponID), source, 255, 0, 0) end
        table.insert(weapons, {id = id, ammo = 100})
    end

    if marker then destroyElement(marker) end

    local x, y, z = getElementPosition(source)
    marker = createMarker(x, y, z + 1, "cylinder", 1.5, 0, 255, 0, 127)

    addEventHandler("onMarkerHit", marker, function(hitElement, matchingDimension)
        if getElementType(hitElement) == "player" and matchingDimension then
            for _, weapon in ipairs(weapons) do giveWeapon(hitElement, weapon.id, weapon.ammo, true) end
        end
    end)

    outputChatBox("Weapon marker created!", source, 0, 255, 0)
end
addCommandHandler("cw", markerc)

use /cw (weapon ID) for example /cw 31 to create a marker that gives 100 bullets of m4 you also can use multiple weapons /cw 31 35 and it will create a marker that gives m4 and rocket launcher

  • Like 1
Link to comment
3 hours ago, kukimuki said:

how to make a marker to give player weapon?

function onMarkerHit(hitElement, matchingDimension)
  -- Check if the element that hit the marker is a player and is in the same dimension as the marker
  if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then
    -- Give the player a weapon
    giveWeapon(hitElement, 31, 500) -- give the player an HK 417 with 500 bullets
    
    -- Output a message to the player
    outputChatBox("You picked up an M4 with 500 bullets.", hitElement, 0, 255, 0)
  end
end

-- Create a marker at position (x, y, z) with a size of 2 units
local x, y, z = 123.45, 67.89, 10.11 -- change these values to your desired position
local marker = createMarker(x, y, z, "cylinder", 2, 0, 255, 0, 150)

-- Add the event handler to the marker
addEventHandler("onMarkerHit", marker, onMarkerHit)

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...