<?php
function main_code(unique_id,event,nr_args,args)
{
	event=args[0];
	if(unique_id==0&&event!=1&&event!=2)
	{
		send_data_to_player(unique_id,[2,0]);//force log in
	}else{
	
	if(event==1)
			{
				//REGISTER ACCOUNT  
				//INPUT:arg1-username  arg2-password
				//OUTPUT:arg1- state  arg2 -unique id
				if(isset(args[1])&&isset(args[2]))
				{
					username=args[1];
					password=args[2];
					if(check_string(username) and check_string(password) and !(is_numeric(password)) and !(is_numeric(username)))
					{
						if(file_exists("accounts/".username.".txt"))
						{
							send_data_to_player(unique_id,[1,0]);//the account already exists
						}else{
							last_unique_id=read_file("server_vars/player.txt") + 1;
							write_file("server_vars/player.txt",last_unique_id);
							
							write_file("username_id/".username.".txt",last_unique_id);
							write_file("accounts/".username.".txt",password);
							
							make_dir('players/'.last_unique_id.'/');//create the id directory
							init_player(last_unique_id,username);
							
							send_data_to_player(unique_id,[1,1,last_unique_id]);//succesfull created account
						}
					}else{
						send_data_to_player(unique_id,[1,4]);//invalid characters used
					}
				}
			}
		else if(event==2)
			{
			//LOG IN
			//INPUT:arg1-username  arg2-password
			//OUTPUT:arg1- state  arg2 -unique id arg3- local id
				if(isset(args[1])&&isset(args[2]))
				{
					username=args[1];
					password=args[2];
					if(check_string(username) and check_string(password) and !(is_numeric(password)) and !(is_numeric(username)))
					{
						if(file_exists("accounts/".username.".txt"))
						{
							real_password=read_file("accounts/".username.".txt");
							if(real_password==password)
							{
								local_id_slot=find_local_id(0);
								if(local_id_slot!=0)
								{
									if(file_exists("ip_login/".get_player_ip().".txt"))
									{
										unique_id_real = get_unique_id_by_username(username);
										send_data_to_player(unique_id,[2,2,unique_id_real,get_local_id_by_ip()]);//succesfull log in	
										send_initial_players(unique_id_real);
									}else{
										unique_id_real =get_unique_id_by_username(username);
										write_file("ip_login/".get_player_ip().".txt",local_id_slot);
										write_file("local_id/".local_id_slot.".txt",unique_id_real);
										write_file("players/".unique_id_real."/active.txt",1);
										write_file("players/".unique_id_real."/last_time_active.txt",time());
										write_file("players/".unique_id_real."/ip.txt",get_player_ip());
										write_file("players/".unique_id_real."/local_id.txt",local_id_slot);
										write_file("players/".unique_id_real."/ping.txt",0);
										write_file("players/".unique_id_real."/ping_var.txt",0);
										send_data_to_player(unique_id,[2,2,unique_id_real,local_id_slot]);//succesfull log in	
										send_initial_players(unique_id);
										
										ti_on_player_connect(unique_id_real);
										
										}
								}else{
									send_data_to_player(unique_id,[2,3]);//the server is full	
								}
							}else{
								send_data_to_player(unique_id,[2,1]);//invalid user or pass
							}
						}else{
							send_data_to_player(unique_id,[2,1]);//invalid user or pass
						}
					}else{
						send_data_to_player(unique_id,[2,4]);//invalid characters used
					}
				}
			}
		else if(event==3)
			{
				//CHAT
				//Input arg1 - message
				if(isset(args[1]))
				{
					message = args[1];
					if(message=='')
					{
					}else{
						if(is_numeric(message))
						{
							message = message.' ';
						}
						username=get_player_username(unique_id);
						for(i=1;i<=10;i++)
						{
							u_id = get_unique_id_by_local(i);
							if(u_id!=0)
							{
								send_data_to_player(u_id,[3,message,username],2);
							}
						}
					}
					
				}
			}
		else if(event==4)
			{
				//SAVE PLAYER POSITION
				//Input: arg1-x arg2-y arg3-rotation
				//output:none
				if(isset(args[1]) and isset(args[2]) and isset(args[3]))
				{
					x=args[1];
					y=args[2];
					rot=args[3];
					global allow_teleport;
					
					if(allow_teleport)
					{
						set_position(unique_id,x,y,rot);	
					}else{
						position=get_position(unique_id);
						old_x=position[0];
						old_y=position[1];
						old_rot=position[2];
						distance=sqrt( pow(old_x - x , 2)  +  pow(old_y - y , 2) );
						if(distance < 1000)
							{
								set_position(unique_id,x,y,rot);
							}
						else
							{
								to_send[0]=5;
								to_send[1]=old_x;
								to_send[2]=old_y;
								to_send[3]=old_rot;
								
								send_data_to_player(unique_id,to_send);
								// send_data_to_player(unique_id,[15," ".distance,0xFF0000],1);
							}
					}
				}
			}
		else if(event==6)
		{
				//SEND PLAYERS POSITION
				//Input:none
				//Output:arg1 - number of players  arg2 - local player id arg3 - x arg4- y arg5 - rot arg6 -local player id ....
				number_of_players=0;
				to_send[0]=6;
				c=2;
				for(i=1;i<=10;i++)
				{
					u_id=get_unique_id_by_local(i);
					if(u_id!=0 and u_id!=unique_id)
					{
						number_of_players++;
						to_send[c]=i;
						c++;
						
						position=get_position(u_id);
						x=position[0];
						y=position[1];
						rot=position[2];
						
						to_send[c]=x;
						c++;
						to_send[c]=y;
						c++;
						to_send[c]=rot;
						c++;
					}
				}
				c--;
				to_send[1]=number_of_players;
				
				send_data_to_player(unique_id,to_send);
		}
		else if(event==9)
			{
				//PING
				if(isset(args[1]))
				{
					if(args[1]==0)
					{
						write_file("players/".unique_id."/ping_var.txt",round(microtime_float(), 2));
						send_data_to_player(unique_id,[9,1]);
					}else{
						time=read_file("players/".unique_id."/ping_var.txt");
						ping=round(round(round(microtime_float(), 2) - round(time,2),2)*100);
						write_file("players/".unique_id."/ping.txt",ping);
						write_file("players/".unique_id."/ping_var.txt",0);
						
						c=2;
						data[0]=9;
						data[1]=0;
						for(i=1;i<=10;i++)
						{
							u_id=get_unique_id_by_local(i);
							if(u_id!=0)
							{
								data[c]=read_file("players/".u_id."/ping.txt");
								c++;
							}else{
								data[c]=0;
								c++;
							}
						}
						
						send_data_to_player(unique_id,data);
					}
				}
			}
		else if(event==10)
			{
				//SEND PLAYER INVENTORY
				inv=read_file("players/".unique_id."/inventory.txt");
				inv=explode("|",inv);
				inv[0]=10;
				send_data_to_player(unique_id,inv);
			}
		else if(event==11)
			{
				//SEND PLAYER GOLD
				send_data_to_player(unique_id,[11,get_gold(unique_id)]);
			}
		else if(event==14)
			{
				//SEND PLAYER TROOPS
				troops=read_file("players/".unique_id."/troops.txt");
				troops=explode("|",troops);
				nr=0;
				foreach (a as troops) 
				{
					if(a!=-1)
						nr++;
				}
				troops[0]=14;
				troops[1]=nr+2;//incrementing here, so we will not have to increment in the game
				send_data_to_player(unique_id,troops);
			}
		}
	}

?>

I want to use username without password. Rework the code so that you can successfully log in using username only