.:HyPeX:. Posted April 2, 2014 Share Posted April 2, 2014 Hey guys, reading over saw that you can set a table value to the settings, will admin panel be able to read and edit is as a table? also, should this work like this? Dashboard = { rankings = { labels = { "Kills", "Deaths", "Headshots", "PlayTime", "EXP", "Level", "Rank", }, } function onResourseStart() set("Labels", Dashboard.rankings.labels) setTimer(CheckLabels, 1000,0) end onResourseStart() function CheckLabels() LabelTable = {unpack(get("Labels"))} Dashboard.rankings.labels = {} for i=1, #LabelTable do Dashboard.rankings.labels[i] = LabelTable[i] end for c,v in ipairs(getElementsByType("player")) do triggerClientEvent(c,"UpdateLocalLabels",resourceRoot, Dashboard.rankings.labels) end end Meta: <settings> <setting name="*Labels" value="{Kills, Deaths, Headshots, PlayTime, EXP, Level, Rank}" friendlyname="Dashboard Labels" group="" accept="" examples="cash, kills" desc="" /> </settings> Link to comment
JR10 Posted April 3, 2014 Share Posted April 3, 2014 Not sure I understand, are you asking if the admin panel can modify tables? That would be a no, it's not possible. Link to comment
.:HyPeX:. Posted April 3, 2014 Author Share Posted April 3, 2014 So i should make a custom way of editing them, but tables are like that itself? (If i wanna use them) Link to comment
Castillo Posted April 3, 2014 Share Posted April 3, 2014 "*Labels" value="[ [ Kills, Deaths, Headshots, PlayTime, EXP, Level, Rank ] ]" friendlyname="Dashboard Labels" group="" accept="" examples="cash, kills" desc="" /> Link to comment
.:HyPeX:. Posted April 3, 2014 Author Share Posted April 3, 2014 That isnt a string itself? Becouse if yes, i cannot unpack it normally.. function CheckLabels() LabelTable = {unpack(get("Labels"))} Dashboard.rankings.labels = {} for i=1, #LabelTable do Dashboard.rankings.labels[i] = LabelTable[i] end for c,v in ipairs(getElementsByType("player")) do triggerClientEvent(c,"UpdateLocalLabels",resourceRoot, Dashboard.rankings.labels) end end Link to comment
Castillo Posted April 3, 2014 Share Posted April 3, 2014 No, it should be a table, try using: outputChatBox ( type ( get ( "Labels" ) ) ) Link to comment
.:HyPeX:. Posted April 3, 2014 Author Share Posted April 3, 2014 Well, that gives error upon unpack, no table. This way it outputed Kills, as expected. function CheckLabels() LabelTable = {unpack(get("Labels"))} outputServerLog(LabelTable[1]) Dashboard.rankings.labels = {} for i=1, #LabelTable do Dashboard.rankings.labels[i] = LabelTable[i] end for c,v in ipairs(getElementsByType("player")) do triggerClientEvent(c,"UpdateLocalLabels",resourceRoot, Dashboard.rankings.labels) end end function onResourseStart() set("Labels", Dashboard.rankings.labels) setTimer(CheckLabels, 1000,0) end onResourseStart() Now, my problem is how to edit it, but i'll figure it out.. Link to comment
xXMADEXx Posted April 3, 2014 Share Posted April 3, 2014 Try this Dashboard = { rankings = { labels = { "Kills", "Deaths", "Headshots", "PlayTime", "EXP", "Level", "Rank", }, } } function onResourseStart() set("Labels", toJSON ( Dashboard.rankings.labels ) ) setTimer(CheckLabels, 1000,0) end onResourseStart() function CheckLabels() LabelTable = fromJSON ( get ( "Labels" ) ) outputChatBox ( "LabelTable Type -> "..type ( LabelTable ) ) outputChatBox ( "LabelTable Value -> "..tostring ( LabelTable ) ) Dashboard.rankings.labels = {} --for i=1, #LabelTable do -> You can't use the "#" operator, since the index's aren't numeric values for i, v in pairs ( LabelTable ) do Dashboard.rankings.labels[i] = v end for c,v in ipairs(getElementsByType("player")) do triggerClientEvent(c,"UpdateLocalLabels",resourceRoot, Dashboard.rankings.labels) end end and reply what it's outputting. 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