Welcome to Open Carnage

A resource for Halo Custom Edition and MCC modding, with unique means of rewarding content creation and support. Have a wander to see why we're worth the time!

EST. 14th of February, 2012

CartmansPieHole

Renaming Players Based on Holiday

Posted (edited)

5/7/2020 EDIT:  Found a script to rename players.  I've heavily modified it to do what I want it to do but I'm still working on it.  This post has been updated.

 

My original post was looking for a script to rename players based on Holiday.

 

I found a script in these forums called OnNameRequest.  The script by itself does nothing, but editing the OnNameRequest function will return a value, thus rename a player.

 

What I've done so far:

  • Created a sub-directory called "Holiday", stored various text files in it, each with related Holiday names.
  • I've so far edited the script to be able to return the current system date.  If this date falls on a holiday (Easter Sunday & Thanksgiving must be hardcoded), the corresponding Holiday file will open, load into a table and the player's name will be randomly selected from this table.
  • The selected name is written to the file players.txt  The text file's output will look like this (no quotations around the names):
Jolly
Tree
Stocking

 

Below is my current code.  I've just added the "Get Current Players List" section.  Mind you, I used the same line variable, not sure if that'll work or not.

 

What I want to accomplish is:  As I'm adding items to the holidayNames table, I want to know if the item already exists in the currentPlayers table, first.  If it exists, skip that item.

 

	-- Get Current Players List
	local currPlayers = io.open(filePath "players.txt", "r");
	local currentPlayers = {}
	
	for line in currPlayers:lines() do
		table.insert (currentPlayers, line);
	end	
	
	-- Get Names from selected Holiday file
	local holFile = io.open(filePath .. holiday .. ".txt", "r");
	local holidayNames = {}
	
	for line in holFile:lines() do
		table.insert (holidayNames, line);
	end

 

Edited by CartmansPieHole

Share this post


Link to post
Share on other sites

Tiddy-bits:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.