headache
#1
Code:
local iniFile = cIniFile("myfile.ini")
                if(iniFile:ReadFile()) then
                        local data = tonumber(iniFile:GetValue(Player:GetName(), "data"))
                        if(not data==true) then
                                Server:SendMessage("cant retrieve data", Player)
                        else
                                Server:SendMessage("data: "..iniFile:GetValue(Player:GetName(), "data"), Player)
                        end
                end
If it finds the key with the players name and value of data, it should output the data, otherwise output "cant retrieve data" right? or am i wrong? :S but either way its not working, it outputs fine if it finds the data, otherwise it doesnt do anything

heeeeeeelllppppp HuhHuh
Reply
Thanks given by:
#2
Is Player's name suppose to be a number? Also you don't want to check for data == true. That simply doesn't work. You want to make sure it isn't null or nil by:

Code:
if (not data) then
for easier readability:
Code:
if (data) then
               Server:SendMessage("data: "..iniFile:GetValue(Player:GetName(),"data"), Player)
            else
                Server:SendMessage("Can't retrieve data",Player)
            end

In reality checking for true is like making something check if it is equal to one.
Reply
Thanks given by:
#3
(03-05-2011, 06:54 AM)Revolucas Wrote: Is Player's name suppose to be a number?
that was when i was trying something else, needed to convert the data to a number, i guess i forgot to take it outTongue


thanks for the help, i tried everything you said and every combination of 'not' '==' etc and it just doesnt want to work :/

but im sure i checked the existence of data using GetValue() before...
Reply
Thanks given by:
#4
You should not check data == true, data is never true, data is a number. However, tonumber can return nil if the given argument is not a number. So what you should do is check for nil instead of true.
Reply
Thanks given by:
#5
Problem solved, cheers for the help guys!
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)