Function Creating
#8
Is there a way to add the function to RegisterPluginInfoCommands();? Also, I tried making things local and when I call the function on load everything works however it still shows the motd with it.

local Rules = {}
function HandleRulesCommand( Split, Player )
	ShowRulesTo( Player )
	return true
end
function LoadRules()

	local Rules = io.open( "rules.txt", "r" )

	-- Check if the file 'rules.txt' exists, else create it.
	if not Rules then
		CreateRule = io.open( "rules.txt", "w" )
		CreateRule:write("@6It works!")
		CreateRule:close()
	else
		Rules:close()
	end
	
	for line in io.lines( "rules.txt" ) do
		local rools = line
		-- Do a for loop that goes to each char in the line.
		for I=1, string.len( rools ) do
			-- If the char is a '@' then check if the next char represents a color.
			if string.sub( rools, I, I ) == "@" then
				local Char = string.sub( rools, I + 1, I + 1 )
				local Color = ReturnColorFromChar( rools, Char )
				-- If the next char represented a color then put the color in the string.
				if Color ~= nil then
					rools = string.gsub( rools, "@" .. Char, Color )
				end
			end
		end
		-- Add the message to the list of messages.
		Messages[#Messages + 1] = rools
	end

end

function ShowRulesTo( Player )
	for I=1, #Messages do
		Player:SendMessage(Messages[I])
	end
end
Reply
Thanks given by:


Messages In This Thread
Function Creating - by RKyle - 10-03-2014, 09:37 PM
RE: Function Creating - by Seadragon91 - 10-03-2014, 09:43 PM
RE: Function Creating - by RKyle - 10-03-2014, 09:46 PM
RE: Function Creating - by xoft - 10-03-2014, 09:48 PM
RE: Function Creating - by xoft - 10-03-2014, 09:50 PM
RE: Function Creating - by RKyle - 10-03-2014, 10:02 PM
RE: Function Creating - by xoft - 10-03-2014, 10:46 PM
RE: Function Creating - by RKyle - 10-04-2014, 12:01 AM
RE: Function Creating - by xoft - 10-04-2014, 12:49 AM



Users browsing this thread: 5 Guest(s)