Jump to content

Variable question


Snoozy

Recommended Posts

Posted

for example don't do

  
var=tbl1[tbl2].tbl3 
  

but

  
local ltbl=tbl1[tbl2] 
var=ltbl.tbl3 
  

but that would help only, if error is in improper calling of arrays

Posted

well that didn't work but the problem is that the one table wont accept the other table inside to access some of the other information inside the first table :D

I don't really know why, but is there a work around?

Posted

first access the 1st table in one line, then propably try to tonumber/tostring, depends what the key is, and on 2nd line acess 2nd table.

Posted

Yea I realized that it was tonumber that was required tho now I've come across a similar problem on like a few lines later.

The whole thing I'm currently having trouble with in case you don't know yet is a enter and exit system, the enter system works now and you can enter.

However now theres a problem in exiting.

local int = BizInfo[getElementData(source,"BizEntered")].interior 
if getDistanceBetweenPoints3D(x,y,z,IntInfo[int].X,IntInfo[int].Y,IntInfo[int].Z) <= 3 then 

I've tried there with tonumber, tostring and toboolean but it wont work I just always get the:

[2011-05-27 08:53:29] ERROR: boulevard\business\server.lua:67: attempt to index field '?' (a nil value)

Posted

you could check public "interiors" resource for a bit of alternative ways of doing so.

and, maybe attach the x,y,z to marker as element data, so you don't need to use the table?

Posted

Okay now after some testing again and changing I came to a new error which is:

[2011-05-27 10:45:58] WARNING: boulevard\business\server.lua:72: Bad argument @ 'getDistanceBetweenPoints3D'

[2011-05-27 10:45:58] ERROR: boulevard\business\server.lua:72: attempt to compare boolean with number

  
local b = tonumber(getElementData(source,"BizEntered")) 
            local int = tonumber(BizInfo[b].Interior) 
            local x,y,z = getElementPosition(source) 
            local pX = getElementData(IntInfo[int].Pickup,"PosX") 
            local pY = getElementData(IntInfo[int].Pickup,"PosY") 
            local pZ = getElementData(IntInfo[int].Pickup,"PosZ") 
            if getDistanceBetweenPoints3D(x,y,z,pX,pY,pZ) <= 3 then 

That is the code used for line 72 which is the last shown the getDistanceBetween

Posted

pX, pY, and/or pZ is false

note that if its not nil it means syncing variables works, just one function in the other side returned false, not number(this mostly appears when trying to get some number out of function with invalid object pointer, or trying to get some ped's vehicle info while ped is on foot.)

  • MTA Team
Posted

Oh and remember if you have

 example = {}  

and you try

 example.chatbox.help = "Help!!"  

it won't work since you need

 example = { chatbox = {} }  

or

 example = {} 
example.chatbox = {}  

:3

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