Jump to content

[Help] item funcion


Unique

Recommended Posts

Hi! I want to make a this resource to work with item, if i have this item, then this /cmd will works, if i dont have this item, then resource will not works, can someone can say in wich row i need put a this one " if exports.global:hasItem(localPlayer, 88) then " ?

 

--- THE CODE, SERVER SIDE only

 if not gpsBlips[playerID] then
        local vehicle = exports.pool:getElement("vehicle", vehID)
        if vehicle then
            local vehicleOwner = getElementData(vehicle, "owner")
            if vehicleOwner == playerID then
                local vehposX, vehposY, vehposZ = getElementPosition(vehicle)
                gpsBlips[playerID] = createBlip(vehposX, vehposY, vehposZ, 19, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer)
                gpsMarkers[playerID] = createMarker(vehposX, vehposY, vehposZ, "checkpoint", 3, 255, 0, 0, 255, thePlayer)
                attachElements(gpsMarkers[playerID], vehicle)
                attachElements(gpsBlips[playerID], vehicle)
                if gpsBlips[playerID] then
                    outputChatBox("Jūs varat sākt izsekot savu transportlīdzekli, kartē atzīmēts ar sarkanu karodziņu.", thePlayer, 0, 255, 0, true)
                end
            else
                outputChatBox("Transportlīdzeklis nepieder Jums!", thePlayer, 255, 0, 0, true)
            end
        end
    else
        outputChatBox("Jūs pašlaik jau izmantojat GPS. Lai ieslēgtu to atkārtoti, sākumā izslēdziet to /closevehgps", thePlayer, 255, 0, 0, true)
    end
end
addCommandHandler("trackingveh", gpsFunc)

--- END

Edited by Danex
Link to comment

Well, if i understood you properly, you want to allow this function to work, only if you have this item with ID 88?

If soo then just add it in first IF statement.

if not gpsBlips[playerID] and exports.global:hasItem(localPlayer, 88) then

Also, you need to change localPlayer to player element.

Edited by gubi
Link to comment
6 hours ago, gubi said:

Well, if i understood you properly, you want to allow this function to work, only if you have this item with ID 88?

If soo then just add it in first IF statement.


if not gpsBlips[playerID] and exports.global:hasItem(localPlayer, 88) then

Also, you need to change localPlayer to player element.

mby better here?

 if gpsBlips[playerID] then

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