Jump to content

Settings > Table


Recommended Posts

Posted

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> 
  
  

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

So i should make a custom way of editing them, but tables are like that itself? (If i wanna use them)

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted
    "*Labels" value="[ [ Kills, Deaths, Headshots, PlayTime, EXP, Level, Rank ] ]" friendlyname="Dashboard Labels" group="" accept="" examples="cash, kills" desc="" /> 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

No, it should be a table, try using:

outputChatBox ( type ( get ( "Labels" ) ) ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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..

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...