Jump to content

Getting key of the specified value in a table


Recommended Posts

jobSheet = { 
    ['fisherman'] = "Fisherman",  
    ['medic'] = "Paramedic",  
    ['lumberjack'] = "Lumber Jack", 
    function thisshit() 
        jobitself = getKeyFromValueInTable(jobSheet, "Fisherman") 
    addEventHandler("onResourceStart", getRootElement(), thisshit) 
function getKeyFromValueInTable(a, b) 
    for k,v in ipairs(a) do 
        if v == b then 
           return k 
    return false 

So I used a function which is https://wiki.multitheftauto.com/wiki/Ge ... lueInTable , but I got a problem using this function, from code above it always returns false. Why is that so?

Link to comment

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