View Single Post
  #1  
Old 03-19-2011, 05:43 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Youtube GuiFlash Player

Pretty straight forward. I used born2kill's flash player as a base; it can be found at http://forums.graalonline.com/forums...hp?t=134260372. Kind of glitchy as of right now, I'll fix it up when I have time. The only known glitch so far is the fact that you sometimes need to try twice to get the video to load, or just wait an extremely long time upon the first attempt if nothing pops up instantly. Dunno, just thought it would be kind of fun to mess around with it since I didn't see it anywhere else on the forums. If any other in-game GUIs are over it, it will not display the youtube player. It also downloads files for the autoplay feature, but that can be removed as it isn't really that necessary. Sadly there are only chat commands to destroy GUIs in case of freezing or to just get rid of the video. Haven't bothered adding any conveniences to it yet.

Video tag I used to test:
Op7yi9wzR5I (it's not a rick roll............. -_- see screen shots for what the video actually is, if you're that concerned)

PHP Code:
function onActionServerSide( afi, acc, svar ) {
  switch( 
afi ) {
    case 
"others": {
      
temp.r = findPlayerByCommunityName( acc ); // Receiving account
      
temp.i = svar; // Youtube tag
      
if ( player.account == temp.r ) {
        
player.chat = "Well, that just doesn't make any sense, does it?";
      }
      if ( 
temp.r != NULL ) {
        
temp.r.triggerClient( "gui", name, "acceptance", player.account, temp.i );
      } else {
        
triggerClient( "gui", name, "negative", temp.r );
      }
      break;
    }
  }
}

//#CLIENTSIDE

function onActionClientSide( afi, svar, svar2 ) {
  switch( 
afi ) {
    case 
"acceptance": {
      
player.chat = svar SPC "has requested that you watch a video!";
      
onAcceptanceGUI( svar, svar2 );
      break;
    }
    case 
"negative": {
      
player.chat = "The player you have requested (" @ svar @ ") was not found!";
      break;
    }
  }
}

function 
onWeaponFired() {
  
say2( "/youtube <- Opens options" NL
  
"/options <- In case the window" NL
  
"freezes, this will remove it" NL
  
"/video <- removes the video from" NL
  
"your screen" NL
  
"/acceptance <- In case the window" NL
  
"freezes, this will remove it" );
}

function 
onPlayerChats() {
  if ( 
player.chat == "/youtube" ) {
    
onOpenOptionsGUI();
    
player.chat = "Youtube options opened!";
  }
  if ( 
player.chat == "/options" && Options_Window1.visible ) {
    
Options_Window1.destroy();
  }
  if ( 
player.chat == "/video" && Youtube_Video.visible ) {
    
Youtube_Video.destroy();
  }
  if ( 
player.chat == "/acceptance" && Acceptance_Window1.visible ) {
    
Acceptance_Window1.destroy();
  }
}

function 
onOpenOptionsGUI() {
  new 
GuiWindowCtrl( "Options_Window1" ) {
    
profile = GuiBlueWindowProfile;
    
clientRelative = true;
    
clientExtent = "265,185";
    
canClose = true;
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Youtube Options Window";
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );

    new 
GuiScrollCtrl( "Options_MultiLine1_Scroll" ) {
      
profile = GuiBlueScrollProfile;
      
height = 185;
      
hScrollBar = "dynamic";
      
vScrollBar = "dynamic";
      
width = 143;

      new 
GuiMLTextCtrl( "Options_MultiLine1" ) {
        
profile = GuiBlueMLTextProfile;
        
height = 192;
        
horizSizing = "width";
        
htmlCompatibility = true;
        
text = "<center><b>Instructions</b><br><br>Enter the \"tag\" (fo0baR3a1 and nothing else) into the provided area. If you'd like to send this video to another player, click \"yes\" and type the community name of the player in the space provided.";
        
width = 118;
      }
    }
    
    new 
GuiTextEditCtrl( "Options_TextEdit1" ) {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 114;
      
x = 146;
      
y = 19;
    }
    
    new 
GuiTextCtrl( "Options_Text1" ) {
      
profile = GuiBlueTextProfile;
      
profile.fontColor = "black";
      
height = 20;
      
text = "Youtube Tag";
      
width = 70;
      
x = 165;
    }
    
    new 
GuiTextCtrl( "Options_Text2" ) {
      
profile = GuiBlueTextProfile;
      
profile.fontColor = "black";
      
height = 20;
      
text = "Send to another player?";
      
width = 116;
      
x = 147;
      
y = 56;
    }
    
    new 
GuiTextEditCtrl( "Options_TextEdit2" ) {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 114;
      
x = 146;
      
y = 116;
    }
    
    new 
GuiCheckBoxCtrl( "Options_CheckBox1" ) {
      
profile = GuiBlueCheckBoxProfile;
      
height = 20;
      
text = "Yes";
      
width = 36;
      
x = 147;
      
y = 77;
      
thiso.catchEvent( this, "onMouseUp", "onCheckYes" );
    }
    
    new 
GuiCheckBoxCtrl( "Options_CheckBox2" ) {
      
profile = GuiBlueCheckBoxProfile;
      
height = 20;
      
text = "No";
      
width = 30;
      
x = 215;
      
y = 77;
      
thiso.catchEvent( this, "onMouseUp", "onCheckNo" );
    }
    
    new 
GuiTextCtrl( "Options_Text3" ) {
      
profile = GuiBlueTextProfile;
      
profile.fontColor = "black";
      
height = 20;
      
text = "Account name:";
      
width = 73;
      
x = 163;
      
y = 97;
    }
    
    new 
GuiButtonCtrl( "Options_Button1" ) {
      
profile = GuiBlueButtonProfile;
      
height = 24;
      
text = "Go!";
      
width = 80;
      
x = 159;
      
y = 136;
    }
    
    new 
GuiButtonCtrl( "Options_Button2" ) {
      
profile = GuiBlueButtonProfile;
      
height = 24;
      
text = "Cancel";
      
width = 80;
      
x = 159;
      
y = 161;
    }
  }
  
Options_CheckBox2.checked = true;
  
Options_TextEdit2.active = false;
}

function 
Options_Button1.onAction() {
  if ( 
Options_CheckBox2.checked == true ) {
    
onOpenFlashGUI( Options_TextEdit1.text );
    
sleep( 1 );
    
Options_Window1.destroy();
  }
  if ( 
Options_CheckBox2.checked == false ) {
    if ( 
Options_TextEdit2.text != "" ) {
      if ( 
Options_TextEdit2.text != "Please enter an account name!" ) {
        
triggerServer( "gui", name, "others", Options_TextEdit2.text, Options_TextEdit1.text );
        
onOpenFlashGUI( Options_TextEdit1.text );
        
sleep( 1 );
        
Options_Window1.destroy();
      }
    } else {
      
Options_TextEdit2.text = "Please enter an account name!";
    }
  }
}

function 
Options_Button2.onAction() {
  
Options_Window1.destroy();
}

function 
onCheckYes() {
  
Options_CheckBox1.checked = true;
  
Options_TextEdit2.active = true;
  
Options_CheckBox2.checked = false;
}

function 
onCheckNo() {
  
Options_CheckBox2.checked = true;
  
Options_TextEdit2.active = false;
  
Options_CheckBox1.checked = false;
}

function 
onAcceptanceGUI( svar, svar2 ) {
  new 
GuiWindowCtrl( "Acceptance_Window1" ) {
    
profile = GuiBlueWindowProfile;
    
clientRelative = true;
    
clientExtent = "320,59";
    
canClose = true;
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Video Request!";
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );

    new 
GuiTextCtrl( "Acceptance_Text1" ) {
      
profile = GuiBlueTextProfile;
      
profile.fontColor = "black";
      
height = 20;
      
text = svar SPC "would like you to watch a video";
      
width = 234;
      
x = 14;
      
y = 4;
    }
    
    new 
GuiTextCtrl( "Acceptance_Text2" ) {
      
profile = GuiBlueTextProfile;
      
profile.fontColor = "black";
      
height = 20;
      
text = svar2;
      
width = 100;
      
x = 220;
      
y = 4;
    }
    
    new 
GuiButtonCtrl( "Acceptance_Button1" ) {
      
profile = GuiBlueButtonProfile;
      
text = "Accept";
      
width = 80;
      
x = 14;
      
y = 29;
    }
    
    new 
GuiButtonCtrl( "Acceptance_Button2" ) {
      
profile = GuiBlueButtonProfile;
      
text = "Decline";
      
width = 80;
      
x = 226;
      
y = 29;
    }
  }
}

function 
Acceptance_Button1.onAction() {
  
player.chat = Acceptance_Text2.text;
  
onOpenFlashGUI( Acceptance_Text2.text );
  
sleep( 2 );
  
Acceptance_Window1.destroy();
}

function 
Acceptance_Button2.onAction() {
  
Acceptance_Window1.destroy();
}

function 
onOpenFlashGUI( svar ) {
  new 
GuiFlash( "Youtube_Video" ) {
    
width = 768;
    
height = 432;
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );
    
requiresActiveX = false;
    
requiresPlugin = false;
    
tryActiveX = true;
    
tryPlugin = true;
    
loopMovie = false;
    
downloadWebFiles = true;
    
movieName = "http://www.youtube.com/v/" @ svar @ "&autoplay=1";
  }
  
  new 
GuiFlash( "Youtube_Loader" ) {
    
x = Youtube_Video.x;
    
y = Youtube_Movie.y;
    
width = Youtube_Movie.width;
    
height = Youtube_Movie.height;
    
requiresActiveX = false;
    
requiresPlugin = false;
    
tryActiveX = true;
    
tryPlugin = true;
    
loopMovie = false;
    
downloadWebFiles = true;
    
moviename = "";
  }
  
sleep( 2 );
  
Youtube_Loader.destroy();
} 
Added default closing of GUIs along with the cancel button.
Removed the players account from triggers.
Attached Thumbnails
Click image for larger version

Name:	screenie1.png
Views:	270
Size:	33.8 KB
ID:	52567   Click image for larger version

Name:	screenie2.png
Views:	277
Size:	23.9 KB
ID:	52568   Click image for larger version

Name:	screenie3.png
Views:	288
Size:	17.3 KB
ID:	52569  

Last edited by devilsknite1; 03-20-2011 at 03:16 AM.. Reason: Script edit
Reply With Quote