• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua What's the problem on this fishing script ?

nagymarci4

New Member
Joined
Jan 14, 2018
Messages
2
Reaction score
0
Lua:
local fishIds =
    {40, 5000},
    {41, 5000},
    {42, 5000},
    {43, 5000},
    {44, 5000}

local myMarker = createMarker(433.85614013672, -1747.8924560547, 9.2119235992432-1, 'cylinder', 2.0, 255, 0, 0, 150)

function MarkerHit( hitElement, matchingDimension )
    local elementType = getElementType( hitElement )
    for key, value in ipairs(fishIds) do
        exports["item-system"]:deleteItem(player, player,value[1])
        setElementData(player, "char:money",getElementData(player,"char:money")+value[2])
        outputChatBox("You sold the fish",player)
    end
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )


And the error:
attempt to index local 'value' ( a number value)

This line:
for key, value in ipairs(fishIds) do
 
Lua:
local fishIds =
    {40, 5000},
    {41, 5000},
    {42, 5000},
    {43, 5000},
    {44, 5000}

local myMarker = createMarker(433.85614013672, -1747.8924560547, 9.2119235992432-1, 'cylinder', 2.0, 255, 0, 0, 150)

function MarkerHit( hitElement, matchingDimension )
    local elementType = getElementType( hitElement )
    for key, value in ipairs(fishIds) do
        exports["item-system"]:deleteItem(player, player,value[1])
        setElementData(player, "char:money",getElementData(player,"char:money")+value[2])
        outputChatBox("You sold the fish",player)
    end
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )


And the error:
attempt to index local 'value' ( a number value)

This line:
for key, value in ipairs(fishIds) do

Your table is incomplete.

change
Lua:
local fishIds =
    {40, 5000},
    {41, 5000},
    {42, 5000},
    {43, 5000},
    {44, 5000}
to
Lua:
local fishIds = {
    {40, 5000},
    {41, 5000},
    {42, 5000},
    {43, 5000},
    {44, 5000}
}
 
Back
Top