Quote:
	
	
		
			
				
					Originally Posted by  gwFCCtennis
					 
				 
				Have you uploaded the image into levels/images or possibly levels/hats? 
This should work, but the script Cyan posted should work.
 
	PHP Code: 
	
		
			
//#CLIENTSIDE
 function onPlayerChats() {
   if (player.chat.starts("sethat")) {
     player.attr[1] = client.ishat = player.chat.tokenize()[1];
   }
 } 
 
		
	 
  
			
		 | 
	
	
 Tokenize isn't good for single-parameter commands, it just ends up requiring players to use "quotes" down the line.
onPlayerChats is also a "deprecated" (imo) way of checking for chat commands on the client-side considering we can access the ChatBar directly.
Here's a pretty generic "sethat" using the ChatBar method.
	PHP Code:
	
		
			
//#CLIENTSIDE
// This event is called when the player presses enter with the ChatBar
// open. Which basically happens every time the player chats.
function ChatBar.onAction() {
  // Define the Command to check for
  temp.cmd = "sethat ";
  // Check if Text in ChatBar starts with the command
  if (ChatBar.text.starts(temp.cmd)) {
    // Determine the Command's Parameter
    temp.param = ChatBar.text.substring(temp.cmd.length()).trim();
    // Make sure Hat name ends with .png, .gif, or .mng
    if (checkHat(temp.param)) {
      // Set the Player's Hat to the Passed Parameter
      player.attr[1] = temp.param;
    }
    // Reset ChatBar text to prevent the player from saying the command in chat
    ChatBar.text = "";
  }
}
function checkHat(hatimg) {
  if (hatimg.ends(".png") || hatimg.ends(".gif") || hatimg.ends(".mng")) {
    return true;
  } else {
    return false;
  }
} 
		
	
 Quick demo of substring, and trim.
	PHP Code:
	
		
			
function onCreated() {
  // string_variable.substring(start_position, length)
  // start_position is the letter it starts with first. Like arrays this is 
  // also zero-based. So in our example start_position 2 is "l"
  // If you don't specify length it just uses everything after it.
  // Note: When you're using this in commands you want the starting
  // position to be after the space in your command.
  temp.str = "Hello World";
  echo(temp.str.substring(6)); // echos "World"
  echo(temp.str.substring(0, 5)); // echos "Hello"
  
  // string_variable.trim()
  // Trims off spaces in the front and back of a string, useful for commands.
  temp.str = "  HELLO WORLD!  ";
  echo(temp.str.trim()); // echos "HELLO WORLD!"
  // Due to the fact that both trim and substring return strings you can
  // use them in a chain like I did in my sethat example. I.e:
  temp.str = "sethat averystupidhat.png  ";
  echo(temp.str.substring(7).trim()); // echos "averystupidhat.png"
} 
		
	
 If your hats still don't work, you're probably not giving the right folder access (button on the top-right corner next to server flags) to your server.
It'll need these lines added to it if you're uploading to levels/hats:
	PHP Code:
	
		
			
file  hats/*.png
file  hats/*.gif
file  hats/*.mng