View Single Post
  #7  
Old 05-23-2013, 03:05 AM
baseman101 baseman101 is offline
Scripter
baseman101's Avatar
Join Date: Nov 2012
Location: Purcellville, VA
Posts: 76
baseman101 will become famous soon enough
Hey, thanks for your consideration! I've done some triggers once I've got a hold of them, and here's my current code. The current problem is that it doesn't resister if someone wins. I know the variable gets sent, because I've added this.chat=temp.answer previously from serverside. Also, I'm going to add the tokenize function later once I get the main idea down. Sorry, I've tried looking for scripting resources, but no ado. Thank you!

PHP Code:
function onCreated() {
  
setshape13232 );
  
setimg"zoneiphone_tv.png" );
}

function 
onActionTrivia(temp.question,temp.answer) {
  
showtext(19821.617.5"Arial""","Q: " temp.question);
  
changeimgzoom 198,.8;
  
onTimeout(temp.answer); //calls the timeout function with the temp.answer variable
}
function 
onTimeout(temp.answer) {
  for(
temp.pl allplayers) { //gets player in the level
    
if(temp.pl.level.name != "zone_event-trivia.nw") continue; //doesn't count players outside this level
    
if(temp.pl == temp.answer) { //checks if someone wins the event
      
showtext(19821.617.5"Arial""",temp.pl.nick " has won!");
    }
  }
  
setTimer(0.5); //loops it
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat=="/trivia" && player.guild=="Events Team") {
    
showTriviaGUI();
  }
}
function 
showTriviaGUI() {
    new 
GuiWindowCtrl("EventTrivia_Window1") {
    
profile GuiBlueWindowProfile;
    
style $pref::Video::defaultguistyle;
    
clientrelative true;
    
clientextent "384,164";

    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canclose false;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Trivia";
    
288;
    
173;
    new 
GuiTextCtrl("EventTrivia_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Please fill out the  text boxes.";
      
width 167;
      
7;
    }
    new 
GuiTextEditCtrl("EventTrivia_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 300;
      
84;
      
37;
    }
    new 
GuiTextCtrl("EventTrivia_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Question";
      
width 53;
      
34;
    }
    new 
GuiTextCtrl("EventTrivia_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Answer";
      
width 42;
      
74;
    }
    new 
GuiTextEditCtrl("EventTrivia_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 300;
      
84;
      
77;
    }
    new 
GuiButtonCtrl("EventTrivia_Button1") {
      
profile GuiBlueButtonProfile;
      
text "Submit Quesiton";
      
width 385;
      
134;
    }
  }
}
function 
EventTrivia_Button1.onAction() {
  
temp.question EventTrivia_TextEdit1.text;
  
temp.answer EventTrivia_TextEdit2.text;
  
EventTrivia_Window1.destroy();
  
temp.= (GraalControl.width width) / 2//attempt to make the trivia box half of the screen width. help please?
  
triggeraction(this.x,this.y,"Trivia",temp.question,temp.answer); //triggers the server


Last edited by baseman101; 05-23-2013 at 03:05 AM.. Reason: Added comments to make code easier to understand
Reply With Quote