Jump to content

giveWeapon problem.


w3rt1x

Recommended Posts

local x, y, z = 215.54638671875,2068.0607910156,20
local marker = createMarker(x, y, z, "cylinder", 1.3, 255, 0, 0)

addEventHandler("onClientMarkerHit", marker,
function(hitPlayer, matchingDimension)
    if hitPlayer == getLocalPlayer() then
        giveWeapon(hitPlayer, 23, 250)
    end
end)


attempt to call global 'giveWeapon' (a nil value)

hello everyone, how to fix it?

Link to comment
  • 4 months later...
On 25/07/2022 at 20:43, w3rt1x said:
local x, y, z = 215.54638671875,2068.0607910156,20
local marker = createMarker(x, y, z, "cylinder", 1.3, 255, 0, 0)

addEventHandler("onClientMarkerHit", marker,
function(hitPlayer, matchingDimension)
    if hitPlayer == getLocalPlayer() then
        giveWeapon(hitPlayer, 23, 250)
    end
end)


attempt to call global 'giveWeapon' (a nil value)

hello everyone, how to fix it?

hello, I have prepared a code related to your problem, if your problem persists, you can try this code

--client

local x, y, z = 215.54638671875,2068.0607910156,20
local marker = createMarker(x, y, z, "cylinder", 1.3, 255, 0, 0)

addEventHandler("onClientMarkerHit", marker,
function(hitPlayer, matchingDimension)
    if hitPlayer == getLocalPlayer() then
       triggerServerEvent("giveWeaponToPlayer", hitPlayer, 23, 250) -- weapon id is 23 and ammo is 250 
    end
end)

--server

addEvent("giveWeaponToPlayer", true)
addEventHandler("giveWeaponToPlayer", root,
    function(weaponID, weaponAmmo)
       giveWeapon(client, weaponID, weaponAmmo)
    end
)

 

  • 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...