INI Files
#1
Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue
Reply
Thanks given by:
#2
(02-27-2011, 09:16 AM)Tim Wrote: Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue

Look at Area Plugin.
Reply
Thanks given by:
#3
I created a page for INI files over here http://mc-server.org/wiki/doku.php?id=api:cinifile
see if you find it useful
Reply
Thanks given by:
#4
(02-27-2011, 05:41 PM)Tybor Wrote:
(02-27-2011, 09:16 AM)Tim Wrote: Hey guys,

If anyone gets a chance do you think you could explain basic usage of reading/writing to ini files, at the moment im just giving myself a headache trying to figure it outTongue

Look at Area Plugin.
yeah, had a look at that - it was useful for some stuff then i started getting confused, might just have been due to it getting kinda late to be fair :p

(02-27-2011, 11:22 PM)FakeTruth Wrote: I created a page for INI files over here http://mc-server.org/wiki/doku.php?id=api:cinifile
see if you find it useful

thats very useful, didnt notice that page before!


Thanks guys Smile
Reply
Thanks given by:
#5
You didn't notice that page because it wasn't there before, haha. I just created it
Reply
Thanks given by:
#6
I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.
Reply
Thanks given by:
#7
(02-28-2011, 06:46 AM)codename_B Wrote: I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.

Look how it is handled in Area Plugin as I make extensive usage of INI file.
Reply
Thanks given by:
#8
(02-28-2011, 03:13 AM)FakeTruth Wrote: You didn't notice that page because it wasn't there before, haha. I just created it
Ahh thanks haha
(02-28-2011, 06:46 AM)codename_B Wrote: I'm having issues getting it to write to the files, have you got any advice for me? It reads perfectly but I can't change settings, I'm trying to make a plugin for scores/money.

dont forget to use WriteFile() , i kept forgetting that one and couldnt understand why it wasnt workingTongue


How can i check if a key exists, like
Code:
if(specified-key-exists) then
--do something
else
--do something else
end
Reply
Thanks given by:
#9
I realised that and got it workingTongue Thanks!
Reply
Thanks given by:
#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:




Users browsing this thread: 10 Guest(s)