| Author | Message | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Wed Sep 19, 2007 5:39 am     Post subject: Lag Plugin |  |   |  |  
				| 
 |  
				| Hello, 
 Well I was testing the Lag check plugin (made by Explody?) and wondered if there was a way to change how the string was handled after the player made the request. For example, lets say I was using the name "Deathwish" and I typed in !lagcheck Death it won't find the player "Deathwish". For the command to work a player has to type in the full name. I wanted to change this so that just by typing !lagcheck Death it would search the players in the current arena and match it to "Deathwish".  Also, if there was a player named "DeathAxe" that's the player would get lag checked (alphabetical order). Basically the bot would have to check each string and compare them. I was just wondering if there was a function already created within merv to handle this. So far every plugin I've seen that allows a player to check another players' status, requires the requesting player to type in the whole name instead of just a part of it. I've rambled on for awhile, it's 4am and I'm tired. Any help would be appreciated. Please excuse any grammatical errors.
 
 
 Thanks
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Maverick 
 
  
 Age:41
 Gender:
  Joined: Feb 26 2005
 Posts: 1521
 Location: The Netherlands
 Offline
 
 | 
			
			  | 
				
					|  Posted: Wed Sep 19, 2007 7:03 am     Post subject: |  |   |  |  
				| 
 |  
				| First things first, you should try to get/find the source to the plugin first - you aren't able to change anything if you haven't got the source files. 
 Not alot of plugins do matches with partial playernames, I'm pretty sure you have to make it yourself if you want it (not that much work though).
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Samapico No, these DO NOT look like penises, ok?
 
  
 Joined: May 08 2003
 Posts: 1252
 Offline
 
 | 
			
			  | 
				
					|  Posted: Wed Sep 19, 2007 12:46 pm     Post subject: |  |   |  |  
				| 
 |  
				| If you can find the code for it, you could use this method I made and use in my stuff: 
 
 	| 
Player* FindPlayerByName(char *name, bool exactmatch, _linkedlist <Player>* list);
 int FirstDifferentCharacter(char *string1, char *string2);
 
 Player* FindPlayerByName(char *name, bool exactmatch, _linkedlist <Player>* list)
 {
 _listnode <Player> *parse = list->head;   //set to first link of the player linked list
 Player* bestmatchplayer = NULL;
 int bestmatchlength = 0;
 
 String nametofind = name;
 nametofind.lcase();
 
 while (parse)   //parse will be NULL when we reach the last link
 {
 Player *p = parse->item;   //item is the actual data stored in the link
 String pname = (String) p->name;
 pname.lcase();
 
 if (pname == nametofind)
 return p;
 if (!exactmatch)
 {
 int firstdifferent = FirstDifferentCharacter(nametofind, pname);
 if (bestmatchlength < firstdifferent)
 {
 bestmatchlength = firstdifferent;
 bestmatchplayer = p;
 }
 }
 parse = parse->next;   //set parse to the next link
 }
 
 return bestmatchplayer;
 }
 
 
 //Zero-based index of the first different character in both string.
 //If both strings are the same, will return the length of the string.
 int FirstDifferentCharacter(char *string1, char *string2)
 {
 int i;
 for (i = 0 ; string1[i] != '\0' && string2[i] != '\0' && tolower(string1[i]) == tolower(string2[i]) ; i++)
 {
 }
 return i;
 }
 | 
 Just make sure you check that the return value != NULL before using it
 _________________
 (Insert a bunch of dead links here)
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Cyan~Fire I'll count you!
 
  
 
 Age:37
 Gender:
  Joined: Jul 14 2003
 Posts: 4608
 Location: A Dream
 Offline
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Wed Sep 19, 2007 3:02 pm     Post subject: |  |   |  |  
				| 
 |  
				| Mav: I do have the source. 
 Sam: I thought I might have to write that part myself.
 
 Cyan: Thanks, I'll try your function first.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Samapico No, these DO NOT look like penises, ok?
 
  
 Joined: May 08 2003
 Posts: 1252
 Offline
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Bak ?ls -s
 0 in
 
  
 Age:26
 Gender:
  Joined: Jun 11 2004
 Posts: 1826
 Location: USA
 Offline
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Maverick 
 
  
 Age:41
 Gender:
  Joined: Feb 26 2005
 Posts: 1521
 Location: The Netherlands
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 2:50 am     Post subject: |  |   |  |  
				| 
 |  
				| Guest, can you attach the source here for any future reference if people are searching for it? |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 3:41 am     Post subject: |  |   |  |  
				| 
 |  
				| Done. 
 
 
 
  lagbot-src.zip - 10.27 KB File downloaded or viewed 37 time(s)
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 3:58 am     Post subject: |  |   |  |  
				| 
 |  
				| Also for some reason when I compile the plugin right from the zip I get errors. 
 Error	3	error C2065: 'ifstream' : undeclared identifier	c:\.....\mervbot\src\lagbot\spawn.cpp	60
 
 Error	4	error C2146: syntax error : missing ';' before identifier 'file'	c:\...\spawn.cpp	60
 
 Error	5	error C3861: 'file': identifier not found	c:\....\spawn.cpp	60
 
 Error	6	error C2228: left of '.getline' must have class/struct/union	c:\....\spawn.cpp	62
 
 Error	7	fatal error C1903: unable to recover from previous error(s); stopping compilation	c:\...\spawn.cpp	62
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 4:05 am     Post subject: |  |   |  |  
				| 
 |  
				| I forgot to add that it was using #include <fstream.h> which is outdated so I changed it to #include <fstream> and it gave me the above errors. BTW, it wasn't compiling even before I made this minor change... 
 Anyone know exactly why?
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Bak ?ls -s
 0 in
 
  
 Age:26
 Gender:
  Joined: Jun 11 2004
 Posts: 1826
 Location: USA
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 10:15 am     Post subject: |  |   |  |  
				| 
 |  
				| after you do "#include <fstream>" you might need to do "using namespace std;" |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Guest 
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Thu Sep 20, 2007 3:29 pm     Post subject: |  |   |  |  
				| 
 |  
				| Thanks Bak, that did the trick. |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| blue monday Novice
 
  
 Joined: Nov 04 2005
 Posts: 75
 Offline
 
 | 
			
			  | 
				
					|  Posted: Tue Oct 30, 2007 2:13 pm     Post subject: |  |   |  |  
				| 
 |  
				| Would you be able to post the new one you made? I would love to only have to type half the name.   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |