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(198, 21.6, 17.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(198, 21.6, 17.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() {
setshape( 1, 32, 32 );
setimg( "zoneiphone_tv.png" );
}
function onActionTrivia(temp.question,temp.answer) {
if (player.guild != "Events Team") { // make sure they're allowed to host
return;
}
showtext(198, 21.6, 17.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(198, 21.6, 17.5, "Arial", "", player.nick @ " has won!");
// reset the answer so nobody else can win this round
this.answer = null;
}
}