Moocow Posted December 24, 2009 Share Posted December 24, 2009 I'm new to MTA Scripting, and I've been trying to use setElementData() to assign information to each player, such as their kills, deaths, other basic information. I want to save these stats to my database on disconnect, so in my query I'm calling getElementData(source, "stats.kills"), getElementData(source, "stats.deaths"), and getElementData(source, "stats.id") All these work fine, they don't return false and they return their respective values. Then in the line below, I have getElementData(source, "stats.id") in a second query, but this time it returns false. I could probably just declare a variable and only call getElementData() once, but then I'd never work out why it doesn't like being called twice. Another problem I was having was I'd assign all the element data stats default values on connect, and then try to reassign them on login, but setElementData() would just return false. Now I don't assign them default variables on connect, I only assign them on login and it's fine. It's like the functions don't like being called more than once or something, like the stats.id problem I'm having. Am I using these functions incorrectly? Should I reset the element data on disconnect or something? Any help would be appreciated. Link to comment
eAi Posted December 25, 2009 Share Posted December 25, 2009 Post your code, it's hard to tell from what you're saying. You can use account data - see setAccountData - for this kind of thing too. Link to comment
Moocow Posted December 27, 2009 Author Share Posted December 27, 2009 Post your code, it's hard to tell from what you're saying.You can use account data - see setAccountData - for this kind of thing too. In my disconnect code: local updatequery = mysql_query(link, "UPDATE mta SET kills=" .. getElementData(source, "stats.kills") .. " WHERE id=" .. getElementData(source, "stats.id")) local updatequery2 = mysql_query(link, "UPDATE accounts SET lastloggedinfrom='Multi Theft Auto' WHERE id=" .. getElementData(source, "stats.id")) 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