map_to_file ...Error?

Pazleysox

Member
I've been using this code for many months for my chatbot to help people in dreadsylvania with element, and monster banishing.

I only just found out today that if a user has a space in their name, the script aborts.

I did not write this, it was written for me.
Code:
		record note
			{
		        string sender;
		        int date;
			}
		[int] ChatLog;
    
    		int NE= count(ChatLog);
		ChatLog[NE].sender= sender;
		Map_to_File(ChatLog,"Chatlog.txt");
		{
			string [int] my_list;
			file_to_map( "chatlog.txt" , my_list);
			playerdata player;
			string temp = "";
			string user = "";
			foreach i,playername in my_list 
				{
					player = GetPlayer( playername );
					if( player.name != "" ) 
					{
						if( temp != "" ) temp += ", ";
						temp += player.clanname;
						user += player.name;
					}
				}
			cli_execute("/whitelist " + temp);
			if (temp != get_clan_name())
			{print("Error!!");	
			chat_private(user, "I couldn't join your clan " + temp +", perhaps I don't have a whitelist?");
			return;}

Here's the error I'm getting:
Code:
Incoming PM from Paz Sox saying: testhot
[COLOR="#FF0000"]Player "Paz Sox" not found![/COLOR]
Sorry, you don't seem to be cool enough to have a whitelist for a clan like ''.

Error!!
Unknown recipient "I". Message (couldn't join your clan , perhaps I don't have a whitelist?) not sent.

I'm not sure how to fix this... Is there anyone who sees the problem?
 

Darzil

Developer
I would guess the issue is in this function : GetPlayer( playername ) which you do not show (As the code generating that error message isn't shown).
 

heeheehee

Developer
Staff member
It may also make sense to key your map by player ID, since that can't change, whereas a playername can undergo capitalization changes, or be "modified" by certain effects / equipment.
 

Pazleysox

Member
It may also make sense to key your map by player ID, since that can't change, whereas a playername can undergo capitalization changes, or be "modified" by certain effects / equipment.

Thanks, I'll try that first. That will be easier than recoding the whole thing.
 
Top