Jump to content

ipairs table (table expecte, got nil) even if there is one


..:D&G:..

Recommended Posts

Posted

Post your script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Here

local vehElements = {} 
  
-- Functii 
function showVehicleGui(vehElementsret) 
    if not wvehicle then 
        local width, height = 400, 200 
        local scrWidth, scrHeight = guiGetScreenSize() 
        local x = scrWidth - width 
        local y = scrHeight/10 
        wvehicle = guiCreateWindow(x, y, width, height, "Tractari: Recupereaza un vehicul", false) 
        guiWindowSetSizable(wvehicle, false) 
        bInchide = guiCreateButton(0.5, 0.85, 0.2, 0.1, "Iesi", true, wvehicle) 
        bVehicul = guiCreateButton(0.725, 0.85, 0.3, 0.2, "Recupereaza", true, wvehicle) 
        addEventHandler("onClientGUIClick", bClose, hideImpoundUI, false) 
        addEventHandler("onClientGUIClick", bRelease, releaseCar, false) 
        gMasini = guiCreateGridList(0.05, 0.1, 0.9, 0.65, true, wvehicle) 
        addEventHandler("onClientGUIClick", gMasini, updateCar, false) 
        local col = guiGridListAddColumn(gMasini, "Vehicule Confiscate", 0.7) 
        IDcolumn = guiGridListAddColumn(gMasini, "ID", 0.2) 
        vehElements = vehElementsret 
        for key, value in ipairs(vehElements) do 
            local dbid = getElementData(value, "dbid") 
            local row = guiGridListAddRow(gCars) 
            guiGridListSetItemText(gCars, row, col, getVehicleName(value), false, false) 
            guiGridListSetItemText(gCars, row, IDcolumn, tostring(dbid), false, false) 
        end 
        guiGridListSetSelectedItem(gCars, 0, 1) 
        lCost = guiCreateLabel(0.1, 0.85, 0.2, 0.1, "Taxă: 100 lei", true, wvehicle) 
        guiSetFont(lPret, "default-bold-small") 
        updateCar() 
        guiSetInputEnabled(true) 
    end 
end 

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

  • 4 months later...
Posted

Client side:

function scoateMasina(button)
if (button=="left") then
	local row = guiGridListGetSelectedItem(gCars)
	hideImpoundUI()
	triggerServerEvent("scoateMasina", getLocalPlayer(), vehElements[row+1])
end
end
addEvent("arataScosul", true)
addEventHandler("arataScosul", getRootElement(), showVehicleGui)

Server side:

function platesteScos(vehID)
   if  exports.bani:iaBani(source, 225) then
       exports.bani:daBani(getTeamFromName("Tractari Auto"), 225)
       setElementFrozen(vehID, false)
       local x, y, z, int, dim, rotation = getReleasePosition()
       setElementPosition(vehID, x, y, z)
       setVehicleRotation(vehID, 0, 0, rotation)
       setElementInterior(vehID, int)
       setElementDimension(vehID, dim)
       setVehicleLocked(vehID, true)
       exports['exports-stuffs']:setProtectedElementData(vehID, "motormort", 0, false)
       setVehicleDamageProof(vehID, false)
       setVehicleEngineState(vehID, false)
       exports['exports-stuffs']:setProtectedElementData(vehID, "frana", 0, false)
       exports['exports-stuffs']:setProtectedElementData(vehID, "scos", 0)

       outputChatBox("Test test release", source, 255, 194, 14)
   else
       outputChatBox("Insufficient funds.", source, 255, 0, 0)
   end
end
addEvent("scoateMasina", true)
addEventHandler("scoateMasina", getRootElement(), platesteScos)

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

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