Unknown command: AddRule
Unknown command: RemoveRule
Errors above.
Rules = file.Read( "Umotd/rulest.txt" )
RulesT = util.KeyValuesToTable( Rules )
for k,v in pairs( RulesT.rules ) do
RulesT.rules[tonumber(k)]=v
end
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
function AddRule( ply, command, RuleA )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if string.find( table.concat(RulesT.rules), "<li>" ..Rule, 1, true ) then
Msg("Rule already exists \n")
else
table.insert( RulesT.rules, "<li>" ..Rule )
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
file.Write( "Umotd/rulest.txt", util.TableToKeyValues(RulesT.rules))
end
else
end
else
Msg("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
function RemoveRule( ply, command, RuleB )
if ply:IsValid() then
if ply:IsAdmin() then
RuleN = table.concat(RuleB)
if tonumber(RuleN) < table.Count(RulesT.rules)+1 && tonumber(RuleN) > 1 then
table.remove( RulesT.rules, RuleN )
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
file.Write( "Umotd/rulest.txt", util.TableToKeyValues(RulesT.rules))
else
Msg("Couldn't find the rule mentioned \n")
end
else
end
else
Msg("Can't run from console \n")
end
end
concommand.Add( "RemoveRule", RemoveRule )
rulest.txt below
"Out"
{
"1" "<ol>"
"2" "<li>Test2"
"3" "<li>Test5"
"4" "<li>Test6"
}
BTW I'm trying to make it handle the table like Uteam does with the Uteam.txt file in the data folder, so my rulest.txt should look like this below, but the rulest.txt was written by the script.
"Out"
{
"rules"
{
"1" "<ol>"
"2" "<li>Test2"
"3" "<li>Test5"
"4" "<li>Test6"
}
}