1. I need to check if my table canCall is empty.
    What I am trying to do is:
    Code:
    if #canCall > 0 then
    print("table canCall contains something")
    else
    print("table canCall is empty")
    end
    
    but it seems like it does not work like that. Because everytime I get table canCall is empty, even if it is not.
    [DOUBLEPOST=1431168137][/DOUBLEPOST]Or should I just do
    Code:
    if canCall == {} then
     
  2. The #tablevar is something you can only use if the table is using the default keys (1, 2, 3, ...) so as soon as you define your own keys tablevar['name'] = 'Mughisi', tablevar['userid'] = 99999, .... you won't be able to use the # in front of the table anymore, another thing you could do is just simply add a count function to your plugin that returns the amount of values in any given table, unregarding the type of the key, so you'd simply do something like
    Code:
    local tablevar = {}
    if self:Count(tablevar) == 0 then
      print("Empty table")
    else
      print("Table contains values!")
    end
    
    The count function could look like this:
    Code:
    function PLUGIN:Count( tbl ) 
      local count = 0
      for _ in pairs( tbl ) do 
        count = count + 1 
        end
      return count
    end
     
  3. would
    Code:
    if canCall == {} then
    work too?
     
  4. No that won't work, you could have tried that though instead of asking ;)
     
  5. sorry but im trying to use that to add that token system to my supply signal plugin. And Its quicker to ask here then going through all the steps to go to that point, ans also my chat dissapeared so i needed to restart my game ^^
    [DOUBLEPOST=1431169495][/DOUBLEPOST]@Mughisi Wow Idk what the hell I am doing wrong. I think I just built it up too complicated... I kinda lost the overview...
    I've build up that you can buy a token and you can check if you have a token. So but if you buy a token and throw a grenade, it works. But if you buy a token and then look if you got a token it says I got none, and If I throw a grenade then, it also doesnt work. It seems like my checking function anyhow resets the table or something like that... I can't find the issue, you propably find it in a second ^^ :c
    Could you do me the favor and take a quick look at it?
     
    Last edited by a moderator: May 9, 2015
  6. You don't have to test it in your plugin as part of the plugin, you just simply put some code in the init like
    Code:
    local tabletest = {}
    if tabletest == {} then
      print("Table is empty")
    end
    And you would've noticed it doesn't print ;)
     
  7. Could you take a quick look I the code I got?
     
  8. Sure, just post it here or send it in a discussion if you don't want everyone to see what you're doing atm :)