INI Files
#10
(02-28-2011, 09:02 PM)Tim Wrote: How can i check if a key exists, like
Code:
if(specified-key-exists) then
--do something
else
--do something else
end

Example from my Area Plugin:
PHP Code:
-- check if Owners already available
  
if(AreaPlugin.IniFile:FindValue(AreaID"Owners") < 0then
    
-- create new value
    AreaPlugin
.IniFile:SetValue(AreaPlugin:GetAreaKey(AreaID), "Owners"'"' .. PlayerName .. '",'true)
  else
    -- 
check if already Owner
    
if(AreaPlugin:IsOwner(AreaIDPlayerName)) then
      
return truePlayerName .. " already owner of Area " .. AreaID
    
else
      -- 
add new Owner
      local Owners 
AreaPlugin.IniFile:GetValue(AreaPlugin:GetAreaKey(AreaID), "Owners")
      
Owners Owners .. '"' .. PlayerName .. '",'
      
AreaPlugin.IniFile:SetValue(AreaPlugin:GetAreaKey(AreaID), "Owners"Ownersfalse)
    
end
  end 
Reply
Thanks given by:


Messages In This Thread
INI Files - by Tim - 02-27-2011, 09:16 AM
RE: INI Files - by Tybor - 02-27-2011, 05:41 PM
RE: INI Files - by FakeTruth - 02-27-2011, 11:22 PM
RE: INI Files - by Tim - 02-28-2011, 01:18 AM
RE: INI Files - by FakeTruth - 02-28-2011, 03:13 AM
RE: INI Files - by codename_B - 02-28-2011, 06:46 AM
RE: INI Files - by Tybor - 02-28-2011, 06:50 AM
RE: INI Files - by Tim - 02-28-2011, 09:02 PM
RE: INI Files - by Tybor - 03-01-2011, 02:49 AM
RE: INI Files - by codename_B - 02-28-2011, 10:06 PM
RE: INI Files - by Tim - 03-07-2011, 12:04 AM
RE: INI Files - by Tybor - 03-07-2011, 03:37 AM
RE: INI Files - by FakeTruth - 03-07-2011, 02:03 AM
RE: INI Files - by Tim - 03-07-2011, 04:35 AM
RE: INI Files - by Tim - 03-07-2011, 06:48 AM



Users browsing this thread: 1 Guest(s)