03-01-2011, 02:49 AM
(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") < 0) then
-- create new value
AreaPlugin.IniFile:SetValue(AreaPlugin:GetAreaKey(AreaID), "Owners", '"' .. PlayerName .. '",', true)
else
-- check if already Owner
if(AreaPlugin:IsOwner(AreaID, PlayerName)) then
return true, PlayerName .. " 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", Owners, false)
end
end