BanNsS1 Posted August 22, 2012 Share Posted August 22, 2012 How can i getElementData onPlayerQuit? On player spawn the server updates the database and set "online" = 1 to the player who spawn. I would like that on player quit the server updates the database and set online to 0. To do it i've to get the character DATABASE ID which sets as a ElementData. When i try to getElementData(thePlayer, "databaseid") in the event onPlayerQuit it returns false. How can i do? Link to comment
Guest Guest4401 Posted August 22, 2012 Share Posted August 22, 2012 addEventHandler("onPlayerQuit",root, function() local id = getElementData(source,"databaseid") end ) Link to comment
BanNsS1 Posted August 22, 2012 Author Share Posted August 22, 2012 Lol... have you read my post? I tried it but the var "id" returns false! Link to comment
Castillo Posted August 22, 2012 Share Posted August 22, 2012 Which means "databaseid" is false. Link to comment
BanNsS1 Posted August 22, 2012 Author Share Posted August 22, 2012 (edited) Look, if i declare these functions (with the events): function onPlayerSpawn() setElementData(source, "databaseid", charSelected) -- charSelected is declared when you select the character you want to use from your character list. end function onPlayerQuit() outputChatBox(getElementData(source, "databaseid")) end When a player quits, the outputChatBox shows "false". EDIT: I tested it again and it works. Excuse me. Thanks so much! Edited August 22, 2012 by Guest Link to comment
AMARANT Posted August 22, 2012 Share Posted August 22, 2012 Check with this: outputChatBox(tostring(getElementData(source, "databaseid"))) Link to comment
BanNsS1 Posted August 22, 2012 Author Share Posted August 22, 2012 Check with this: outputChatBox(tostring(getElementData(source, "databaseid"))) EDIT: I tested it again and it works. Excuse me. Thanks so much! Anyway thanks you. Link to comment
Guest Guest4401 Posted August 23, 2012 Share Posted August 23, 2012 Lol... have you read my post? I tried it but the var "id" returns false! Yes I had read your post, where you were using thePlayer instead of source which is wrong. Link to comment
BanNsS1 Posted August 23, 2012 Author Share Posted August 23, 2012 No, it was an example. It wasn't my error. 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