tommymaster Posted January 16, 2018 Share Posted January 16, 2018 Hi! I want to list a client-sided table when a player disconnects. --client items = {} items[1] = "1" items[2] = "2" function saveItems() triggerServerEvent ("listItems", source, items) end addEventHandler ("onClientPlayerQuit", root, saveItems) --server function listItems(items) outputServerLog (""..items..":"..getPlayerName(source).."") iprint (""..items..":"..getPlayerName(source).."") outputDebugString (""..items..":"..getPlayerName(source).."") end addEvent ("listItems", true) addEventHandler ("listItems", root, listItems) I can't see the message at all in the server console. Link to comment
Awang Posted January 17, 2018 Share Posted January 17, 2018 Because this event can't use detect if the player quit and this player is himself... This event can use to detect other clients quite in client side... With onClientResourceStop () you can do it, if you want to push the local data to serverside, in this case: --- Client side items = {1,2} function saveItems() triggerServerEvent ("listItems", localPlayer, items) end addEventHandler ("onClientResourceStop", resourceRoot, saveItems) Serverside should be good, but I have doubt about get the player name... Anyway, you can read all of these usefull advice in wiki, It's good to use it... You can read also great examples and I'ts always uptodate. 1 Link to comment
tommymaster Posted January 17, 2018 Author Share Posted January 17, 2018 16 hours ago, Awang said: Because this event can't use detect if the player quit and this player is himself... This event can use to detect other clients quite in client side... With onClientResourceStop () you can do it, if you want to push the local data to serverside, in this case: --- Client side items = {1,2} function saveItems() triggerServerEvent ("listItems", localPlayer, items) end addEventHandler ("onClientResourceStop", resourceRoot, saveItems) Serverside should be good, but I have doubt about get the player name... Anyway, you can read all of these usefull advice in wiki, It's good to use it... You can read also great examples and I'ts always uptodate. Thanks. It seems to work this way. I want to see the items of the table, but it outputs like "table: 0x......." in the log instead the items of the table. How may i fix this? Link to comment
raynner Posted January 17, 2018 Share Posted January 17, 2018 5 hours ago, tommymaster said: Thanks. It seems to work this way. I want to see the items of the table, but it outputs like "table: 0x......." in the log instead the items of the table. How may i fix this? use for i, v in iparis(Itens) do outputChatBox( tostring(v), source) end 1 Link to comment
tommymaster Posted January 18, 2018 Author Share Posted January 18, 2018 thanks, i solved it by not using a client-sided table, but setting the table as elementdata. it's easier for me. 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