Jump to content

Getelementdata


Fuentes

Recommended Posts

Posted
function safeLoadCallback(qh) 
    local result, num = dbPoll(qh, 0) 
  
    for k, row in ipairs(result) do 
  
  
        local safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) 
         
        setElementData(safe, "dbId", row["id"]) 
        setElementData(safe, "x", row["x"]) 
        setElementData(safe, "y", row["y"]) 
        setElementData(safe, "z", row["z"]) 
        setElementData(safe, "interior", row["interior"]) 
        setElementData(safe, "rot", row["rotation"]) 
        setElementData(safe, "group", row["group"]) 
        setElementData(safe, "money", row["money"]) 
        setElementData(safe, "kokain", row["kokain"]) 
        setElementData(safe, "heroin", row["heroin"]) 
        setElementData(safe, "matreial", row["material"]) 
         
        
        end 
end 
  
  
  
  
function test(player) 
  
local money = getElementData(safe, "money") 
  
  
outputChatBox("money: "..money,player, 255, 0, 0) 
  
  
                             
end 
addCommandHandler("test", test, false, false) 

Bad argument @ 'getElementData' [Expected element at argument 1, got nil

Posted

I believe the error you are getting is because the

local money = getElementData(safe, "money") 

is in a seperate function than the object safe try this

function safeLoadCallback(qh) 
    local result, num = dbPoll(qh, 0) 
  
    for k, row in ipairs(result) do 
  
  
        local safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) 
        
        setElementData(safe, "dbId", row["id"]) 
        setElementData(safe, "x", row["x"]) 
        setElementData(safe, "y", row["y"]) 
        setElementData(safe, "z", row["z"]) 
        setElementData(safe, "interior", row["interior"]) 
        setElementData(safe, "rot", row["rotation"]) 
        setElementData(safe, "group", row["group"]) 
        setElementData(safe, "money", row["money"]) 
        setElementData(safe, "kokain", row["kokain"]) 
        setElementData(safe, "heroin", row["heroin"]) 
        setElementData(safe, "matreial", row["material"]) 
function test(player) 
  
local money = getElementData(safe, "money") 
  
  
outputChatBox("money: "..money,player, 255, 0, 0) 
  
  
                            
end 
        
        end 
end 
  
addCommandHandler("test", test, false, false) 

Tho I'm not sure about this I only had a quick look.

Posted
function safeLoadCallback(qh) 
    local result, num = dbPoll(qh, 0) 
    for k, row in ipairs(result) do 
        safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) 
        setElementData(safe, "dbId", row["id"]) 
        setElementData(safe, "x", row["x"]) 
        setElementData(safe, "y", row["y"]) 
        setElementData(safe, "z", row["z"]) 
        setElementData(safe, "interior", row["interior"]) 
        setElementData(safe, "rot", row["rotation"]) 
        setElementData(safe, "group", row["group"]) 
        setElementData(safe, "money", row["money"]) 
        setElementData(safe, "kokain", row["kokain"]) 
        setElementData(safe, "heroin", row["heroin"]) 
        setElementData(safe, "matreial", row["material"]) 
    end 
end 
  
  
function test(player) 
    local money = getElementData(safe, "money") 
    if money then  
        outputChatBox("money: "..money,player, 255, 0, 0)     
    end  
end 
addCommandHandler("test", test) 

Posted

next getelementdata problem:

local groupsafe = tonumber(getElementData(safe, "group"))

and mysql datatable 2 safe id

1 safeid:faction1

2 safeid:faction2

script now i faction 1

chatbox test faction 1 safe money please help thank you

function safecheck() 
  
    local teamID = tonumber(getElementData(source, "group")) 
        local groupsafe = tonumber(getElementData(safe, "group")) 
    if teamID >0 then 
      
     
       if  groupsafe == teamID then  
       
    outputChatBox ("test ") 
    else 
     outputChatBox ("Not are factionsafe") 
    end 
    else 
    outputChatBox ("Not are faction") 
    end 
     
end 
addEvent("safecheck", true ) 
addEventHandler("safecheck", getRootElement(),safecheck) 

Posted

You're attempting to getElementData of a nil value (that is, a variable that is set to nil, or even more simply, the variable is set to nothing or not set at all)

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