Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 03-19-2011, 06:21 AM
nullify nullify is offline
Registerd Abuser
nullify's Avatar
Join Date: May 2004
Location: The cheese state.
Posts: 851
nullify has a spectacular aura about
Never gonna give you up...
Reply With Quote
  #3  
Old 03-19-2011, 06:36 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
There is no absolutely no reason to send your own account along with a trigger. All it does it open up the possibility for a memory editor to change their own account on clientside, which would allow you to send requests that look like they're from a different user.

Also, why not use GuiRadioCtrl instead of makeshift radio buttons using check boxes?

You should also enable closing the window. It's confusing from a UI perspective when you have to click a "Cancel" button instead of clicking the normal "x".

Nice work though, it's quite interesting.
__________________
Reply With Quote
  #4  
Old 03-20-2011, 02:08 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
Quote:
Originally Posted by cbk1994 View Post
There is no absolutely no reason to send your own account along with a trigger. All it does it open up the possibility for a memory editor to change their own account on clientside, which would allow you to send requests that look like they're from a different user.

Also, why not use GuiRadioCtrl instead of makeshift radio buttons using check boxes?

You should also enable closing the window. It's confusing from a UI perspective when you have to click a "Cancel" button instead of clicking the normal "x".

Nice work though, it's quite interesting.
- This is true, but for some reason it really didn't like it when I didn't send the players account along with the trigger; it was mainly for debugging purposes. Removed.

- Eh, I just like the boxes versus the circles. Not really affecting anything from a functionality standpoint, so not going to really bother with that one, but will keep it in mind for other GUIs.

- Agreed. Changed.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:21 AM.


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