Posts: 118
Threads: 12
Joined: Feb 2011
Thanks: 0
Given 2 thank(s) in 2 post(s)
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 out
Posts: 42
Threads: 4
Joined: Feb 2011
Thanks: 0
Given 0 thank(s) in 0 post(s)
(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 out
Look at Area Plugin.
Posts: 1,450
Threads: 53
Joined: Feb 2011
Thanks: 15
Given 120 thank(s) in 91 post(s)
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
Posts: 118
Threads: 12
Joined: Feb 2011
Thanks: 0
Given 2 thank(s) in 2 post(s)
02-28-2011, 01:18 AM
(This post was last modified: 02-28-2011, 01:19 AM by Tim.)
(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 out
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
Posts: 1,450
Threads: 53
Joined: Feb 2011
Thanks: 15
Given 120 thank(s) in 91 post(s)
You didn't notice that page because it wasn't there before, haha. I just created it
Posts: 39
Threads: 12
Joined: Feb 2011
Thanks: 0
Given 1 thank(s) in 1 post(s)
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.
Posts: 42
Threads: 4
Joined: Feb 2011
Thanks: 0
Given 0 thank(s) in 0 post(s)
(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.
Posts: 118
Threads: 12
Joined: Feb 2011
Thanks: 0
Given 2 thank(s) in 2 post(s)
(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 working
How can i check if a key exists, like
Code: if(specified-key-exists) then
--do something
else
--do something else
end
Posts: 39
Threads: 12
Joined: Feb 2011
Thanks: 0
Given 1 thank(s) in 1 post(s)
I realised that and got it working Thanks!
Posts: 42
Threads: 4
Joined: Feb 2011
Thanks: 0
Given 0 thank(s) in 0 post(s)
(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
|