View Single Post
  #8  
Old 05-23-2013, 03:54 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
The first thing you need to do is store the answer in a variable:

PHP Code:
function onActionTrivia(temp.question,temp.answer) {
  if (
player.guild != "Events Team") { // make sure they're allowed to host
    
return;
  }
  
  
showtext(19821.617.5"Arial""","Q: " temp.question);
  
changeimgzoom(198.8);
  
this.answer temp.answer.trim(); // store the answer

You don't need a timeout here; since this is a level NPC, you can just use onPlayerChats serverside:

PHP Code:
function onPlayerChats() {
  if (
player.chat.trim() == this.answer && this.answer != null) {
    
// the player won!
    
showtext(19821.617.5"Arial"""player.nick " has won!");
    
    
// reset the answer so nobody else can win this round
    
this.answer null;
  }

So, your serverside code can be pretty simple:

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

function 
onActionTrivia(temp.question,temp.answer) {
  if (
player.guild != "Events Team") { // make sure they're allowed to host
    
return;
  }
  
  
showtext(19821.617.5"Arial""","Q: " temp.question);
  
changeimgzoom(198.8);
  
this.answer temp.answer.trim(); // store the answer
}

function 
onPlayerChats() {
  if (
player.chat.trim() == this.answer && this.answer != null) {
    
// the player won!
    
showtext(19821.617.5"Arial"""player.nick " has won!");
    
    
// reset the answer so nobody else can win this round
    
this.answer null;
  }

__________________
Reply With Quote