does exist a reverse function for this .? : [url]https://wiki.garrysmod.com/page/table/KeyFromValue[/url]
[url]https://wiki.garrysmod.com/page/Category:table[/url] <-- no, or i don't know read
[CODE]
local WeaponPrices = table.CollapseKeyValue(
{
--{ Key = "", Value = }, template :)
{ Key = "weapon_9mm", Value = 200 },
{ Key = "weapon_shotgun", Value = 1000 },
{ Key = "weapon_smg", Value = 1000 },
{ Key = "weapon_frag", Value = 300 },
})
PrintTable ( WeaponPrices ) --works fine ;)
function SearchPrice(WeaponName)
return WeaponPrices.GetValueFromKey(WeaponName) -- <= obiviously this does not exist
end
local ItemCoast = SearchPrice("weapon_pistol")
print(" 9mm coast " .. ItemCoast)
[/CODE]
i have also test a for k,v pairs() bla bla bla but i dont understand this ...
thanks for incomming responses :v:
Can't you do
[CODE]
WeaponPrices[ WeaponName ] -- returns the value associated with that key
[/CODE]
[editline]23rd June 2016[/editline]
That's one of the most basic table things you can do in Lua by the way
oh ... i see ... thanks much !
[QUOTE=MPan1;50579525]That's one of the most basic table things you can do in Lua by the way[/QUOTE]
ehm ... i'm a noob with the Lua, this is only two days i have started Lua Scripting :)
Sorry, you need to Log In to post a reply to this thread.