Snoozy Posted May 31, 2011 Share Posted May 31, 2011 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? Link to comment
Aibo Posted May 31, 2011 Share Posted May 31, 2011 if your variable contains a string — why not. Link to comment
Snoozy Posted May 31, 2011 Author Share Posted May 31, 2011 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: vehicle=getElementsByType("vehicle") for k1,v in ipairs(vehicle) do local Name = getElementData(source,"CharacterName") setElementData(v,tostring(Name),0) end 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 vehicle=getElementsByType("vehicle") players=getElementsByType("player") 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 outputChatBox("Test3",v) setElementData(v1,tostring(Name),1) end end end 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 Link to comment
Aibo Posted May 31, 2011 Share Posted May 31, 2011 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now