Thread: GUI Help
View Single Post
  #9  
Old 03-30-2011, 11:33 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
So, I thought the object might have a maxchars variable to limit the amount of characters typed but apparently it doesn't. Anyhoo,

PHP Code:
function onActionServerSide() {
  if (
params[0] == "changenick") {
    
player.nick params[1];
    
player.chat "Your nick has been changed";
  }
}

//#CLIENTSIDE
function onCreated() {
  if (
test_window != NULLtest_window.destroy();
  new 
GuiWindowCtrl("test_window") {
    
profile GuiBlueWindowProfile;
    
resize(1,1,200,100);
    
text "blah";
  
    new 
GuiTextEditCtrl("nicknametext") {
      
profile GuiBlueTextEditProfile;
      
resize(10,45,160,30);
      
text "Type here!";
    }
  }
  
//onDebug(nicknametext);
}

function 
nicknametext.onMouseDown() {
  if (!
nicknametext.clickedonce) {
    
nicknametext.text "";
    
nicknametext.clickedonce true;
  }
}

function 
nicknametext.onTextChanged() {
  if (
nicknametext.text.length() > 10)
    
nicknametext.text nicknametext.text.substring(0,10);
}

function 
nicknametext.onAction()
  
triggerserver("gui"this.name"changenick"nicknametext.text);
  


/* Debug method
  Press f2 after calling this function */
function onDebug(obj) {
  
say2("Press f2 to read output!");
  echo(
"\nFUNCTIONS");
  for (
obj.getfunctions())
    echo(
f);
  echo(
"\nVARIABLES");
  for (
obj.getvarnames())
    
printf("%s=%s"fobj.(@f));
  echo(
"\nPROFILE VARS");
  for (
fobj.profile.getvarnames())
    
printf("%s=%s"fobj.profile.(@f));

If you uncomment the onDebug() line, you can run that script then press F2 in game and it will show you all the functions/variables available for that object which can be useful to determine what the object is capable of. Can change it to onDebug(test_window) or even onDebug(player) to see the different functions/variables for objects
Reply With Quote