Sign in to follow this  

setElementData with variable in 2nd argument?

Recommended Posts

Is it possible to setElementData(vehicle,A variable,0) ?

And then to get it again later.

getElementData(vehicle, A variable)?

What I'm trying to do is to set a variable for vehicle with a player name as the 2nd argument and therefore I need to use variables?

Share this post

Link to post

if your variable contains a string — why not.

Share this post

Link to post

Well I've been trying but it doesn't seem to work the way I've been doing, the way I do is

When a player joins it does:

    for k1,v in ipairs(vehicle) do 
        local Name = getElementData(source,"CharacterName") 

Got no problems here at all, used tostring to make sure that it turns out to be a string.

Then in another lua file I do following, this is where the problem appears

    for k,v in ipairs(players) do 
        for k1,v1 in ipairs(vehicle) do 
                local Name = getElementData(v,"CharacterName") 
                if getElementData(v1,tostring(Name)) == 0 then 

But here it says that theres a bad argument at the getElementData, which I don't get since it works with the variable at start but in the getElement I get a error/warning

Share this post

Link to post

that is some really weird system, what are your trying to achieve with it anyway?

can't see what actually wrong. except the idea itself, why set all vehicles' element data to player name on join.

what if another player joins? is "CharacterName" is even set? how do you know first part is working?

and what line throws the error exactly?

ps: since "CharacterName" doesnt change in ipairs(vehicle) loop, you better move it outside of the loop.

Share this post

Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.