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.