Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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 onActionServerSideafiaccsvar ) {
  switch( 
afi ) {
    case 
"others": {
      
temp.findPlayerByCommunityNameacc ); // Receiving account
      
temp.svar// Youtube tag
      
if ( player.account == temp.) {
        
player.chat "Well, that just doesn't make any sense, does it?";
      }
      if ( 
temp.!= NULL ) {
        
temp.r.triggerClient"gui"name"acceptance"player.accounttemp.);
      } else {
        
triggerClient"gui"name"negative"temp.);
      }
      break;
    }
  }
}

//#CLIENTSIDE

function onActionClientSideafisvarsvar2 ) {
  switch( 
afi ) {
    case 
"acceptance": {
      
player.chat svar SPC "has requested that you watch a video!";
      
onAcceptanceGUIsvarsvar2 );
      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";
    
screenwidth - ( width );
    
screenheight - ( height );

    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;
      
146;
      
19;
    }
    
    new 
GuiTextCtrl"Options_Text1" ) {
      
profile GuiBlueTextProfile;
      
profile.fontColor "black";
      
height 20;
      
text "Youtube Tag";
      
width 70;
      
165;
    }
    
    new 
GuiTextCtrl"Options_Text2" ) {
      
profile GuiBlueTextProfile;
      
profile.fontColor "black";
      
height 20;
      
text "Send to another player?";
      
width 116;
      
147;
      
56;
    }
    
    new 
GuiTextEditCtrl"Options_TextEdit2" ) {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 114;
      
146;
      
116;
    }
    
    new 
GuiCheckBoxCtrl"Options_CheckBox1" ) {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
text "Yes";
      
width 36;
      
147;
      
77;
      
thiso.catchEventthis"onMouseUp""onCheckYes" );
    }
    
    new 
GuiCheckBoxCtrl"Options_CheckBox2" ) {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
text "No";
      
width 30;
      
215;
      
77;
      
thiso.catchEventthis"onMouseUp""onCheckNo" );
    }
    
    new 
GuiTextCtrl"Options_Text3" ) {
      
profile GuiBlueTextProfile;
      
profile.fontColor "black";
      
height 20;
      
text "Account name:";
      
width 73;
      
163;
      
97;
    }
    
    new 
GuiButtonCtrl"Options_Button1" ) {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "Go!";
      
width 80;
      
159;
      
136;
    }
    
    new 
GuiButtonCtrl"Options_Button2" ) {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "Cancel";
      
width 80;
      
159;
      
161;
    }
  }
  
Options_CheckBox2.checked true;
  
Options_TextEdit2.active false;
}

function 
Options_Button1.onAction() {
  if ( 
Options_CheckBox2.checked == true ) {
    
onOpenFlashGUIOptions_TextEdit1.text );
    
sleep);
    
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.textOptions_TextEdit1.text );
        
onOpenFlashGUIOptions_TextEdit1.text );
        
sleep);
        
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 
onAcceptanceGUIsvarsvar2 ) {
  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!";
    
screenwidth - ( width );
    
screenheight - ( height );

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

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

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

function 
onOpenFlashGUIsvar ) {
  new 
GuiFlash"Youtube_Video" ) {
    
width 768;
    
height 432;
    
screenwidth - ( width );
    
screenheight - ( height );
    
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" ) {
    
Youtube_Video.x;
    
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);
  
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:	264
Size:	33.8 KB
ID:	52567   Click image for larger version

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

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

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.